diff --git a/lib/ko/diagnosticMessages.generated.json b/lib/ko/diagnosticMessages.generated.json index abda4ace91fd7..fb77b68ac6785 100644 --- a/lib/ko/diagnosticMessages.generated.json +++ b/lib/ko/diagnosticMessages.generated.json @@ -885,7 +885,7 @@ "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701": "개체 rest 할당의 대상은 변수 또는 속성 액세스여야 합니다.", "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684": "'{0}' 형식의 'this' 컨텍스트를 메서드의 '{1}' 형식 'this'에 할당할 수 없습니다.", "The_this_types_of_each_signature_are_incompatible_2685": "각 시그니처의 'this' 형식이 호환되지 않습니다.", - "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453": "형식 매개 변수 '{0}'의 형식 인수를 유추할 수 없습니다. 형식 인수를 명시적으로 지정하세요.", + "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453": "사용량에서 형식 매개 변수 '{0}'의 형식 인수를 유추할 수 없습니다. 형식 인수를 명시적으로 지정하세요.", "The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value__2547": "비동기 반복기의 'next()' 메서드에서 반환하는 형식은 'value' 속성이 있는 형식에 대한 프라미스여야 합니다.", "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490": "반복기의 'next()' 메서드에 의해 반환되는 형식에는 'value' 속성이 있어야 합니다.", "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189": "'for...in' 문의 변수 선언에 이니셜라이저가 포함될 수 없습니다.", @@ -1067,7 +1067,7 @@ "or_expected_1144": "'{' 또는 ';'이(가) 필요합니다.", "package_json_does_not_have_a_0_field_6100": "'package.json'에는 '{0}' 필드가 없습니다.", "package_json_has_0_field_1_that_references_2_6101": "'package.json'에 '{2}'을(를) 참조하는 '{0}' 필드 '{1}'이(가) 있습니다.", - "parameter_modifiers_can_only_be_used_in_a_ts_file_8012": "'parameter modifiers'는 .ts 파일에서만 사용할 수 있습니다.", + "parameter_modifiers_can_only_be_used_in_a_ts_file_8012": "'매개 변수 한정자'는 .ts 파일에서만 사용할 수 있습니다.", "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091": "'paths' 옵션이 지정되었습니다. 모듈 이름 '{0}'과(와) 일치하는 패턴을 찾는 중입니다.", "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024": "'readonly' 한정자는 속성 선언 또는 인덱스 시그니처에만 나타날 수 있습니다.", "require_call_may_be_converted_to_an_import_80005": "'require' 호출이 가져오기로 변환될 수 있습니다.", diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 92500ffc046be..da1ba2985dc15 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -2750,7 +2750,7 @@ interface CSSStyleDeclaration { alignContent: string; alignItems: string; alignSelf: string; - alignmentBaseline: string | null; + alignmentBaseline: string; animation: string; animationDelay: string; animationDirection: string; @@ -2760,65 +2760,83 @@ interface CSSStyleDeclaration { animationName: string; animationPlayState: string; animationTimingFunction: string; - backfaceVisibility: string | null; - background: string | null; - backgroundAttachment: string | null; - backgroundClip: string | null; - backgroundColor: string | null; - backgroundImage: string | null; - backgroundOrigin: string | null; - backgroundPosition: string | null; - backgroundPositionX: string | null; - backgroundPositionY: string | null; - backgroundRepeat: string | null; - backgroundSize: string | null; - baselineShift: string | null; - border: string | null; - borderBottom: string | null; - borderBottomColor: string | null; - borderBottomLeftRadius: string | null; - borderBottomRightRadius: string | null; - borderBottomStyle: string | null; - borderBottomWidth: string | null; - borderCollapse: string | null; - borderColor: string | null; - borderImage: string | null; - borderImageOutset: string | null; - borderImageRepeat: string | null; - borderImageSlice: string | null; - borderImageSource: string | null; - borderImageWidth: string | null; - borderLeft: string | null; - borderLeftColor: string | null; - borderLeftStyle: string | null; - borderLeftWidth: string | null; - borderRadius: string | null; - borderRight: string | null; - borderRightColor: string | null; - borderRightStyle: string | null; - borderRightWidth: string | null; - borderSpacing: string | null; - borderStyle: string | null; - borderTop: string | null; - borderTopColor: string | null; - borderTopLeftRadius: string | null; - borderTopRightRadius: string | null; - borderTopStyle: string | null; - borderTopWidth: string | null; - borderWidth: string | null; - bottom: string | null; - boxShadow: string | null; + backfaceVisibility: string; + background: string; + backgroundAttachment: string; + backgroundClip: string; + backgroundColor: string; + backgroundImage: string; + backgroundOrigin: string; + backgroundPosition: string; + backgroundPositionX: string; + backgroundPositionY: string; + backgroundRepeat: string; + backgroundSize: string; + baselineShift: string; + blockSize: string; + border: string; + borderBlockEnd: string; + borderBlockEndColor: string; + borderBlockEndStyle: string; + borderBlockEndWidth: string; + borderBlockStart: string; + borderBlockStartColor: string; + borderBlockStartStyle: string; + borderBlockStartWidth: string; + borderBottom: string; + borderBottomColor: string; + borderBottomLeftRadius: string; + borderBottomRightRadius: string; + borderBottomStyle: string; + borderBottomWidth: string; + borderCollapse: string; + borderColor: string; + borderImage: string; + borderImageOutset: string; + borderImageRepeat: string; + borderImageSlice: string; + borderImageSource: string; + borderImageWidth: string; + borderInlineEnd: string; + borderInlineEndColor: string; + borderInlineEndStyle: string; + borderInlineEndWidth: string; + borderInlineStart: string; + borderInlineStartColor: string; + borderInlineStartStyle: string; + borderInlineStartWidth: string; + borderLeft: string; + borderLeftColor: string; + borderLeftStyle: string; + borderLeftWidth: string; + borderRadius: string; + borderRight: string; + borderRightColor: string; + borderRightStyle: string; + borderRightWidth: string; + borderSpacing: string; + borderStyle: string; + borderTop: string; + borderTopColor: string; + borderTopLeftRadius: string; + borderTopRightRadius: string; + borderTopStyle: string; + borderTopWidth: string; + borderWidth: string; + bottom: string; + boxShadow: string; boxSizing: string; - breakAfter: string | null; - breakBefore: string | null; - breakInside: string | null; - captionSide: string | null; + breakAfter: string; + breakBefore: string; + breakInside: string; + captionSide: string; caretColor: string; - clear: string | null; + clear: string; clip: string; clipPath: string; clipRule: string; color: string | null; + colorInterpolation: string; colorInterpolationFilters: string; columnCount: string; columnFill: string; @@ -2830,28 +2848,29 @@ interface CSSStyleDeclaration { columnSpan: string; columnWidth: string; columns: string; - content: string | null; - counterIncrement: string | null; - counterReset: string | null; + content: string; + counterIncrement: string; + counterReset: string; cssFloat: string | null; cssText: string; cursor: string; direction: string; - display: string | null; - dominantBaseline: string | null; - emptyCells: string | null; + display: string; + dominantBaseline: string; + emptyCells: string; enableBackground: string | null; - fill: string | null; - fillOpacity: string | null; - fillRule: string | null; + fill: string; + fillOpacity: string; + fillRule: string; filter: string; - flex: string | null; - flexBasis: string | null; - flexDirection: string | null; - flexFlow: string | null; - flexGrow: string | null; - flexShrink: string | null; - flexWrap: string | null; + flex: string; + flexBasis: string; + flexDirection: string; + flexFlow: string; + flexGrow: string; + flexShrink: string; + flexWrap: string; + float: string; floodColor: string; floodOpacity: string; font: string; @@ -2873,29 +2892,30 @@ interface CSSStyleDeclaration { gap: string; glyphOrientationHorizontal: string | null; glyphOrientationVertical: string; - grid: string | null; - gridArea: string | null; - gridAutoColumns: string | null; - gridAutoFlow: string | null; - gridAutoRows: string | null; - gridColumn: string | null; - gridColumnEnd: string | null; + grid: string; + gridArea: string; + gridAutoColumns: string; + gridAutoFlow: string; + gridAutoRows: string; + gridColumn: string; + gridColumnEnd: string; gridColumnGap: string; - gridColumnStart: string | null; + gridColumnStart: string; gridGap: string; - gridRow: string | null; - gridRowEnd: string | null; + gridRow: string; + gridRowEnd: string; gridRowGap: string; - gridRowStart: string | null; - gridTemplate: string | null; - gridTemplateAreas: string | null; - gridTemplateColumns: string | null; - gridTemplateRows: string | null; - height: string | null; + gridRowStart: string; + gridTemplate: string; + gridTemplateAreas: string; + gridTemplateColumns: string; + gridTemplateRows: string; + height: string; hyphens: string; imageOrientation: string; imageRendering: string; imeMode: string | null; + inlineSize: string; justifyContent: string; justifyItems: string; justifySelf: string; @@ -2905,25 +2925,29 @@ interface CSSStyleDeclaration { layoutGridLine: string | null; layoutGridMode: string | null; layoutGridType: string | null; - left: string | null; + left: string; readonly length: number; letterSpacing: string; lightingColor: string; lineBreak: string; - lineHeight: string | null; - listStyle: string | null; - listStyleImage: string | null; - listStylePosition: string | null; - listStyleType: string | null; - margin: string | null; - marginBottom: string | null; - marginLeft: string | null; - marginRight: string | null; - marginTop: string | null; - marker: string | null; - markerEnd: string | null; - markerMid: string | null; - markerStart: string | null; + lineHeight: string; + listStyle: string; + listStyleImage: string; + listStylePosition: string; + listStyleType: string; + margin: string; + marginBlockEnd: string; + marginBlockStart: string; + marginBottom: string; + marginInlineEnd: string; + marginInlineStart: string; + marginLeft: string; + marginRight: string; + marginTop: string; + marker: string; + markerEnd: string; + markerMid: string; + markerStart: string; mask: string; maskComposite: string; maskImage: string; @@ -2931,10 +2955,14 @@ interface CSSStyleDeclaration { maskRepeat: string; maskSize: string; maskType: string; - maxHeight: string | null; - maxWidth: string | null; - minHeight: string | null; - minWidth: string | null; + maxBlockSize: string; + maxHeight: string; + maxInlineSize: string; + maxWidth: string; + minBlockSize: string; + minHeight: string; + minInlineSize: string; + minWidth: string; msContentZoomChaining: string | null; msContentZoomLimit: string | null; msContentZoomLimitMax: any; @@ -2985,8 +3013,8 @@ interface CSSStyleDeclaration { objectFit: string; objectPosition: string; opacity: string | null; - order: string | null; - orphans: string | null; + order: string; + orphans: string; outline: string; outlineColor: string; outlineOffset: string; @@ -2997,45 +3025,51 @@ interface CSSStyleDeclaration { overflowWrap: string; overflowX: string; overflowY: string; - padding: string | null; - paddingBottom: string | null; - paddingLeft: string | null; - paddingRight: string | null; - paddingTop: string | null; - pageBreakAfter: string | null; - pageBreakBefore: string | null; - pageBreakInside: string | null; + padding: string; + paddingBlockEnd: string; + paddingBlockStart: string; + paddingBottom: string; + paddingInlineEnd: string; + paddingInlineStart: string; + paddingLeft: string; + paddingRight: string; + paddingTop: string; + pageBreakAfter: string; + pageBreakBefore: string; + pageBreakInside: string; + paintOrder: string; readonly parentRule: CSSRule; penAction: string | null; - perspective: string | null; - perspectiveOrigin: string | null; + perspective: string; + perspectiveOrigin: string; placeContent: string; placeItems: string; placeSelf: string; pointerEvents: string | null; - position: string | null; - quotes: string | null; + position: string; + quotes: string; resize: string; - right: string | null; - rotate: string | null; + right: string; + rotate: string; rowGap: string; rubyAlign: string | null; rubyOverhang: string | null; rubyPosition: string | null; - scale: string | null; + scale: string; scrollBehavior: string; + shapeRendering: string; stopColor: string | null; stopOpacity: string | null; - stroke: string | null; - strokeDasharray: string | null; - strokeDashoffset: string | null; - strokeLinecap: string | null; - strokeLinejoin: string | null; - strokeMiterlimit: string | null; - strokeOpacity: string | null; - strokeWidth: string | null; + stroke: string; + strokeDasharray: string; + strokeDashoffset: string; + strokeLinecap: string; + strokeLinejoin: string; + strokeMiterlimit: string; + strokeOpacity: string; + strokeWidth: string; tabSize: string; - tableLayout: string | null; + tableLayout: string; textAlign: string; textAlignLast: string; textAnchor: string | null; @@ -3054,25 +3088,26 @@ interface CSSStyleDeclaration { textKashidaSpace: string | null; textOrientation: string; textOverflow: string; + textRendering: string; textShadow: string; textTransform: string; textUnderlinePosition: string; - top: string | null; + top: string; touchAction: string; transform: string; transformBox: string; transformOrigin: string; - transformStyle: string | null; + transformStyle: string; transition: string; transitionDelay: string; transitionDuration: string; transitionProperty: string; transitionTimingFunction: string; - translate: string | null; + translate: string; unicodeBidi: string; userSelect: string; - verticalAlign: string | null; - visibility: string | null; + verticalAlign: string; + visibility: string; /** @deprecated */ webkitAlignContent: string; /** @deprecated */ @@ -3228,14 +3263,14 @@ interface CSSStyleDeclaration { webkitUserSelect: string | null; webkitWritingMode: string | null; whiteSpace: string; - widows: string | null; - width: string | null; + widows: string; + width: string; willChange: string; wordBreak: string; wordSpacing: string; wordWrap: string; writingMode: string; - zIndex: string | null; + zIndex: string; zoom: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; @@ -3445,7 +3480,7 @@ interface CanvasRect { } /** The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a element. It is used for drawing shapes, text, images, and other objects. */ -interface CanvasRenderingContext2D extends CanvasState, CanvasTransform, CanvasCompositing, CanvasImageSmoothing, CanvasFillStrokeStyles, CanvasShadowStyles, CanvasFilters, CanvasRect, CanvasDrawPath, CanvasUserInterface, CanvasText, CanvasDrawImage, CanvasImageData, CanvasPathDrawingStyles, CanvasTextDrawingStyles, CanvasPath { +interface CanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface { readonly canvas: HTMLCanvasElement; } @@ -3527,7 +3562,7 @@ declare var ChannelSplitterNode: { }; /** The CharacterData abstract interface represents a Node object that contains characters. This is an abstract interface, meaning there aren't any object of type CharacterData: it is implemented by other interfaces, like Text, Comment, or ProcessingInstruction which aren't abstract. */ -interface CharacterData extends Node, NonDocumentTypeChildNode, ChildNode { +interface CharacterData extends Node, ChildNode, NonDocumentTypeChildNode { data: string; readonly length: number; appendData(data: string): void; @@ -4469,7 +4504,7 @@ interface DocumentEventMap extends GlobalEventHandlersEventMap, DocumentAndEleme } /** Any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree. */ -interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, ParentNode, XPathEvaluatorBase, GlobalEventHandlers, DocumentAndElementEventHandlers { +interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShadowRoot, GlobalEventHandlers, NonElementParentNode, ParentNode, XPathEvaluatorBase { /** * Sets or gets the URL for the current document. */ @@ -5160,7 +5195,7 @@ interface ElementEventMap { } /** Element is the most general base class from which all objects in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element. */ -interface Element extends Node, ParentNode, NonDocumentTypeChildNode, ChildNode, Slotable, InnerHTML, Animatable { +interface Element extends Node, Animatable, ChildNode, InnerHTML, NonDocumentTypeChildNode, ParentNode, Slotable { readonly assignedSlot: HTMLSlotElement | null; readonly attributes: NamedNodeMap; /** @@ -5234,8 +5269,8 @@ interface Element extends Node, ParentNode, NonDocumentTypeChildNode, ChildNode, getAttributeNames(): string[]; getAttributeNode(name: string): Attr | null; getAttributeNodeNS(namespaceURI: string, localName: string): Attr | null; - getBoundingClientRect(): ClientRect | DOMRect; - getClientRects(): ClientRectList | DOMRectList; + getBoundingClientRect(): DOMRect; + getClientRects(): DOMRectList; /** * Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. */ @@ -6655,7 +6690,7 @@ interface HTMLElementEventMap extends ElementEventMap, GlobalEventHandlersEventM } /** Any HTML element. Some elements directly implement this interface, while others implement it via an interface that inherits it. */ -interface HTMLElement extends Element, GlobalEventHandlers, DocumentAndElementEventHandlers, ElementContentEditable, HTMLOrSVGElement, ElementCSSInlineStyle { +interface HTMLElement extends Element, DocumentAndElementEventHandlers, ElementCSSInlineStyle, ElementContentEditable, GlobalEventHandlers, HTMLOrSVGElement { accessKey: string; readonly accessKeyLabel: string; autocapitalize: string; @@ -9792,11 +9827,11 @@ declare var IntersectionObserver: { /** This Intersection Observer API interface describes the intersection between the target element and its root container at a specific moment of transition. */ interface IntersectionObserverEntry { - readonly boundingClientRect: ClientRect | DOMRect; + readonly boundingClientRect: DOMRectReadOnly; readonly intersectionRatio: number; - readonly intersectionRect: ClientRect | DOMRect; + readonly intersectionRect: DOMRectReadOnly; readonly isIntersecting: boolean; - readonly rootBounds: ClientRect | DOMRect | null; + readonly rootBounds: DOMRectReadOnly | null; readonly target: Element; readonly time: number; } @@ -10837,7 +10872,7 @@ declare var NavigationPreloadManager: { }; /** The state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities. */ -interface Navigator extends NavigatorID, NavigatorLanguage, NavigatorOnLine, NavigatorContentUtils, NavigatorCookies, NavigatorPlugins, NavigatorConcurrentHardware, NavigatorStorage, NavigatorAutomationInformation, MSFileSaver, MSNavigatorDoNotTrack, NavigatorBeacon { +interface Navigator extends MSFileSaver, MSNavigatorDoNotTrack, NavigatorAutomationInformation, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorContentUtils, NavigatorCookies, NavigatorID, NavigatorLanguage, NavigatorOnLine, NavigatorPlugins, NavigatorStorage { readonly activeVRDisplays: ReadonlyArray; readonly clipboard: Clipboard; readonly credentials: CredentialsContainer; @@ -11376,7 +11411,7 @@ declare var OffscreenCanvas: { new(width: number, height: number): OffscreenCanvas; }; -interface OffscreenCanvasRenderingContext2D extends CanvasState, CanvasTransform, CanvasCompositing, CanvasImageSmoothing, CanvasFillStrokeStyles, CanvasShadowStyles, CanvasFilters, CanvasRect, CanvasDrawPath, CanvasText, CanvasDrawImage, CanvasImageData, CanvasPathDrawingStyles, CanvasTextDrawingStyles, CanvasPath { +interface OffscreenCanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform { readonly canvas: OffscreenCanvas; commit(): void; } @@ -12608,8 +12643,8 @@ interface Range extends AbstractRange { deleteContents(): void; detach(): void; extractContents(): DocumentFragment; - getBoundingClientRect(): ClientRect | DOMRect; - getClientRects(): ClientRectList | DOMRectList; + getBoundingClientRect(): DOMRect; + getClientRects(): DOMRectList; insertNode(node: Node): void; /** * Returns whether range intersects node. @@ -13133,7 +13168,7 @@ interface SVGElementEventMap extends ElementEventMap, GlobalEventHandlersEventMa } /** All of the SVG DOM interfaces that correspond directly to elements in the SVG language derive from the SVGElement interface. */ -interface SVGElement extends Element, GlobalEventHandlers, DocumentAndElementEventHandlers, SVGElementInstance, HTMLOrSVGElement, ElementCSSInlineStyle { +interface SVGElement extends Element, DocumentAndElementEventHandlers, ElementCSSInlineStyle, GlobalEventHandlers, HTMLOrSVGElement, SVGElementInstance { /** @deprecated */ readonly className: any; readonly ownerSVGElement: SVGSVGElement | null; @@ -14343,7 +14378,7 @@ declare var SVGPathSegMovetoRel: { }; /** Corresponds to the element. */ -interface SVGPatternElement extends SVGElement, SVGTests, SVGFitToViewBox, SVGURIReference { +interface SVGPatternElement extends SVGElement, SVGFitToViewBox, SVGTests, SVGURIReference { readonly height: SVGAnimatedLength; readonly patternContentUnits: SVGAnimatedEnumeration; readonly patternTransform: SVGAnimatedTransformList; @@ -15644,7 +15679,7 @@ interface TextDecoderCommon { readonly ignoreBOM: boolean; } -interface TextDecoderStream extends TextDecoderCommon, GenericTransformStream { +interface TextDecoderStream extends GenericTransformStream, TextDecoderCommon { } declare var TextDecoderStream: { @@ -15676,7 +15711,7 @@ interface TextEncoderCommon { readonly encoding: string; } -interface TextEncoderStream extends TextEncoderCommon, GenericTransformStream { +interface TextEncoderStream extends GenericTransformStream, TextEncoderCommon { } declare var TextEncoderStream: { @@ -16444,7 +16479,7 @@ declare var WebAuthnAssertion: { new(): WebAuthnAssertion; }; -interface WebGL2RenderingContext extends WebGLRenderingContextBase, WebGL2RenderingContextBase, WebGL2RenderingContextOverloads { +interface WebGL2RenderingContext extends WebGL2RenderingContextBase, WebGL2RenderingContextOverloads, WebGLRenderingContextBase { } declare var WebGL2RenderingContext: { @@ -18497,7 +18532,7 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler } /** A window containing a DOM document; the document property points to the DOM document loaded in that window. */ -interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, AnimationFrameProvider, WindowOrWorkerGlobalScope, WindowEventHandlers { +interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandlers, IDBEnvironment, WindowBase64, WindowConsole, WindowEventHandlers, WindowLocalStorage, WindowOrWorkerGlobalScope, WindowSessionStorage, WindowTimers { readonly applicationCache: ApplicationCache; readonly caches: CacheStorage; readonly clientInformation: Navigator; @@ -19059,11 +19094,11 @@ declare namespace WebAssembly { var Global: { prototype: Global; - new(descriptor: GlobalDescriptor, value?: any): Global; + new(descriptor: GlobalDescriptor, v?: any): Global; }; interface Instance { - readonly exports: any; + readonly exports: Exports; } var Instance: { @@ -19095,9 +19130,9 @@ declare namespace WebAssembly { var Module: { prototype: Module; new(bytes: BufferSource): Module; - customSections(module: Module, sectionName: string): ArrayBuffer[]; - exports(module: Module): ModuleExportDescriptor[]; - imports(module: Module): ModuleImportDescriptor[]; + customSections(moduleObject: Module, sectionName: string): ArrayBuffer[]; + exports(moduleObject: Module): ModuleExportDescriptor[]; + imports(moduleObject: Module): ModuleImportDescriptor[]; }; interface RuntimeError { @@ -19122,7 +19157,7 @@ declare namespace WebAssembly { interface GlobalDescriptor { mutable?: boolean; - value: string; + value: ValueType; } interface MemoryDescriptor { @@ -19154,9 +19189,17 @@ declare namespace WebAssembly { type ImportExportKind = "function" | "table" | "memory" | "global"; type TableKind = "anyfunc"; + type ValueType = "i32" | "i64" | "f32" | "f64"; + type ExportValue = Function | Global | Memory | Table; + type Exports = Record; + type ImportValue = ExportValue | number; + type ModuleImports = Record; + type Imports = Record; function compile(bytes: BufferSource): Promise; - function instantiate(bytes: BufferSource, importObject?: any): Promise; - function instantiate(moduleObject: Module, importObject?: any): Promise; + function compileStreaming(source: Response | Promise): Promise; + function instantiate(bytes: BufferSource, importObject?: Imports): Promise; + function instantiate(moduleObject: Module, importObject?: Imports): Promise; + function instantiateStreaming(response: Response | PromiseLike, importObject?: Imports): Promise; function validate(bytes: BufferSource): boolean; } @@ -20116,7 +20159,7 @@ type Transport = "usb" | "nfc" | "ble"; type UserVerificationRequirement = "required" | "preferred" | "discouraged"; type VRDisplayEventReason = "mounted" | "navigation" | "requested" | "unmounted"; type VideoFacingModeEnum = "user" | "environment" | "left" | "right"; -type VisibilityState = "hidden" | "visible" | "prerender"; +type VisibilityState = "hidden" | "visible"; type WebGLPowerPreference = "default" | "low-power" | "high-performance"; type WorkerType = "classic" | "module"; type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; diff --git a/lib/lib.dom.iterable.d.ts b/lib/lib.dom.iterable.d.ts index 00b00fa524888..e5db9c136745b 100644 --- a/lib/lib.dom.iterable.d.ts +++ b/lib/lib.dom.iterable.d.ts @@ -293,37 +293,37 @@ interface WebAuthentication { } interface WebGL2RenderingContextBase { + clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; + clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; + clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; + drawBuffers(buffers: Iterable): void; + getActiveUniforms(program: WebGLProgram, uniformIndices: Iterable, pname: GLenum): any; + getUniformIndices(program: WebGLProgram, uniformNames: Iterable): Iterable | null; invalidateFramebuffer(target: GLenum, attachments: Iterable): void; invalidateSubFramebuffer(target: GLenum, attachments: Iterable, x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; + transformFeedbackVaryings(program: WebGLProgram, varyings: Iterable, bufferMode: GLenum): void; uniform1uiv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform2uiv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform3uiv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform4uiv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix3x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix4x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniformMatrix2x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix4x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniformMatrix2x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniformMatrix3x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniformMatrix3x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniformMatrix4x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniformMatrix4x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; vertexAttribI4iv(index: GLuint, values: Iterable): void; vertexAttribI4uiv(index: GLuint, values: Iterable): void; - drawBuffers(buffers: Iterable): void; - clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; - clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; - clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; - transformFeedbackVaryings(program: WebGLProgram, varyings: Iterable, bufferMode: GLenum): void; - getUniformIndices(program: WebGLProgram, uniformNames: Iterable): Iterable | null; - getActiveUniforms(program: WebGLProgram, uniformIndices: Iterable, pname: GLenum): any; } interface WebGL2RenderingContextOverloads { uniform1fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform2fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform3fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform4fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform1iv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniform2fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform2iv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniform3fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform3iv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniform4fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform4iv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; @@ -339,12 +339,12 @@ interface WebGLRenderingContextBase { interface WebGLRenderingContextOverloads { uniform1fv(location: WebGLUniformLocation | null, v: Iterable): void; - uniform2fv(location: WebGLUniformLocation | null, v: Iterable): void; - uniform3fv(location: WebGLUniformLocation | null, v: Iterable): void; - uniform4fv(location: WebGLUniformLocation | null, v: Iterable): void; uniform1iv(location: WebGLUniformLocation | null, v: Iterable): void; + uniform2fv(location: WebGLUniformLocation | null, v: Iterable): void; uniform2iv(location: WebGLUniformLocation | null, v: Iterable): void; + uniform3fv(location: WebGLUniformLocation | null, v: Iterable): void; uniform3iv(location: WebGLUniformLocation | null, v: Iterable): void; + uniform4fv(location: WebGLUniformLocation | null, v: Iterable): void; uniform4iv(location: WebGLUniformLocation | null, v: Iterable): void; uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable): void; uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable): void; diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index 557bfd9bcf3fc..dc93004c04b45 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -30,7 +30,7 @@ interface Map { interface MapConstructor { new(): Map; - new(entries?: ReadonlyArray | null): Map; + new(entries?: readonly (readonly [K, V])[] | null): Map; readonly prototype: Map; } declare var Map: MapConstructor; @@ -50,7 +50,7 @@ interface WeakMap { } interface WeakMapConstructor { - new (entries?: ReadonlyArray<[K, V]> | null): WeakMap; + new (entries?: readonly [K, V][] | null): WeakMap; readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -65,7 +65,7 @@ interface Set { } interface SetConstructor { - new (values?: ReadonlyArray | null): Set; + new (values?: readonly T[] | null): Set; readonly prototype: Set; } declare var Set: SetConstructor; @@ -83,7 +83,7 @@ interface WeakSet { } interface WeakSetConstructor { - new (values?: ReadonlyArray | null): WeakSet; + new (values?: readonly T[] | null): WeakSet; readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index 8cecc6e01d8aa..e0c83ad4647a6 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -319,9 +319,9 @@ interface ObjectConstructor { getOwnPropertySymbols(o: any): symbol[]; /** - * Returns the names of the enumerable string properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ + * Returns the names of the enumerable string properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ keys(o: {}): string[]; /** @@ -332,7 +332,7 @@ interface ObjectConstructor { is(value1: any, value2: any): boolean; /** - * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * Sets the prototype of a specified object o to object proto or null. Returns the object o. * @param o The object to change its prototype. * @param proto The value of the new prototype or null. */ @@ -349,8 +349,8 @@ interface ReadonlyArray { * @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: (this: void, value: T, index: number, obj: ReadonlyArray) => value is S, thisArg?: any): S | undefined; - find(predicate: (value: T, index: number, obj: ReadonlyArray) => unknown, thisArg?: any): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined; + find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -361,7 +361,7 @@ interface ReadonlyArray { * @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: T, index: number, obj: ReadonlyArray) => unknown, thisArg?: any): number; + findIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number; } interface RegExp { diff --git a/lib/lib.es2015.promise.d.ts b/lib/lib.es2015.promise.d.ts index 4db67542cad24..1c73467ea41f0 100644 --- a/lib/lib.es2015.promise.d.ts +++ b/lib/lib.es2015.promise.d.ts @@ -38,7 +38,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -46,7 +46,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -54,7 +54,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -62,7 +62,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -70,7 +70,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -78,7 +78,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -86,7 +86,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -94,7 +94,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -102,7 +102,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -110,7 +110,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: (T | PromiseLike)[]): Promise; + all(values: readonly (T | PromiseLike)[]): Promise; /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved @@ -118,7 +118,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - race(values: T[]): Promise ? U : T>; + race(values: readonly T[]): Promise ? U : T>; /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved diff --git a/lib/lib.es2017.object.d.ts b/lib/lib.es2017.object.d.ts index 65aa1f959284c..aaea4246c8335 100644 --- a/lib/lib.es2017.object.d.ts +++ b/lib/lib.es2017.object.d.ts @@ -23,7 +23,7 @@ interface ObjectConstructor { * Returns an array of values of the enumerable properties of an object * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - values(o: { [s: string]: T } | ArrayLike): T[]; + values(o: { [s: string]: T } | ArrayLike): T[]; /** * Returns an array of values of the enumerable properties of an object diff --git a/lib/lib.es2018.asyncgenerator.d.ts b/lib/lib.es2018.asyncgenerator.d.ts index a569853be9f7a..61eb9c39af2f4 100644 --- a/lib/lib.es2018.asyncgenerator.d.ts +++ b/lib/lib.es2018.asyncgenerator.d.ts @@ -22,7 +22,7 @@ and limitations under the License. interface AsyncGenerator extends AsyncIterator { // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. - next(...args: [] | [TNext | PromiseLike]): Promise>; + next(...args: [] | [TNext]): Promise>; return(value: TReturn | PromiseLike): Promise>; throw(e: any): Promise>; [Symbol.asyncIterator](): AsyncGenerator; diff --git a/lib/lib.es2018.asynciterable.d.ts b/lib/lib.es2018.asynciterable.d.ts index c5bc92da280bd..8eebde36364b2 100644 --- a/lib/lib.es2018.asynciterable.d.ts +++ b/lib/lib.es2018.asynciterable.d.ts @@ -31,7 +31,7 @@ interface SymbolConstructor { interface AsyncIterator { // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. - next(...args: [] | [TNext | PromiseLike]): Promise>; + next(...args: [] | [TNext]): Promise>; return?(value?: TReturn | PromiseLike): Promise>; throw?(e?: any): Promise>; } diff --git a/lib/lib.es2018.intl.d.ts b/lib/lib.es2018.intl.d.ts index 84e95f481b467..6ab0dca02e75d 100644 --- a/lib/lib.es2018.intl.d.ts +++ b/lib/lib.es2018.intl.d.ts @@ -20,14 +20,14 @@ and limitations under the License. declare namespace Intl { interface PluralRulesOptions { - localeMatcher?: 'lookup' | 'best fit'; - type?: 'cardinal' | 'ordinal'; + localeMatcher?: "lookup" | "best fit"; + type?: "cardinal" | "ordinal"; } interface ResolvedPluralRulesOptions { locale: string; pluralCategories: string[]; - type: 'cardinal' | 'ordinal'; + type: "cardinal" | "ordinal"; minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; diff --git a/lib/lib.es2019.array.d.ts b/lib/lib.es2019.array.d.ts index 6c75122320954..b67c7c14c49a9 100644 --- a/lib/lib.es2019.array.d.ts +++ b/lib/lib.es2019.array.d.ts @@ -31,7 +31,7 @@ interface ReadonlyArray { * thisArg is omitted, undefined is used as the this value. */ flatMap ( - callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray, + callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This ): U[] @@ -130,7 +130,7 @@ interface ReadonlyArray { * @param depth The maximum recursion depth */ flat(depth?: number): any[]; - } +} interface Array { @@ -145,7 +145,7 @@ interface Array { * thisArg is omitted, undefined is used as the this value. */ flatMap ( - callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray, + callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This ): U[] diff --git a/lib/lib.es2019.string.d.ts b/lib/lib.es2019.string.d.ts index 60985db048047..a5a9dc6920479 100644 --- a/lib/lib.es2019.string.d.ts +++ b/lib/lib.es2019.string.d.ts @@ -19,15 +19,15 @@ and limitations under the License. interface String { - /** Removes the trailing white space and line terminator characters from a string. */ - trimEnd(): string; + /** Removes the trailing white space and line terminator characters from a string. */ + trimEnd(): string; - /** Removes the leading white space and line terminator characters from a string. */ - trimStart(): string; + /** Removes the leading white space and line terminator characters from a string. */ + trimStart(): string; - /** Removes the leading white space and line terminator characters from a string. */ - trimLeft(): string; + /** Removes the leading white space and line terminator characters from a string. */ + trimLeft(): string; - /** Removes the trailing white space and line terminator characters from a string. */ - trimRight(): string; + /** Removes the trailing white space and line terminator characters from a string. */ + trimRight(): string; } diff --git a/lib/lib.es2020.string.d.ts b/lib/lib.es2020.string.d.ts index c9a99d3228176..146786641bd94 100644 --- a/lib/lib.es2020.string.d.ts +++ b/lib/lib.es2020.string.d.ts @@ -21,10 +21,10 @@ and limitations under the License. /// interface String { - /** - * Matches a string with a regular expression, and returns an iterable of matches - * containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ - matchAll(regexp: RegExp): IterableIterator; + /** + * Matches a string with a regular expression, and returns an iterable of matches + * containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + matchAll(regexp: RegExp): IterableIterator; } diff --git a/lib/lib.es2020.symbol.wellknown.d.ts b/lib/lib.es2020.symbol.wellknown.d.ts index f513f5e960b18..599d62d24a89c 100644 --- a/lib/lib.es2020.symbol.wellknown.d.ts +++ b/lib/lib.es2020.symbol.wellknown.d.ts @@ -22,18 +22,18 @@ and limitations under the License. /// interface SymbolConstructor { - /** - * A regular expression method that matches the regular expression against a string. Called - * by the String.prototype.matchAll method. - */ - readonly matchAll: symbol; + /** + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.matchAll method. + */ + readonly matchAll: symbol; } interface RegExp { - /** - * Matches a string with this regular expression, and returns an iterable of matches - * containing the results of that search. - * @param string A string to search within. - */ - [Symbol.matchAll](str: string): IterableIterator; + /** + * Matches a string with this regular expression, and returns an iterable of matches + * containing the results of that search. + * @param string A string to search within. + */ + [Symbol.matchAll](str: string): IterableIterator; } diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 48637e9de1773..13bf9bb239e7d 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -26,80 +26,80 @@ declare var NaN: number; declare var Infinity: number; /** - * Evaluates JavaScript code and executes it. - * @param x A String value that contains valid JavaScript code. - */ + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ declare function eval(x: string): any; /** - * Converts a string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. - * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. - * All other strings are considered decimal. - */ + * Converts a string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ declare function parseInt(s: string, radix?: number): number; /** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. - */ + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ declare function parseFloat(string: string): number; /** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). - * @param number A numeric value. - */ + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ declare function isNaN(number: number): boolean; /** - * Determines whether a supplied number is finite. - * @param number Any numeric value. - */ + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ declare function isFinite(number: number): boolean; /** - * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). - * @param encodedURI A value representing an encoded URI. - */ + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ declare function decodeURI(encodedURI: string): string; /** - * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). - * @param encodedURIComponent A value representing an encoded URI component. - */ + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ declare function decodeURIComponent(encodedURIComponent: string): string; /** - * Encodes a text string as a valid Uniform Resource Identifier (URI) - * @param uri A value representing an encoded URI. - */ + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ declare function encodeURI(uri: string): string; /** - * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). - * @param uriComponent A value representing an encoded URI component. - */ + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ declare function encodeURIComponent(uriComponent: string | number | boolean): string; /** - * Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence. - * @param string A string value - */ + * Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence. + * @param string A string value + */ declare function escape(string: string): string; /** - * Computes a new string in which hexadecimal escape sequences are replaced with the character that it represents. - * @param string A string value - */ + * Computes a new string in which hexadecimal escape sequences are replaced with the character that it represents. + * @param string A string value + */ declare function unescape(string: string): string; interface Symbol { - /** Returns a string representation of an object. */ - toString(): string; + /** Returns a string representation of an object. */ + toString(): string; - /** Returns the primitive value of the specified object. */ - valueOf(): symbol; + /** Returns the primitive value of the specified object. */ + valueOf(): symbol; } declare type PropertyKey = string | number | symbol; @@ -131,21 +131,21 @@ interface Object { valueOf(): Object; /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ hasOwnProperty(v: PropertyKey): boolean; /** - * Determines whether an object exists in another object's prototype chain. - * @param v Another object whose prototype chain is to be checked. - */ + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ isPrototypeOf(v: Object): boolean; /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ + * Determines whether a specified property is enumerable. + * @param v A property name. + */ propertyIsEnumerable(v: PropertyKey): boolean; } @@ -158,138 +158,138 @@ interface ObjectConstructor { readonly prototype: Object; /** - * Returns the prototype of an object. - * @param o The object that references the prototype. - */ + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ getPrototypeOf(o: any): any; /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. - * @param o Object that contains the property. - * @param p Name of the property. - */ + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ getOwnPropertyDescriptor(o: any, p: PropertyKey): PropertyDescriptor | undefined; /** - * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly - * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. - * @param o Object that contains the own properties. - */ + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ getOwnPropertyNames(o: any): string[]; /** - * Creates an object that has the specified prototype or that has null prototype. - * @param o Object to use as a prototype. May be null. - */ + * Creates an object that has the specified prototype or that has null prototype. + * @param o Object to use as a prototype. May be null. + */ create(o: object | null): any; /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - * @param properties JavaScript object that contains one or more property descriptors. - */ + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ create(o: object | null, properties: PropertyDescriptorMap & ThisType): any; /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. - * @param p The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor property. - */ + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ defineProperty(o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType): any; /** - * Adds one or more properties to an object, and/or modifies attributes of existing properties. - * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. - * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. - */ + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ defineProperties(o: any, properties: PropertyDescriptorMap & ThisType): any; /** - * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ seal(o: T): T; /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - freeze(a: T[]): ReadonlyArray; + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(a: T[]): readonly T[]; /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ freeze(f: T): T; /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ freeze(o: T): Readonly; /** - * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. - */ + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ preventExtensions(o: T): T; /** - * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. - */ + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ isSealed(o: any): boolean; /** - * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. - */ + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ isFrozen(o: any): boolean; /** - * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. - */ + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ isExtensible(o: any): boolean; /** - * Returns the names of the enumerable string properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ - keys(o: object): string[]; + * Returns the names of the enumerable string properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: object): string[]; } /** - * Provides functionality common to all JavaScript objects. - */ + * Provides functionality common to all JavaScript objects. + */ declare var Object: ObjectConstructor; /** - * Creates a new function. - */ + * Creates a new function. + */ interface Function { /** - * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. - * @param thisArg The object to be used as the this object. - * @param argArray A set of arguments to be passed to the function. - */ + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ apply(this: Function, thisArg: any, argArray?: any): any; /** - * Calls a method of an object, substituting another object for the current object. - * @param thisArg The object to be used as the current object. - * @param argArray A list of arguments to be passed to the method. - */ + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ call(this: Function, thisArg: any, ...argArray: any[]): any; /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg An object to which the this keyword can refer inside the new function. - * @param argArray A list of arguments to be passed to the new function. - */ + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ bind(this: Function, thisArg: any, ...argArray: any[]): any; /** Returns a string representation of a function. */ @@ -305,9 +305,9 @@ interface Function { interface FunctionConstructor { /** - * Creates a new function. - * @param args A list of arguments the function accepts. - */ + * Creates a new function. + * @param args A list of arguments the function accepts. + */ new(...args: string[]): Function; (...args: string[]): Function; readonly prototype: Function; @@ -327,26 +327,26 @@ type OmitThisParameter = unknown extends ThisParameterType ? T : T extends interface CallableFunction extends Function { /** - * Calls the function with the specified object as the this value and the elements of specified array as the arguments. - * @param thisArg The object to be used as the this object. - * @param args An array of argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the elements of specified array as the arguments. + * @param thisArg The object to be used as the this object. + * @param args An array of argument values to be passed to the function. + */ apply(this: (this: T) => R, thisArg: T): R; apply(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; /** - * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. - * @param thisArg The object to be used as the this object. - * @param args Argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. + * @param thisArg The object to be used as the this object. + * @param args Argument values to be passed to the function. + */ call(this: (this: T, ...args: A) => R, thisArg: T, ...args: A): R; /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg The object to be used as the this object. - * @param args Arguments to bind to the parameters of the function. - */ + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg The object to be used as the this object. + * @param args Arguments to bind to the parameters of the function. + */ bind(this: T, thisArg: ThisParameterType): OmitThisParameter; bind(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; bind(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; @@ -357,26 +357,26 @@ interface CallableFunction extends Function { interface NewableFunction extends Function { /** - * Calls the function with the specified object as the this value and the elements of specified array as the arguments. - * @param thisArg The object to be used as the this object. - * @param args An array of argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the elements of specified array as the arguments. + * @param thisArg The object to be used as the this object. + * @param args An array of argument values to be passed to the function. + */ apply(this: new () => T, thisArg: T): void; apply(this: new (...args: A) => T, thisArg: T, args: A): void; /** - * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. - * @param thisArg The object to be used as the this object. - * @param args Argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. + * @param thisArg The object to be used as the this object. + * @param args Argument values to be passed to the function. + */ call(this: new (...args: A) => T, thisArg: T, ...args: A): void; /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg The object to be used as the this object. - * @param args Arguments to bind to the parameters of the function. - */ + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg The object to be used as the this object. + * @param args Arguments to bind to the parameters of the function. + */ bind(this: T, thisArg: any): T; bind(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; bind(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; @@ -396,103 +396,103 @@ interface String { toString(): string; /** - * Returns the character at the specified index. - * @param pos The zero-based index of the desired character. - */ + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ charAt(pos: number): string; /** - * Returns the Unicode value of the character at the specified location. - * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. - */ + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ charCodeAt(index: number): number; /** - * Returns a string that contains the concatenation of two or more strings. - * @param strings The strings to append to the end of the string. - */ + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ concat(...strings: string[]): string; /** - * Returns the position of the first occurrence of a substring. - * @param searchString The substring to search for in the string - * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. - */ + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ indexOf(searchString: string, position?: number): number; /** - * Returns the last occurrence of a substring in the string. - * @param searchString The substring to search for. - * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. - */ + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ lastIndexOf(searchString: string, position?: number): number; /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - */ + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ localeCompare(that: string): number; /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ match(regexp: string | RegExp): RegExpMatchArray | null; /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. - */ + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ replace(searchValue: string | RegExp, replaceValue: string): string; /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replacer A function that returns the replacement text. - */ + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replacer A function that returns the replacement text. + */ replace(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ search(regexp: string | RegExp): number; /** - * Returns a section of a string. - * @param start The index to the beginning of the specified portion of stringObj. - * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. - * If this value is not specified, the substring continues to the end of stringObj. - */ + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ slice(start?: number, end?: number): string; /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ split(separator: string | RegExp, limit?: number): string[]; /** - * Returns the substring at the specified location within a String object. - * @param start The zero-based index number indicating the beginning of the substring. - * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. - * If end is omitted, the characters from start through the end of the original string are returned. - */ + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ substring(start: number, end?: number): string; /** Converts all the alphabetic characters in a string to lowercase. */ toLowerCase(): string; /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ - toLocaleLowerCase(): string; + toLocaleLowerCase(locales?: string | string[]): string; /** Converts all the alphabetic characters in a string to uppercase. */ toUpperCase(): string; /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ - toLocaleUpperCase(): string; + toLocaleUpperCase(locales?: string | string[]): string; /** Removes the leading and trailing white space and line terminator characters from a string. */ trim(): string; @@ -502,10 +502,10 @@ interface String { // IE extensions /** - * Gets a substring beginning at the specified location and having the specified length. - * @param from The starting position of the desired substring. The index of the first character in the string is zero. - * @param length The number of characters to include in the returned substring. - */ + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ substr(from: number, length?: number): string; /** Returns the primitive value of the specified object. */ @@ -522,8 +522,8 @@ interface StringConstructor { } /** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ declare var String: StringConstructor; interface Boolean { @@ -541,27 +541,27 @@ declare var Boolean: BooleanConstructor; interface Number { /** - * Returns a string representation of an object. - * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. - */ + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ toString(radix?: number): string; /** - * Returns a string representing a number in fixed-point notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ toFixed(fractionDigits?: number): string; /** - * Returns a string containing a number represented in exponential notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ toExponential(fractionDigits?: number): string; /** - * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. - * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. - */ + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ toPrecision(precision?: number): string; /** Returns the primitive value of the specified object. */ @@ -580,21 +580,21 @@ interface NumberConstructor { readonly MIN_VALUE: number; /** - * A value that is not a number. - * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. - */ + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ readonly NaN: number; /** - * A value that is less than the largest negative number that can be represented in JavaScript. - * JavaScript displays NEGATIVE_INFINITY values as -infinity. - */ + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ readonly NEGATIVE_INFINITY: number; /** - * A value greater than the largest number that can be represented in JavaScript. - * JavaScript displays POSITIVE_INFINITY values as infinity. - */ + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ readonly POSITIVE_INFINITY: number; } @@ -602,7 +602,7 @@ interface NumberConstructor { declare var Number: NumberConstructor; interface TemplateStringsArray extends ReadonlyArray { - readonly raw: ReadonlyArray; + readonly raw: readonly string[]; } /** @@ -632,94 +632,94 @@ interface Math { /** The square root of 2. */ readonly SQRT2: number; /** - * Returns the absolute value of a number (the value without regard to whether it is positive or negative). - * For example, the absolute value of -5 is the same as the absolute value of 5. - * @param x A numeric expression for which the absolute value is needed. - */ + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ abs(x: number): number; /** - * Returns the arc cosine (or inverse cosine) of a number. - * @param x A numeric expression. - */ + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ acos(x: number): number; /** - * Returns the arcsine of a number. - * @param x A numeric expression. - */ + * Returns the arcsine of a number. + * @param x A numeric expression. + */ asin(x: number): number; /** - * Returns the arctangent of a number. - * @param x A numeric expression for which the arctangent is needed. - */ + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ atan(x: number): number; /** - * Returns the angle (in radians) from the X axis to a point. - * @param y A numeric expression representing the cartesian y-coordinate. - * @param x A numeric expression representing the cartesian x-coordinate. - */ + * Returns the angle (in radians) from the X axis to a point. + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ atan2(y: number, x: number): number; /** - * Returns the smallest integer greater than or equal to its numeric argument. - * @param x A numeric expression. - */ + * Returns the smallest integer greater than or equal to its numeric argument. + * @param x A numeric expression. + */ ceil(x: number): number; /** - * Returns the cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ cos(x: number): number; /** - * Returns e (the base of natural logarithms) raised to a power. - * @param x A numeric expression representing the power of e. - */ + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ exp(x: number): number; /** - * Returns the greatest integer less than or equal to its numeric argument. - * @param x A numeric expression. - */ + * Returns the greatest integer less than or equal to its numeric argument. + * @param x A numeric expression. + */ floor(x: number): number; /** - * Returns the natural logarithm (base e) of a number. - * @param x A numeric expression. - */ + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ log(x: number): number; /** - * Returns the larger of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ max(...values: number[]): number; /** - * Returns the smaller of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ min(...values: number[]): number; /** - * Returns the value of a base expression taken to a specified power. - * @param x The base value of the expression. - * @param y The exponent value of the expression. - */ + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ pow(x: number, y: number): number; /** Returns a pseudorandom number between 0 and 1. */ random(): number; /** - * Returns a supplied numeric expression rounded to the nearest number. - * @param x The value to be rounded to the nearest number. - */ + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ round(x: number): number; /** - * Returns the sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ sin(x: number): number; /** - * Returns the square root of a number. - * @param x A numeric expression. - */ + * Returns the square root of a number. + * @param x A numeric expression. + */ sqrt(x: number): number; /** - * Returns the tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ tan(x: number): number; } /** An intrinsic object that provides basic mathematics functionality and constants. */ @@ -778,98 +778,98 @@ interface Date { /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ getTimezoneOffset(): number; /** - * Sets the date and time value in the Date object. - * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. - */ + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ setTime(time: number): number; /** - * Sets the milliseconds value in the Date object using local time. - * @param ms A numeric value equal to the millisecond value. - */ + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ setMilliseconds(ms: number): number; /** - * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). - * @param ms A numeric value equal to the millisecond value. - */ + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ setUTCMilliseconds(ms: number): number; /** - * Sets the seconds value in the Date object using local time. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setSeconds(sec: number, ms?: number): number; /** - * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setUTCSeconds(sec: number, ms?: number): number; /** - * Sets the minutes value in the Date object using local time. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setMinutes(min: number, sec?: number, ms?: number): number; /** - * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setUTCMinutes(min: number, sec?: number, ms?: number): number; /** - * Sets the hour value in the Date object using local time. - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setHours(hours: number, min?: number, sec?: number, ms?: number): number; /** - * Sets the hours value in the Date object using Universal Coordinated Time (UTC). - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; /** - * Sets the numeric day-of-the-month value of the Date object using local time. - * @param date A numeric value equal to the day of the month. - */ + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ setDate(date: number): number; /** - * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). - * @param date A numeric value equal to the day of the month. - */ + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ setUTCDate(date: number): number; /** - * Sets the month value in the Date object using local time. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. - * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. - */ + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ setMonth(month: number, date?: number): number; /** - * Sets the month value in the Date object using Universal Coordinated Time (UTC). - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. - * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. - */ + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ setUTCMonth(month: number, date?: number): number; /** - * Sets the year of the Date object using local time. - * @param year A numeric value for the year. - * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. - * @param date A numeric value equal for the day of the month. - */ + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ setFullYear(year: number, month?: number, date?: number): number; /** - * Sets the year value in the Date object using Universal Coordinated Time (UTC). - * @param year A numeric value equal to the year. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. - * @param date A numeric value equal to the day of the month. - */ + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ setUTCFullYear(year: number, month?: number, date?: number): number; /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ toUTCString(): string; @@ -886,20 +886,20 @@ interface DateConstructor { (): string; readonly prototype: Date; /** - * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. - * @param s A date string - */ + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ parse(s: string): number; /** - * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. - * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. - * @param month The month as an number between 0 and 11 (January to December). - * @param date The date as an number between 1 and 31. - * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. - * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. - * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. - * @param ms An number from 0 to 999 that specifies the milliseconds. - */ + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } @@ -918,15 +918,15 @@ interface RegExpExecArray extends Array { interface RegExp { /** - * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. - * @param string The String object or string literal on which to perform the search. - */ + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ exec(string: string): RegExpExecArray | null; /** - * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. - * @param string String on which to perform the search. - */ + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ test(string: string): boolean; /** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */ @@ -1051,31 +1051,31 @@ declare var URIError: URIErrorConstructor; interface JSON { /** - * Converts a JavaScript Object Notation (JSON) string into an object. - * @param text A valid JSON string. - * @param reviver A function that transforms the results. This function is called for each member of the object. - * If a member contains nested objects, the nested objects are transformed before the parent object is. - */ + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ parse(text: string, reviver?: (this: any, key: string, value: any) => any): any; /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer An array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer An array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string; } /** - * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. - */ + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ declare var JSON: JSON; @@ -1085,112 +1085,118 @@ declare var JSON: JSON; interface ReadonlyArray { /** - * Gets the length of the array. This is a number one higher than the highest element defined in an array. - */ + * Gets the length of the array. This is a number one higher than the highest element defined in an array. + */ readonly length: number; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. - */ + * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. + */ toLocaleString(): string; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: ConcatArray[]): T[]; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: (T | ConcatArray)[]): T[]; /** - * 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. - */ + * 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; /** - * 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. - */ + * 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. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): T[]; /** - * 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. - */ + * 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: T, fromIndex?: number): number; /** - * Returns the index of the last occurrence of a specified 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 the last index in the array. - */ + * Returns the index of the last occurrence of a specified 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 the last index in the array. + */ lastIndexOf(searchElement: T, fromIndex?: number): number; /** - * 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 array1 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: T, index: number, array: ReadonlyArray) => unknown, thisArg?: any): boolean; - /** - * 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 array1 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: T, index: number, array: ReadonlyArray) => unknown, thisArg?: any): boolean; - /** - * 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: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; - /** - * 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: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + * 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 a value + * which is coercible to the Boolean value 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: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean; + /** + * 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 a value + * which is coercible to the Boolean value 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: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean; + /** + * 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: T, index: number, array: readonly T[]) => void, thisArg?: any): void; + /** + * 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: T, index: number, array: readonly T[]) => U, thisArg?: any): U[]; /** * 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: T, index: number, array: ReadonlyArray) => value is S, thisArg?: any): S[]; - /** - * 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: T, index: number, array: ReadonlyArray) => unknown, thisArg?: any): T[]; - /** - * 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: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T): T; - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue: T): T; - /** - * 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: T, currentIndex: number, array: ReadonlyArray) => 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: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T): T; - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue: T): T; - /** - * 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: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; + filter(callbackfn: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[]; + /** + * 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: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[]; + /** + * 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: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; + /** + * 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: T, currentIndex: number, array: readonly T[]) => 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: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; + /** + * 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: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U; readonly [n: number]: T; } @@ -1204,113 +1210,124 @@ interface ConcatArray { interface Array { /** - * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. - */ + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ length: number; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. - */ + * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. + */ toLocaleString(): string; /** - * Removes the last element from an array and returns it. - */ + * Removes the last element from an array and returns it. + */ pop(): T | undefined; /** - * Appends new elements to an array, and returns the new length of the array. - * @param items New elements of the Array. - */ + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ push(...items: T[]): number; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: ConcatArray[]): T[]; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: (T | ConcatArray)[]): T[]; /** - * 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. - */ + * 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; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): T[]; /** - * Removes the first element from an array and returns it. - */ + * Removes the first element from an array and returns it. + */ shift(): T | undefined; /** - * 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. - */ + * 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. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): T[]; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: T, b: T) => number): this; /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - */ + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + */ splice(start: number, deleteCount?: number): T[]; /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - */ + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ splice(start: number, deleteCount: number, ...items: T[]): T[]; /** - * Inserts new elements at the start of an array. - * @param items Elements to insert at the start of the Array. - */ + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ unshift(...items: T[]): number; /** - * 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. - */ + * 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: T, fromIndex?: number): number; /** - * Returns the index of the last occurrence of a specified 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 the last index in the array. - */ + * Returns the index of the last occurrence of a specified 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 the last index in the array. + */ lastIndexOf(searchElement: T, fromIndex?: number): number; /** - * 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 array1 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. - */ + * 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 a value + * which is coercible to the Boolean value 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: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** - * 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 array1 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. - */ + * 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 a value + * which is coercible to the Boolean value 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: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** - * 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. - */ + * 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: T, index: number, array: T[]) => void, thisArg?: any): void; /** - * 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. - */ + * 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: T, index: number, array: T[]) => U, thisArg?: any): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -1319,36 +1336,36 @@ interface Array { */ filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; /** - * 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. - */ + * 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: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; /** - * 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. - */ + * 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: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; /** - * 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. - */ + * 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: T, currentIndex: number, array: T[]) => 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. - */ + * 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: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; /** - * 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. - */ + * 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: T, currentIndex: number, array: T[]) => U, initialValue: U): U; [n: number]: T; @@ -1361,8 +1378,8 @@ interface ArrayConstructor { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; - isArray(arg: any): arg is Array; - readonly prototype: Array; + isArray(arg: any): arg is any[]; + readonly prototype: any[]; } declare var Array: ArrayConstructor; @@ -1499,20 +1516,20 @@ type InstanceType any> = T extends new (...args: interface ThisType { } /** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ interface ArrayBuffer { /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ + * Read-only. The length of the ArrayBuffer (in bytes). + */ readonly byteLength: number; /** - * Returns a section of an ArrayBuffer. - */ + * Returns a section of an ArrayBuffer. + */ slice(begin: number, end?: number): ArrayBuffer; } @@ -1533,18 +1550,18 @@ declare var ArrayBuffer: ArrayBufferConstructor; interface ArrayBufferView { /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ byteOffset: number; } @@ -1553,126 +1570,126 @@ interface DataView { readonly byteLength: number; readonly byteOffset: number; /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getFloat32(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getFloat64(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Int8 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. - */ + * Gets the Int8 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. + */ getInt8(byteOffset: number): number; /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getInt16(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getInt32(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Uint8 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. - */ + * Gets the Uint8 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. + */ getUint8(byteOffset: number): number; /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getUint16(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getUint32(byteOffset: number, littleEndian?: boolean): number; /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Int8 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. - */ + * Stores an Int8 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. + */ setInt8(byteOffset: number, value: number): void; /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Uint8 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. - */ + * Stores an Uint8 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. + */ setUint8(byteOffset: number, value: number): void; /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; } @@ -1682,241 +1699,245 @@ interface DataViewConstructor { declare var DataView: DataViewConstructor; /** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ interface Int8Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * 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. - */ + * 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; /** - * 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 array1 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: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Int8Array) => unknown, 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. - */ + * 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: number, 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. - */ + * 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: number, index: number, array: Int8Array) => any, thisArg?: any): Int8Array; /** - * 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. - */ + * 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: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | 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. - */ + * 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: number, index: number, obj: Int8Array) => 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. - */ + * 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: number, index: number, array: Int8Array) => void, thisArg?: any): void; /** - * 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. - */ + * 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: number, 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. - */ + * 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; /** - * 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. - */ + * 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: number, fromIndex?: number): number; /** - * The length of the array. - */ + * 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. - */ + * 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: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; /** - * 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Int8Array) => 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Int8Array; /** - * 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. - */ + * 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. - */ + * 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. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Int8Array; /** - * 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 array1 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: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Int8Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Int8Array 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): Int8Array; + * Gets a new Int8Array 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): Int8Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -1928,28 +1949,28 @@ interface Int8ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int8Array; /** - * The size in bytes of each element in the array. - */ + * 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. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Int8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Int8Array; /** - * 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. - */ + * 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, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; @@ -1957,241 +1978,245 @@ interface Int8ArrayConstructor { declare var Int8Array: Int8ArrayConstructor; /** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-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 Uint8Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * 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. - */ + * 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; /** - * 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 array1 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: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Uint8Array) => unknown, 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. - */ + * 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: number, 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. - */ + * 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: number, index: number, array: Uint8Array) => any, thisArg?: any): Uint8Array; /** - * 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. - */ + * 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: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | 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. - */ + * 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: number, index: number, obj: Uint8Array) => 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. - */ + * 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: number, index: number, array: Uint8Array) => void, thisArg?: any): void; /** - * 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. - */ + * 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: number, 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. - */ + * 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; /** - * 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. - */ + * 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: number, fromIndex?: number): number; /** - * The length of the array. - */ + * 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. - */ + * 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: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; /** - * 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Uint8Array) => 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint8Array; /** - * 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. - */ + * 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. - */ + * 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. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint8Array; /** - * 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 array1 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: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Uint8Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint8Array 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): Uint8Array; + * Gets a new Uint8Array 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): Uint8Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -2204,269 +2229,273 @@ interface Uint8ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8Array; /** - * The size in bytes of each element in the array. - */ + * 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. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint8Array; /** - * 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. - */ + * 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, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; } declare var Uint8Array: Uint8ArrayConstructor; /** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ interface Uint8ClampedArray { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * 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. - */ + * 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; /** - * 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 array1 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: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Uint8ClampedArray) => unknown, 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. - */ + * 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: number, 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. - */ + * 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: number, index: number, array: Uint8ClampedArray) => any, thisArg?: any): Uint8ClampedArray; /** - * 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. - */ + * 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: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | 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. - */ + * 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: number, index: number, obj: Uint8ClampedArray) => 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. - */ + * 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: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; /** - * 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. - */ + * 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: number, 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. - */ + * 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; /** - * 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. - */ + * 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: number, fromIndex?: number): number; /** - * The length of the array. - */ + * 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. - */ + * 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: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; /** - * 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Uint8ClampedArray) => 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint8ClampedArray; /** - * 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. - */ + * 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. - */ + * 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. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint8ClampedArray; /** - * 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 array1 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: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint8ClampedArray 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): Uint8ClampedArray; + * Gets a new Uint8ClampedArray 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): Uint8ClampedArray; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -2479,267 +2508,271 @@ interface Uint8ClampedArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8ClampedArray; /** - * The size in bytes of each element in the array. - */ + * 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. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint8ClampedArray; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint8ClampedArray; /** - * 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. - */ + * 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, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; } declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 16-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 Int16Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * 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. - */ + * 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; /** - * 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 array1 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: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Int16Array) => unknown, 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. - */ + * 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: number, 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. - */ + * 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: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; /** - * 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. - */ + * 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: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | 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. - */ + * 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: number, index: number, obj: Int16Array) => 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. - */ + * 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: number, index: number, array: Int16Array) => void, thisArg?: any): void; /** - * 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. - */ + * 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: number, 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. - */ + * 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; /** - * 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. - */ + * 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: number, fromIndex?: number): number; /** - * The length of the array. - */ + * 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. - */ + * 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: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; /** - * 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Int16Array) => 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Int16Array; /** - * 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. - */ + * 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. - */ + * 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. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Int16Array; /** - * 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 array1 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: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Int16Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Int16Array 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): Int16Array; + * Gets a new Int16Array 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): Int16Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -2752,28 +2785,28 @@ interface Int16ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int16Array; /** - * The size in bytes of each element in the array. - */ + * 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. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Int16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Int16Array; /** - * 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. - */ + * 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, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; @@ -2781,241 +2814,245 @@ interface Int16ArrayConstructor { declare var Int16Array: Int16ArrayConstructor; /** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 16-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 Uint16Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * 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. - */ + * 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; /** - * 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 array1 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: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Uint16Array) => unknown, 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. - */ + * 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: number, 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. - */ + * 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: number, index: number, array: Uint16Array) => any, thisArg?: any): Uint16Array; /** - * 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. - */ + * 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: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | 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. - */ + * 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: number, index: number, obj: Uint16Array) => 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. - */ + * 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: number, index: number, array: Uint16Array) => void, thisArg?: any): void; /** - * 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. - */ + * 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: number, 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. - */ + * 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; /** - * 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. - */ + * 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: number, fromIndex?: number): number; /** - * The length of the array. - */ + * 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. - */ + * 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: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; /** - * 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Uint16Array) => 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint16Array; /** - * 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. - */ + * 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. - */ + * 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. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint16Array; /** - * 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 array1 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: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Uint16Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint16Array 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): Uint16Array; + * Gets a new Uint16Array 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): Uint16Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3028,269 +3065,273 @@ interface Uint16ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint16Array; /** - * The size in bytes of each element in the array. - */ + * 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. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint16Array; /** - * 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. - */ + * 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, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; } declare var Uint16Array: Uint16ArrayConstructor; /** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-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 Int32Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * 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. - */ + * 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; /** - * 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 array1 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: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Int32Array) => unknown, 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. - */ + * 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: number, 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. - */ + * 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: number, index: number, array: Int32Array) => any, thisArg?: any): Int32Array; /** - * 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. - */ + * 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: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | 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. - */ + * 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: number, index: number, obj: Int32Array) => 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. - */ + * 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: number, index: number, array: Int32Array) => void, thisArg?: any): void; /** - * 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. - */ + * 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: number, 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. - */ + * 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; /** - * 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. - */ + * 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: number, fromIndex?: number): number; /** - * The length of the array. - */ + * 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. - */ + * 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: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; /** - * 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Int32Array) => 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Int32Array; /** - * 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. - */ + * 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. - */ + * 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. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Int32Array; /** - * 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 array1 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: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Int32Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Int32Array 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): Int32Array; + * Gets a new Int32Array 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): Int32Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3303,268 +3344,272 @@ interface Int32ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int32Array; /** - * The size in bytes of each element in the array. - */ + * 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. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Int32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Int32Array; /** - * 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. - */ + * 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, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; } declare var Int32Array: Int32ArrayConstructor; /** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-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 Uint32Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * 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. - */ + * 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; /** - * 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 array1 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: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Uint32Array) => unknown, 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. - */ + * 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: number, 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. - */ + * 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: number, index: number, array: Uint32Array) => any, thisArg?: any): Uint32Array; /** - * 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. - */ + * 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: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | 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. - */ + * 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: number, index: number, obj: Uint32Array) => 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. - */ + * 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: number, index: number, array: Uint32Array) => void, thisArg?: any): void; /** - * 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. - */ + * 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: number, 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. - */ + * 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; /** - * 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. - */ + * 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: number, fromIndex?: number): number; /** - * The length of the array. - */ + * 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. - */ + * 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: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; /** - * 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Uint32Array) => 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint32Array; /** - * 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. - */ + * 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. - */ + * 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. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint32Array; /** - * 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 array1 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: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Uint32Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint32Array 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): Uint32Array; + * Gets a new Uint32Array 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): Uint32Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3577,269 +3622,273 @@ interface Uint32ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint32Array; /** - * The size in bytes of each element in the array. - */ + * 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. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint32Array; /** - * 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. - */ + * 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, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; } declare var Uint32Array: Uint32ArrayConstructor; /** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ interface Float32Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * 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. - */ + * 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; /** - * 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 array1 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: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Float32Array) => unknown, 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. - */ + * 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: number, 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. - */ + * 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: number, index: number, array: Float32Array) => any, thisArg?: any): Float32Array; /** - * 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. - */ + * 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: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | 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. - */ + * 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: number, index: number, obj: Float32Array) => 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. - */ + * 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: number, index: number, array: Float32Array) => void, thisArg?: any): void; /** - * 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. - */ + * 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: number, 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. - */ + * 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; /** - * 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. - */ + * 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: number, fromIndex?: number): number; /** - * The length of the array. - */ + * 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. - */ + * 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: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; /** - * 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Float32Array) => 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Float32Array; /** - * 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. - */ + * 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. - */ + * 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. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Float32Array; /** - * 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 array1 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: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Float32Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Float32Array 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): Float32Array; + * Gets a new Float32Array 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): Float32Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3852,28 +3901,28 @@ interface Float32ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float32Array; /** - * The size in bytes of each element in the array. - */ + * 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. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Float32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Float32Array; /** - * 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. - */ + * 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, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; @@ -3881,241 +3930,236 @@ interface Float32ArrayConstructor { declare var Float32Array: Float32ArrayConstructor; /** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ interface Float64Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * 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. - */ + * 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; /** - * 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 array1 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: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Float64Array) => unknown, 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. - */ + * 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: number, 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. - */ + * 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: number, index: number, array: Float64Array) => any, thisArg?: any): Float64Array; /** - * 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. - */ + * 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: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | 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. - */ + * 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: number, index: number, obj: Float64Array) => 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. - */ + * 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: number, index: number, array: Float64Array) => void, thisArg?: any): void; /** - * 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. - */ + * 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: number, 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. - */ + * 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; /** - * 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. - */ + * 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: number, fromIndex?: number): number; /** - * The length of the array. - */ + * 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. - */ + * 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: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; /** - * 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Float64Array) => 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. - */ + * 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: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; /** - * 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. - */ + * 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: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Float64Array; /** - * 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. - */ + * 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. - */ + * 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. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Float64Array; /** - * 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 array1 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: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + * 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 a value + * which is coercible to the Boolean value 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: number, index: number, array: Float64Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Float64Array 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): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; + * 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): Float64Array; - /** - * Returns a string representation of an array. - */ toString(): string; [index: number]: number; @@ -4128,28 +4172,28 @@ interface Float64ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float64Array; /** - * The size in bytes of each element in the array. - */ + * 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. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Float64Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Float64Array; /** - * 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. - */ + * 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, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; } @@ -4272,41 +4316,41 @@ declare namespace Intl { interface String { /** - * Determines whether two strings are equivalent in the current or specified locale. - * @param that String to compare to target string - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. - * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. - */ + * Determines whether two strings are equivalent in the current or specified locale. + * @param that String to compare to target string + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ localeCompare(that: string, locales?: string | string[], options?: Intl.CollatorOptions): number; } interface Number { /** - * Converts a number to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a number to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions): string; } interface Date { /** - * Converts a date and time to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a date and time to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; /** - * Converts a date to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a date to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleDateString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; /** - * Converts a time to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a time to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; } diff --git a/lib/lib.esnext.bigint.d.ts b/lib/lib.esnext.bigint.d.ts index 50967de98fea7..ba9bae6e85939 100644 --- a/lib/lib.esnext.bigint.d.ts +++ b/lib/lib.esnext.bigint.d.ts @@ -20,9 +20,9 @@ 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. - */ + * 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. */ @@ -39,27 +39,27 @@ interface BigIntConstructor { 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 - */ + * 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 - */ + * 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 var 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. - */ + * 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; @@ -74,213 +74,213 @@ interface BigInt64Array { 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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; + * 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; @@ -308,17 +308,17 @@ interface BigInt64ArrayConstructor { 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. - */ + * 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. - */ + * 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; } @@ -326,9 +326,9 @@ interface BigInt64ArrayConstructor { declare var 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. - */ + * 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; @@ -343,213 +343,213 @@ interface BigUint64Array { 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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; + * 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; @@ -577,17 +577,17 @@ interface BigUint64ArrayConstructor { 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. - */ + * 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. - */ + * 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; } @@ -596,34 +596,34 @@ declare var 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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; } diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts index ea5841bdf89ba..d71ce67c5359c 100644 --- a/lib/lib.esnext.d.ts +++ b/lib/lib.esnext.d.ts @@ -18,6 +18,6 @@ and limitations under the License. /// -/// +/// /// /// diff --git a/lib/lib.esnext.intl.d.ts b/lib/lib.esnext.intl.d.ts index 73a45eedf2076..404ffc35bf468 100644 --- a/lib/lib.esnext.intl.d.ts +++ b/lib/lib.esnext.intl.d.ts @@ -29,4 +29,4 @@ declare namespace Intl { interface NumberFormat { formatToParts(number?: number): NumberFormatPart[]; } - } +} diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 9b73c55a9367e..57e9b28b531a2 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -2472,7 +2472,7 @@ declare var OffscreenCanvas: { new(width: number, height: number): OffscreenCanvas; }; -interface OffscreenCanvasRenderingContext2D extends CanvasState, CanvasTransform, CanvasCompositing, CanvasImageSmoothing, CanvasFillStrokeStyles, CanvasShadowStyles, CanvasFilters, CanvasRect, CanvasDrawPath, CanvasText, CanvasDrawImage, CanvasImageData, CanvasPathDrawingStyles, CanvasTextDrawingStyles, CanvasPath { +interface OffscreenCanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform { readonly canvas: OffscreenCanvas; commit(): void; } @@ -3102,7 +3102,7 @@ interface TextDecoderCommon { readonly ignoreBOM: boolean; } -interface TextDecoderStream extends TextDecoderCommon, GenericTransformStream { +interface TextDecoderStream extends GenericTransformStream, TextDecoderCommon { } declare var TextDecoderStream: { @@ -3134,7 +3134,7 @@ interface TextEncoderCommon { readonly encoding: string; } -interface TextEncoderStream extends TextEncoderCommon, GenericTransformStream { +interface TextEncoderStream extends GenericTransformStream, TextEncoderCommon { } declare var TextEncoderStream: { @@ -3385,7 +3385,7 @@ interface WEBGL_lose_context { restoreContext(): void; } -interface WebGL2RenderingContext extends WebGLRenderingContextBase, WebGL2RenderingContextBase, WebGL2RenderingContextOverloads { +interface WebGL2RenderingContext extends WebGL2RenderingContextBase, WebGL2RenderingContextOverloads, WebGLRenderingContextBase { } declare var WebGL2RenderingContext: { @@ -5375,7 +5375,7 @@ interface WorkerGlobalScopeEventMap { } /** This Web Workers API interface is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by Window objects — in this case event handlers, the console or the associated WorkerNavigator object. Each WorkerGlobalScope has its own event loop. */ -interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, WindowOrWorkerGlobalScope { +interface WorkerGlobalScope extends EventTarget, WindowConsole, WindowOrWorkerGlobalScope, WorkerUtils { readonly caches: CacheStorage; readonly isSecureContext: boolean; readonly location: WorkerLocation; @@ -5414,7 +5414,7 @@ declare var WorkerLocation: { }; /** A subset of the Navigator interface allowed to be accessed from a Worker. Such an object is initialized for each worker and is available via the WorkerGlobalScope.navigator property obtained by calling window.self.navigator. */ -interface WorkerNavigator extends NavigatorID, NavigatorOnLine, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorStorage { +interface WorkerNavigator extends NavigatorBeacon, NavigatorConcurrentHardware, NavigatorID, NavigatorOnLine, NavigatorStorage { readonly permissions: Permissions; readonly serviceWorker: ServiceWorkerContainer; } @@ -5620,11 +5620,11 @@ declare namespace WebAssembly { var Global: { prototype: Global; - new(descriptor: GlobalDescriptor, value?: any): Global; + new(descriptor: GlobalDescriptor, v?: any): Global; }; interface Instance { - readonly exports: any; + readonly exports: Exports; } var Instance: { @@ -5648,9 +5648,9 @@ declare namespace WebAssembly { var Module: { prototype: Module; new(bytes: BufferSource): Module; - customSections(module: Module, sectionName: string): ArrayBuffer[]; - exports(module: Module): ModuleExportDescriptor[]; - imports(module: Module): ModuleImportDescriptor[]; + customSections(moduleObject: Module, sectionName: string): ArrayBuffer[]; + exports(moduleObject: Module): ModuleExportDescriptor[]; + imports(moduleObject: Module): ModuleImportDescriptor[]; }; interface Table { @@ -5667,7 +5667,7 @@ declare namespace WebAssembly { interface GlobalDescriptor { mutable?: boolean; - value: string; + value: ValueType; } interface MemoryDescriptor { @@ -5699,9 +5699,17 @@ declare namespace WebAssembly { type ImportExportKind = "function" | "table" | "memory" | "global"; type TableKind = "anyfunc"; + type ValueType = "i32" | "i64" | "f32" | "f64"; + type ExportValue = Function | Global | Memory | Table; + type Exports = Record; + type ImportValue = ExportValue | number; + type ModuleImports = Record; + type Imports = Record; function compile(bytes: BufferSource): Promise; - function instantiate(bytes: BufferSource, importObject?: any): Promise; - function instantiate(moduleObject: Module, importObject?: any): Promise; + function compileStreaming(source: Response | Promise): Promise; + function instantiate(bytes: BufferSource, importObject?: Imports): Promise; + function instantiate(moduleObject: Module, importObject?: Imports): Promise; + function instantiateStreaming(response: Response | PromiseLike, importObject?: Imports): Promise; function validate(bytes: BufferSource): boolean; } @@ -5875,7 +5883,7 @@ type RequestRedirect = "follow" | "error" | "manual"; type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant"; type ServiceWorkerUpdateViaCache = "imports" | "all" | "none"; -type VisibilityState = "hidden" | "visible" | "prerender"; +type VisibilityState = "hidden" | "visible"; type WebGLPowerPreference = "default" | "low-power" | "high-performance"; type WorkerType = "classic" | "module"; type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; diff --git a/lib/pl/diagnosticMessages.generated.json b/lib/pl/diagnosticMessages.generated.json index 8573d802c7439..9d219542c8696 100644 --- a/lib/pl/diagnosticMessages.generated.json +++ b/lib/pl/diagnosticMessages.generated.json @@ -278,7 +278,7 @@ "Computed_property_names_are_not_allowed_in_enums_1164": "Obliczone nazwy właściwości nie są dozwolone w wyliczeniach.", "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553": "Obliczone wartości nie są dozwolone w wyliczeniu ze składowymi o wartości ciągu.", "Concatenate_and_emit_output_to_single_file_6001": "Połącz i wyemituj dane wyjściowe do pojedynczego pliku.", - "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090": "Znaleziono sprzeczne definicje dla „{0}” w „{1}” i „{2}”. Rozważ zainstalowanie konkretnej wersji tej biblioteki, aby rozwiązać problem.", + "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090": "Znaleziono definicje będące w konflikcie dla „{0}” w „{1}” i „{2}”. Rozważ zainstalowanie konkretnej wersji tej biblioteki, aby rozwiązać problem.", "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013": "Dla sygnatury konstrukcji bez adnotacji zwracanego typu niejawnie określono zwracany typ „any”.", "Constructor_implementation_is_missing_2390": "Brak implementacji konstruktora.", "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673": "Konstruktor klasy „{0}” jest prywatny i dostępny tylko w ramach deklaracji klasy.", diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index ca84f3dab7979..def3c67bdf0bc 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -467,7 +467,7 @@ declare namespace ts.server.protocol { scope: OrganizeImportsScope; } interface OrganizeImportsResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } interface GetEditsForFileRenameRequest extends Request { command: CommandTypes.GetEditsForFileRename; @@ -479,7 +479,7 @@ declare namespace ts.server.protocol { readonly newFilePath: string; } interface GetEditsForFileRenameResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } /** * Request for the available codefixes at a specific position. @@ -526,7 +526,7 @@ declare namespace ts.server.protocol { /** * Errorcodes we want to get the fixes for. */ - errorCodes: ReadonlyArray; + errorCodes: readonly number[]; } interface GetCombinedCodeFixRequestArgs { scope: GetCombinedCodeFixScope; @@ -643,7 +643,7 @@ declare namespace ts.server.protocol { interface FileSpanWithContext extends FileSpan, TextSpanWithContext { } interface DefinitionInfoAndBoundSpan { - definitions: ReadonlyArray; + definitions: readonly FileSpanWithContext[]; textSpan: TextSpan; } /** @@ -781,7 +781,7 @@ declare namespace ts.server.protocol { /** * The file locations referencing the symbol. */ - refs: ReadonlyArray; + refs: readonly ReferencesResponseItem[]; /** * The name of the symbol. */ @@ -885,7 +885,7 @@ declare namespace ts.server.protocol { /** * An array of span groups (one per file) that refer to the item to be renamed. */ - locs: ReadonlyArray; + locs: readonly SpanGroup[]; } /** * Rename response message. @@ -1364,8 +1364,8 @@ declare namespace ts.server.protocol { commands?: {}[]; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray<{}>; + changes: readonly FileCodeEdits[]; + commands?: readonly {}[]; } interface CodeFixAction extends CodeAction { /** Short name to identify the fix, for use by telemetry. */ @@ -1572,7 +1572,7 @@ declare namespace ts.server.protocol { readonly isGlobalCompletion: boolean; readonly isMemberCompletion: boolean; readonly isNewIdentifierLocation: boolean; - readonly entries: ReadonlyArray; + readonly entries: readonly CompletionEntry[]; } interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; @@ -2251,7 +2251,7 @@ declare namespace ts.server.protocol { /** * list of packages to install */ - packages: ReadonlyArray; + packages: readonly string[]; } interface BeginInstallTypesEventBody extends InstallTypesEventBody { } @@ -2272,6 +2272,11 @@ declare namespace ts.server.protocol { Block = "Block", Smart = "Smart" } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorSettings { baseIndentSize?: number; indentSize?: number; @@ -2297,6 +2302,7 @@ declare namespace ts.server.protocol { placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; insertSpaceBeforeTypeAnnotation?: boolean; + semicolons?: SemicolonPreference; } interface UserPreferences { readonly disableSuggestions?: boolean; @@ -2380,6 +2386,7 @@ declare namespace ts.server.protocol { strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; + useDefineForClassFields?: boolean; target?: ScriptTarget | ts.ScriptTarget; traceResolution?: boolean; resolveJsonModule?: boolean; @@ -2532,7 +2539,11 @@ declare namespace ts.server.protocol { string = "string" } - interface TypeAcquisition { + export interface TypeAcquisition { + /** + * @deprecated typingOptions.enableAutoDiscovery + * Use typeAcquisition.enable instead. + */ enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; @@ -2540,7 +2551,7 @@ declare namespace ts.server.protocol { [option: string]: string[] | boolean | undefined; } - interface FileExtensionInfo { + export interface FileExtensionInfo { extension: string; isMixedContent: boolean; scriptKind?: ScriptKind; @@ -2560,11 +2571,11 @@ declare namespace ts.server.protocol { [index: string]: T; } - interface PluginImport { + export interface PluginImport { name: string; } - interface ProjectReference { + export interface ProjectReference { /** A normalized path on disk */ path: string; /** The path as the user originally wrote it */ @@ -2575,7 +2586,7 @@ declare namespace ts.server.protocol { circular?: boolean; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; } declare namespace ts { // these types are empty stubs for types from services and should not be used directly diff --git a/lib/tsc.js b/lib/tsc.js index ba422ff94a2ea..f24e84bf7d6dd 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -15,6 +15,13 @@ and limitations under the License. "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -59,7 +66,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook }; var ts; (function (ts) { - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); (function (ts) { @@ -224,6 +231,18 @@ var ts; return undefined; } ts.forEach = forEach; + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; function firstDefined(array, callback) { if (array === undefined) { return undefined; @@ -697,7 +716,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -1047,6 +1066,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1179,6 +1210,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1259,7 +1296,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1620,10 +1657,32 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { @@ -1765,7 +1824,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -1870,6 +1929,9 @@ var ts; Debug.assertNode = shouldAssert(1) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -2009,6 +2071,41 @@ var ts; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + var etwModule; + try { + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +var ts; (function (ts) { var versionRegExp = /^(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i; var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i; @@ -2297,12 +2394,19 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); var ExitStatus; (function (ExitStatus) { ExitStatus[ExitStatus["Success"] = 0] = "Success"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { @@ -2456,7 +2560,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -2595,6 +2699,37 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; function onWatchedFileStat(watchedFile, modifiedTime) { var oldTime = watchedFile.mtime.getTime(); var newTime = modifiedTime.getTime(); @@ -2615,6 +2750,7 @@ var ts; } ts.getFileWatcherEventKind = getFileWatcherEventKind; ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + ts.sysLog = ts.noop; function createRecursiveDirectoryWatcher(host) { var cache = ts.createMap(); var callbackCache = ts.createMultiMap(); @@ -2696,6 +2832,27 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + function patchWriteFileEnsuringDirectory(sys) { + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -2714,6 +2871,7 @@ var ts; ts.sys = (function () { var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -2724,14 +2882,18 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; + var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -2795,8 +2957,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -2821,6 +2985,79 @@ var ts; base64encode: function (input) { return bufferFrom(input).toString("base64"); }, }; return nodeSystem; + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { return Buffer.from && Buffer.from !== Int8Array.from ? Buffer.from(input, encoding) @@ -2854,7 +3091,7 @@ var ts; } return useNonPollingWatchers ? createNonPollingWatchFile() : - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, undefined); }; } function getWatchDirectory() { var fsSupportsRecursive = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin"); @@ -2923,7 +3160,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -2971,6 +3208,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : watchPresentFileSystemEntry(); @@ -2981,6 +3224,7 @@ var ts; } }; function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); callback("rename", ""); if (watcher) { watcher.close(); @@ -2997,7 +3241,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; } @@ -3005,7 +3251,17 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } function watchMissingFileSystemEntry() { @@ -3031,7 +3287,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -3054,7 +3310,14 @@ var ts; } return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; } @@ -3070,6 +3333,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -3123,6 +3387,7 @@ var ts; return fileSystemEntryExists(path, 1); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1); }); } function realpath(path) { @@ -3198,16 +3463,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -3216,14 +3471,7 @@ var ts; sys = getNodeSystem(); } if (sys) { - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -3239,8 +3487,8 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; } ts.Diagnostics = { Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), @@ -3304,7 +3552,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -3359,7 +3606,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -3457,6 +3703,7 @@ var ts; A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -3489,7 +3736,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -3503,6 +3750,16 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(1359, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_1359", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(1360, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_1360", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", undefined, true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", undefined, true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", undefined, true), 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."), @@ -3546,7 +3803,7 @@ var ts; Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), @@ -3794,6 +4051,9 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -3916,6 +4176,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), 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}'."), @@ -4002,6 +4270,9 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -4012,6 +4283,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -4037,6 +4309,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -4224,6 +4497,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + 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}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -4242,9 +4516,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), 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}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -4283,6 +4559,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -4369,6 +4647,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -4398,6 +4678,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -4515,6 +4796,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -4524,97 +4813,100 @@ var ts; (function (ts) { var _a; function tokenIsIdentifierOrKeyword(token) { - return token >= 73; + return token >= 75; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 || tokenIsIdentifierOrKeyword(token); + return token === 31 || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119, - any: 121, - as: 120, - bigint: 147, - boolean: 124, - break: 74, - case: 75, - catch: 76, - class: 77, - continue: 79, - const: 78 + abstract: 121, + any: 124, + as: 122, + asserts: 123, + bigint: 150, + boolean: 127, + break: 76, + case: 77, + catch: 78, + class: 79, + continue: 81, + const: 80 }, - _a["" + "constructor"] = 125, - _a.debugger = 80, - _a.declare = 126, - _a.default = 81, - _a.delete = 82, - _a.do = 83, - _a.else = 84, - _a.enum = 85, - _a.export = 86, - _a.extends = 87, - _a.false = 88, - _a.finally = 89, - _a.for = 90, - _a.from = 145, - _a.function = 91, - _a.get = 127, - _a.if = 92, - _a.implements = 110, - _a.import = 93, - _a.in = 94, - _a.infer = 128, - _a.instanceof = 95, - _a.interface = 111, - _a.is = 129, - _a.keyof = 130, - _a.let = 112, - _a.module = 131, - _a.namespace = 132, - _a.never = 133, - _a.new = 96, - _a.null = 97, - _a.number = 136, - _a.object = 137, - _a.package = 113, - _a.private = 114, - _a.protected = 115, - _a.public = 116, - _a.readonly = 134, - _a.require = 135, - _a.global = 146, - _a.return = 98, - _a.set = 138, - _a.static = 117, - _a.string = 139, - _a.super = 99, - _a.switch = 100, - _a.symbol = 140, - _a.this = 101, - _a.throw = 102, - _a.true = 103, - _a.try = 104, - _a.type = 141, - _a.typeof = 105, - _a.undefined = 142, - _a.unique = 143, - _a.unknown = 144, - _a.var = 106, - _a.void = 107, - _a.while = 108, - _a.with = 109, - _a.yield = 118, - _a.async = 122, - _a.await = 123, - _a.of = 148, + _a["" + "constructor"] = 128, + _a.debugger = 82, + _a.declare = 129, + _a.default = 83, + _a.delete = 84, + _a.do = 85, + _a.else = 86, + _a.enum = 87, + _a.export = 88, + _a.extends = 89, + _a.false = 90, + _a.finally = 91, + _a.for = 92, + _a.from = 148, + _a.function = 93, + _a.get = 130, + _a.if = 94, + _a.implements = 112, + _a.import = 95, + _a.in = 96, + _a.infer = 131, + _a.instanceof = 97, + _a.interface = 113, + _a.is = 132, + _a.keyof = 133, + _a.let = 114, + _a.module = 134, + _a.namespace = 135, + _a.never = 136, + _a.new = 98, + _a.null = 99, + _a.number = 139, + _a.object = 140, + _a.package = 115, + _a.private = 116, + _a.protected = 117, + _a.public = 118, + _a.readonly = 137, + _a.require = 138, + _a.global = 149, + _a.return = 100, + _a.set = 141, + _a.static = 119, + _a.string = 142, + _a.super = 101, + _a.switch = 102, + _a.symbol = 143, + _a.this = 103, + _a.throw = 104, + _a.true = 105, + _a.try = 106, + _a.type = 144, + _a.typeof = 107, + _a.undefined = 145, + _a.unique = 146, + _a.unknown = 147, + _a.var = 108, + _a.void = 109, + _a.while = 110, + _a.with = 111, + _a.yield = 120, + _a.async = 125, + _a.await = 126, + _a.of = 151, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - 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, "=": 60, "+=": 61, "-=": 62, "*=": 63, "**=": 64, "/=": 65, "%=": 66, "<<=": 67, ">>=": 68, ">>>=": 69, "&=": 70, "|=": 71, "^=": 72, "@": 58, "`": 59 })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18, "}": 19, "(": 20, ")": 21, "[": 22, "]": 23, ".": 24, "...": 25, ";": 26, ",": 27, "<": 29, ">": 31, "<=": 32, ">=": 33, "==": 34, "!=": 35, "===": 36, "!==": 37, "=>": 38, "+": 39, "-": 40, "**": 42, "*": 41, "/": 43, "%": 44, "++": 45, "--": 46, "<<": 47, ">": 48, ">>>": 49, "&": 50, "|": 51, "^": 52, "!": 53, "~": 54, "&&": 55, "||": 56, "?": 57, "??": 60, "?.": 28, ":": 58, "=": 62, "+=": 63, "-=": 64, "*=": 65, "**=": 66, "/=": 67, "%=": 68, "<<=": 69, ">>=": 70, ">>>=": 71, "&=": 72, "|=": 73, "^=": 74, "@": 59, "`": 61 })); 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,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 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, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 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, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 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, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 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, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 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, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 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, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 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, 2809, 2809, 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, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 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, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 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, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 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, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 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, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 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, 43824, 43866, 43868, 43879, 43888, 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, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 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, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { if (code < map[0]) { return false; @@ -4638,15 +4930,17 @@ var ts; return false; } function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -5069,11 +5363,12 @@ var ts; } ts.isIdentifierPart = isIdentifierPart; function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -5092,17 +5387,18 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1) !== 0; }, - isIdentifier: function () { return token === 73 || token > 109; }, - isReservedWord: function () { return token >= 74 && token <= 109; }, + isIdentifier: function () { return token === 75 || token > 111; }, + isReservedWord: function () { return token >= 76 && token <= 111; }, isUnterminated: function () { return (tokenFlags & 4) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -5112,6 +5408,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -5126,6 +5423,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -5225,7 +5531,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -5415,6 +5721,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024; return scanHexadecimalEscape(4); case 120: return scanHexadecimalEscape(2); @@ -5487,21 +5794,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 && codePointAt(text, pos + 1) === 117 && codePointAt(text, pos + 2) === 123) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); pos += 6; start = pos; } @@ -5523,7 +5850,7 @@ var ts; } } } - return token = 73; + return token = 75; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -5588,7 +5915,7 @@ var ts; if (pos >= end) { return token = 1; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { @@ -5650,12 +5977,12 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 36; + return pos += 3, token = 37; } - return pos += 2, token = 34; + return pos += 2, token = 35; } pos++; - return token = 52; + return token = 53; case 34: case 39: tokenValue = scanString(); @@ -5664,19 +5991,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 68; } pos++; - return token = 43; + return token = 44; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 54; + return pos += 2, token = 55; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 70; + return pos += 2, token = 72; } pos++; - return token = 49; + return token = 50; case 40: pos++; return token = 20; @@ -5685,41 +6012,41 @@ var ts; return token = 21; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 65; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 64; + return pos += 3, token = 66; } - return pos += 2, token = 41; + return pos += 2, token = 42; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1)) { asteriskSeen = true; continue; } - return token = 40; + return token = 41; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 63; } pos++; - return token = 38; + return token = 39; case 44: pos++; return token = 27; case 45: if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 45; + return pos += 2, token = 46; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 64; } pos++; - return token = 39; + return token = 40; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -5778,10 +6105,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 67; } pos++; - return token = 42; + return token = 43; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -5834,7 +6161,7 @@ var ts; return token; case 58: pos++; - return token = 57; + return token = 58; case 59: pos++; return token = 26; @@ -5850,20 +6177,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 67; + return pos += 3, token = 69; } - return pos += 2, token = 46; + return pos += 2, token = 47; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 31; + return pos += 2, token = 32; } if (languageVariant === 1 && text.charCodeAt(pos + 1) === 47 && text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 29; + return pos += 2, token = 30; } pos++; - return token = 28; + return token = 29; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5876,15 +6203,15 @@ var ts; } 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; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 37; + return pos += 2, token = 38; } pos++; - return token = 60; + return token = 62; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5896,10 +6223,18 @@ var ts; } } pos++; - return token = 30; + return token = 31; case 63: pos++; - return token = 56; + if (text.charCodeAt(pos) === 46 && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28; + } + if (text.charCodeAt(pos) === 63) { + pos++; + return token = 60; + } + return token = 57; case 91: pos++; return token = 22; @@ -5908,10 +6243,10 @@ var ts; return token = 23; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 72; + return pos += 2, token = 74; } pos++; - return token = 51; + return token = 52; case 123: pos++; return token = 18; @@ -5926,26 +6261,34 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 55; + return pos += 2, token = 56; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 71; + return pos += 2, token = 73; } pos++; - return token = 50; + return token = 51; case 125: pos++; return token = 19; case 126: pos++; - return token = 53; + return token = 54; case 64: pos++; - return token = 58; + return token = 59; case 92: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -5954,9 +6297,9 @@ var ts; return token = 0; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92) { tokenValue += scanIdentifierParts(); @@ -5964,44 +6307,44 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0; } } } function reScanGreaterToken() { - if (token === 30) { + if (token === 31) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 69; + return pos += 3, token = 71; } - return pos += 2, token = 48; + return pos += 2, token = 49; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; + return pos += 2, token = 70; } pos++; - return token = 47; + return token = 48; } if (text.charCodeAt(pos) === 61) { pos++; - return token = 32; + return token = 33; } } return token; } function reScanSlashToken() { - if (token === 42 || token === 65) { + if (token === 43 || token === 67) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -6054,12 +6397,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46) { + if (token === 47) { pos = tokenPos + 1; - return token = 28; + return token = 29; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -6069,10 +6417,10 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 29; + return token = 30; } pos++; - return token = 28; + return token = 29; } if (char === 123) { pos++; @@ -6104,17 +6452,19 @@ var ts; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -6135,8 +6485,8 @@ var ts; if (pos >= end) { return token = 1; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9: case 11: @@ -6147,13 +6497,13 @@ var ts; } return token = 5; case 64: - return token = 58; + return token = 59; case 10: case 13: tokenFlags |= 1; return token = 4; case 42: - return token = 40; + return token = 41; case 123: return token = 18; case 125: @@ -6163,23 +6513,44 @@ var ts; case 93: return token = 23; case 60: - return token = 28; + return token = 29; case 62: - return token = 30; + return token = 31; case 61: - return token = 60; + return token = 62; case 44: return token = 27; case 46: return token = 24; case 96: - return token = 59; - } - if (isIdentifierStart(ch, 99)) { - while (isIdentifierPart(text.charCodeAt(pos), 99) && pos < end) { + return token = 61; + case 92: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -6260,6 +6631,26 @@ var ts; } } ts.createScanner = createScanner; + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + var size = str.length; + if (i < 0 || i >= size) { + return undefined; + } + var first = str.charCodeAt(i); + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -6334,6 +6725,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, writeLine: function () { return str += " "; }, increaseIndent: ts.noop, decreaseIndent: ts.noop, @@ -6419,7 +6812,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -6506,21 +6899,21 @@ var ts; ts.hasChangesInResolutions = hasChangesInResolutions; function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072) !== 0; + return (node.flags & 262144) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768) !== 0) || + if (!(node.flags & 524288)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072; + node.flags |= 262144; } - node.flags |= 262144; + node.flags |= 524288; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285) { + while (node && node.kind !== 288) { node = node.parent; } return node; @@ -6528,11 +6921,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219: - case 247: - case 226: - case 227: - case 228: + case 222: + case 250: + case 229: + case 230: + case 231: return true; } return false; @@ -6592,7 +6985,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -6655,7 +7048,7 @@ var ts; if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 313 && node._children.length > 0) { + if (node.kind === 317 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -6674,7 +7067,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -6720,13 +7113,21 @@ var ts; return '"' + escapeText(node.text, 34) + '"'; } case 14: - return "`" + escapeText(node.text, 96) + "`"; case 15: - return "`" + escapeText(node.text, 96) + "${"; case 16: - return "}" + escapeText(node.text, 96) + "${"; case 17: - return "}" + escapeText(node.text, 96) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96)); + switch (node.kind) { + case 14: + return "`" + rawText + "`"; + case 15: + return "`" + rawText + "${"; + case 16: + return "}" + rawText + "${"; + case 17: + return "}" + rawText + "`"; + } + break; case 8: case 9: case 13: @@ -6750,7 +7151,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 && node.parent.kind === 275; + return node.kind === 241 && node.parent.kind === 278; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -6774,16 +7175,16 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 245 && (!node.body); + return node && node.kind === 248 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 || - node.kind === 245 || + return node.kind === 288 || + node.kind === 248 || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512); + return !!(module.flags & 1024); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -6792,9 +7193,9 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isModuleAugmentationExternal(node) { switch (node.parent.kind) { - case 285: + case 288: return ts.isExternalModule(node.parent); - case 246: + case 249: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6808,24 +7209,52 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + switch (node.scriptKind) { + case 1: + case 3: + case 2: + case 4: + break; + default: + return false; + } + if (node.isDeclarationFile) { + return false; + } + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285: - case 247: - case 275: - case 245: - case 226: - case 227: - case 228: - case 158: - case 157: - case 159: + case 288: + case 250: + case 278: + case 248: + case 229: + case 230: + case 231: + case 161: case 160: - case 240: - case 197: - case 198: + case 162: + case 163: + case 243: + case 200: + case 201: return true; - case 219: + case 222: return !ts.isFunctionLike(parentNode); } return false; @@ -6833,9 +7262,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304: - case 311: - case 299: + case 308: + case 315: + case 303: return true; default: ts.assertType(node); @@ -6845,25 +7274,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161: - case 162: - case 156: - case 163: + case 164: + case 165: + case 159: case 166: - case 167: - case 295: - case 241: - case 210: - case 242: + case 169: + case 170: + case 298: + case 244: + case 213: + case 245: + case 246: + case 314: case 243: - case 310: - case 240: - case 157: - case 158: - case 159: case 160: - case 197: - case 198: + case 161: + case 162: + case 163: + case 200: + case 201: return true; default: ts.assertType(node); @@ -6873,8 +7302,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250: - case 249: + case 253: + case 252: return true; default: return false; @@ -6883,15 +7312,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250: - case 249: - case 220: - case 241: - case 240: - case 245: - case 243: - case 242: + case 253: + case 252: + case 224: case 244: + case 243: + case 248: + case 246: + case 245: + case 247: return true; default: return false; @@ -6916,13 +7345,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73: + case 75: return name.escapedText; case 10: case 8: case 14: return ts.escapeLeadingUnderscores(name.text); - case 150: + case 153: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -6933,11 +7362,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73: + case 75: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149: + case 152: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190: + case 193: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -6982,7 +7411,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219) { + if (node.body && node.body.kind === 222) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6994,36 +7423,37 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285: + case 288: 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 238: - case 187: case 241: - case 210: - case 242: - case 245: + case 190: case 244: - case 279: - case 240: - case 197: - case 157: - case 159: - case 160: + case 213: + case 245: + case 248: + case 247: + case 282: case 243: - case 155: - case 154: + case 200: + case 160: + case 162: + case 163: + case 246: + case 158: + case 157: errorNode = node.name; break; - case 198: + case 201: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -7052,7 +7482,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -7064,19 +7494,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 && n.expression.kind === 99; + return n.kind === 195 && n.expression.kind === 101; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 && n.expression.kind === 93; + return n.kind === 195 && n.expression.kind === 95; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 95 + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 + return node.kind === 225 && node.expression.kind === 10; } ts.isPrologueDirective = isPrologueDirective; @@ -7085,11 +7521,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 || - node.kind === 151 || - node.kind === 197 || - node.kind === 198 || - node.kind === 196) ? + var commentRanges = (node.kind === 155 || + node.kind === 154 || + node.kind === 200 || + node.kind === 201 || + node.kind === 199) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { @@ -7104,79 +7540,79 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 <= node.kind && node.kind <= 184) { + if (167 <= node.kind && node.kind <= 187) { return true; } switch (node.kind) { - case 121: - case 144: - case 136: + case 124: case 147: case 139: - case 124: - case 140: - case 137: + case 150: case 142: - case 133: + case 127: + case 143: + case 140: + case 145: + case 136: return true; - case 107: - return node.parent.kind !== 201; - case 212: + case 109: + return node.parent.kind !== 204; + case 215: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151: - return node.parent.kind === 182 || node.parent.kind === 177; - case 73: - if (node.parent.kind === 149 && node.parent.right === node) { + case 154: + return node.parent.kind === 185 || node.parent.kind === 180; + case 75: + if (node.parent.kind === 152 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 && node.parent.name === node) { + else if (node.parent.kind === 193 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 73 || node.kind === 149 || node.kind === 190, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 149: - case 190: - case 101: { + ts.Debug.assert(node.kind === 75 || node.kind === 152 || node.kind === 193, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 152: + case 193: + case 103: { var parent = node.parent; - if (parent.kind === 168) { + if (parent.kind === 171) { return false; } - if (parent.kind === 184) { + if (parent.kind === 187) { return !parent.isTypeOf; } - if (164 <= parent.kind && parent.kind <= 184) { + if (167 <= parent.kind && parent.kind <= 187) { return true; } switch (parent.kind) { - case 212: + case 215: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151: + case 154: return node === parent.constraint; - case 310: + case 314: return node === parent.constraint; - case 155: - case 154: - case 152: - case 238: - return node === parent.type; - case 240: - case 197: - case 198: case 158: case 157: - case 156: - case 159: - case 160: + case 155: + case 241: return node === parent.type; + case 243: + case 200: + case 201: case 161: + case 160: + case 159: case 162: case 163: return node === parent.type; - case 195: + case 164: + case 165: + case 166: return node === parent.type; - case 192: - case 193: + case 198: + return node === parent.type; + case 195: + case 196: return ts.contains(parent.typeArguments, node); - case 194: + case 197: return false; } } @@ -7198,23 +7634,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231: + case 234: return visitor(node); - case 247: - case 219: - case 223: - case 224: - case 225: + case 250: + case 222: case 226: case 227: case 228: - case 232: - case 233: - case 272: - case 273: - case 234: + case 229: + case 230: + case 231: + case 235: case 236: case 275: + case 276: + case 237: + case 239: + case 278: return ts.forEachChild(node, traverse); } } @@ -7224,23 +7660,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208: + case 211: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244: - case 242: + case 247: case 245: - case 243: - case 241: - case 210: + case 248: + case 246: + case 244: + case 213: return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150) { + if (node.name && node.name.kind === 153) { traverse(node.name.expression); return; } @@ -7253,10 +7689,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 170) { + if (node && node.kind === 173) { return node.elementType; } - else if (node && node.kind === 165) { + else if (node && node.kind === 168) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7266,12 +7702,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242: - case 241: - case 210: - case 169: + case 245: + case 244: + case 213: + case 172: return node.members; - case 189: + case 192: return node.properties; } } @@ -7279,14 +7715,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187: - case 279: - case 152: - case 276: + case 190: + case 282: case 155: - case 154: - case 277: - case 238: + case 279: + case 158: + case 157: + case 280: + case 241: return true; } } @@ -7298,8 +7734,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 - && node.parent.parent.kind === 220; + return node.parent.kind === 242 + && node.parent.parent.kind === 224; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -7310,13 +7746,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157: - case 156: - case 158: - case 159: case 160: - case 240: - case 197: + case 159: + case 161: + case 162: + case 163: + case 243: + case 200: return true; } return false; @@ -7327,7 +7763,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234) { + if (node.statement.kind !== 237) { return node.statement; } node = node.statement; @@ -7335,17 +7771,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 && ts.isFunctionLike(node.parent); + return node && node.kind === 222 && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 && node.parent.kind === 189; + return node && node.kind === 160 && node.parent.kind === 192; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 && - (node.parent.kind === 189 || - node.parent.kind === 210); + return node.kind === 160 && + (node.parent.kind === 192 || + node.parent.kind === 213); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7358,7 +7794,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276) { + if (property.kind === 279) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -7399,46 +7835,46 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285); + ts.Debug.assert(node.kind !== 288); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); } switch (node.kind) { - case 150: + case 153: if (ts.isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 153: - if (node.parent.kind === 152 && ts.isClassElement(node.parent.parent)) { + case 156: + if (node.parent.kind === 155 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { node = node.parent; } break; - case 198: + case 201: if (!includeArrowFunctions) { continue; } - case 240: - case 197: - case 245: - case 155: - case 154: - case 157: - case 156: + case 243: + case 200: + case 248: case 158: - case 159: + case 157: case 160: + case 159: case 161: case 162: case 163: - case 244: - case 285: + case 164: + case 165: + case 166: + case 247: + case 288: return node; } } @@ -7448,9 +7884,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 158: - case 240: - case 197: + case 161: + case 243: + case 200: return container; } } @@ -7464,25 +7900,25 @@ var ts; return node; } switch (node.kind) { - case 150: + case 153: node = node.parent; break; - case 240: - case 197: - case 198: + case 243: + case 200: + case 201: if (!stopOnFunctions) { continue; } - case 155: - case 154: - case 157: - case 156: case 158: - case 159: + case 157: case 160: + case 159: + case 161: + case 162: + case 163: return node; - case 153: - if (node.parent.kind === 152 && ts.isClassElement(node.parent.parent)) { + case 156: + if (node.parent.kind === 155 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { @@ -7494,46 +7930,46 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 || func.kind === 198) { + if (func.kind === 200 || func.kind === 201) { var prev = func; var parent = func.parent; - while (parent.kind === 196) { + while (parent.kind === 199) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 && parent.expression === prev) { + if (parent.kind === 195 && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 + return node.kind === 101 || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 || kind === 191) - && node.expression.kind === 99; + return (kind === 193 || kind === 194) + && node.expression.kind === 101; } ts.isSuperProperty = isSuperProperty; function isThisProperty(node) { var kind = node.kind; - return (kind === 190 || kind === 191) - && node.expression.kind === 101; + return (kind === 193 || kind === 194) + && node.expression.kind === 103; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165: + case 168: return node.typeName; - case 212: + case 215: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73: - case 149: + case 75: + case 152: return node; } return undefined; @@ -7541,10 +7977,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194: + case 197: return node.tag; - case 263: - case 262: + case 266: + case 265: return node.tagName; default: return node.expression; @@ -7553,21 +7989,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241: + case 244: return true; - case 155: - return parent.kind === 241; - case 159: + case 158: + return parent.kind === 244; + case 162: + case 163: case 160: - case 157: return node.body !== undefined - && parent.kind === 241; - case 152: + && parent.kind === 244; + case 155: return parent.body !== undefined - && (parent.kind === 158 - || parent.kind === 157 - || parent.kind === 160) - && grandparent.kind === 241; + && (parent.kind === 161 + || parent.kind === 160 + || parent.kind === 163) + && grandparent.kind === 244; } return false; } @@ -7583,10 +8019,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241: + case 244: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); - case 157: case 160: + case 163: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); default: return false; @@ -7595,9 +8031,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 || - parent.kind === 262 || - parent.kind === 264) { + if (parent.kind === 266 || + parent.kind === 265 || + parent.kind === 267) { return parent.tagName === node; } return false; @@ -7605,56 +8041,56 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { + case 101: case 99: - case 97: - case 103: - case 88: + case 105: + case 90: case 13: - case 188: - case 189: - case 190: case 191: case 192: case 193: case 194: - case 213: case 195: - case 214: case 196: case 197: - case 210: + case 216: case 198: - case 201: + case 217: case 199: case 200: - case 203: + case 213: + case 201: case 204: - case 205: + case 202: + case 203: case 206: - case 209: case 207: - case 14: - case 211: - case 261: - case 262: - case 265: case 208: - case 202: - case 215: + case 209: + case 212: + case 210: + case 214: + case 264: + case 265: + case 268: + case 211: + case 205: + case 218: return true; - case 149: - while (node.parent.kind === 149) { + case 152: + while (node.parent.kind === 152) { node = node.parent; } - return node.parent.kind === 168 || isJSXTagName(node); - case 73: - if (node.parent.kind === 168 || isJSXTagName(node)) { + return node.parent.kind === 171 || isJSXTagName(node); + case 75: + if (node.parent.kind === 171 || isJSXTagName(node)) { return true; } case 8: case 9: case 10: - case 101: + case 14: + case 103: return isInExpressionContext(node); default: return false; @@ -7664,49 +8100,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238: - case 152: + case 241: case 155: - case 154: + case 158: + case 157: + case 282: case 279: - case 276: - case 187: + case 190: return parent.initializer === node; - case 222: - case 223: - case 224: case 225: - case 231: - case 232: - case 233: - case 272: + case 226: + case 227: + case 228: + case 234: case 235: + case 236: + case 275: + case 238: return parent.expression === node; - case 226: + case 229: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242) || forStatement.condition === node || forStatement.incrementor === node; - case 227: - case 228: + case 230: + case 231: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242) || forInStatement.expression === node; - case 195: - case 213: - return node === parent.expression; - case 217: + case 198: + case 216: return node === parent.expression; - case 150: + case 220: return node === parent.expression; case 153: - case 271: - case 270: - case 278: + return node === parent.expression; + case 156: + case 274: + case 273: + case 281: return true; - case 212: + case 215: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277: + case 280: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -7714,7 +8150,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 && node.moduleReference.kind === 260; + return node.kind === 252 && node.moduleReference.kind === 263; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7723,7 +8159,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 && node.moduleReference.kind !== 260; + return node.kind === 252 && node.moduleReference.kind !== 263; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -7735,15 +8171,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536); + return !!node && !!(node.flags & 131072); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216); + return !!node && !!(node.flags & 33554432); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152); + return !!node && !!(node.flags & 4194304); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -7751,15 +8187,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 || node.typeArguments[0].kind === 136); + (node.typeArguments[0].kind === 142 || node.typeArguments[0].kind === 139); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192) { + if (callExpression.kind !== 195) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 || expression.escapedText !== "require") { + if (expression.kind !== 75 || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -7790,21 +8226,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - 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 === 60 && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 || parentNodeOperator === 60) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -7814,12 +8254,13 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(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 === 55 && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 || node.initializer.operatorToken.kind === 60) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -7832,10 +8273,16 @@ var ts; } 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); }); + 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 === 60) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -7851,11 +8298,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 || e.kind === 198 ? initializer : undefined; + return e.kind === 200 || e.kind === 201 ? initializer : undefined; } - if (initializer.kind === 197 || - initializer.kind === 210 || - initializer.kind === 198) { + if (initializer.kind === 200 || + initializer.kind === 213 || + initializer.kind === 201) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -7864,22 +8311,24 @@ var ts; } ts.getExpandoInitializer = getExpandoInitializer; function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 || initializer.operatorToken.kind === 60) + && 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 === 60 ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 ? 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 === 55 && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 || node.parent.operatorToken.kind === 60) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -7889,19 +8338,20 @@ var ts; } ts.getNameOfExpando = getNameOfExpando; function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -7916,10 +8366,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); return special === 5 || isInJSFile(expr) ? special : 0; @@ -7932,52 +8385,108 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0]); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103) || + isEntityNameExpression(node.expression) || + isBindableStaticElementAccessExpression(node.expression, true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 || isBindableStaticNameExpression(node.expression, true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9; } return 7; } - if (expr.operatorToken.kind !== 60 || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 || !isAccessExpression(expr.left)) { return 0; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { return 6; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); } + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; + } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; + } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101) { + if (lhs.expression.kind === 103) { return 4; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { return 2; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, true)) { if (isPrototypeAccess(lhs.expression)) { return 3; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") { return 1; } return 5; @@ -7998,7 +8507,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 && + expr.parent && expr.parent.kind === 225 && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -8007,7 +8517,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -8016,14 +8526,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250: - case 256: + case 253: + case 259: return node.parent; - case 260: + case 263: return node.parent.parent; - case 192: + case 195: return isImportCall(node.parent) || isRequireCall(node.parent, false) ? node.parent : undefined; - case 183: + case 186: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -8033,12 +8543,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250: - case 256: + case 253: + case 259: return node.moduleSpecifier; - case 249: - return node.moduleReference.kind === 260 ? node.moduleReference.expression : undefined; - case 184: + case 252: + return node.moduleReference.kind === 263 ? node.moduleReference.expression : undefined; + case 187: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -8047,11 +8557,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250: + case 253: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249: + case 252: return node; - case 256: + case 259: return undefined; default: return ts.Debug.assertNever(node); @@ -8059,19 +8569,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 && !!node.importClause && !!node.importClause.name; + return node.kind === 253 && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152: - case 157: - case 156: - case 277: - case 276: case 155: - case 154: + case 160: + case 159: + case 280: + case 279: + case 158: + case 157: return node.questionToken !== undefined; } } @@ -8085,7 +8595,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 || node.kind === 304; + return node.kind === 315 || node.kind === 308 || node.kind === 309; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -8095,7 +8605,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 + node.expression.operatorToken.kind === 62 ? node.expression.right : undefined; } @@ -8104,18 +8614,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 + (node.expression.right.operatorToken.kind === 56 || node.expression.right.operatorToken.kind === 60) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220: + case 224: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155: + case 158: return node.initializer; - case 276: + case 279: return node.initializer; } } @@ -8126,7 +8636,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 + node.body.kind === 248 ? node.body : undefined; } @@ -8140,11 +8650,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152) { + if (node.kind === 155) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151) { + if (node.kind === 154) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -8155,17 +8665,17 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 || - parent.kind === 255 || - parent.kind === 155 || - parent.kind === 222 && node.kind === 190 || + if (parent.kind === 279 || + parent.kind === 258 || + parent.kind === 158 || + parent.kind === 225 && node.kind === 193 || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62) { return parent; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -8187,7 +8697,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -8212,7 +8722,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -8222,38 +8732,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 === 296; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299; } ts.isRestParameter = isRestParameter; function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { switch (parent.kind) { - case 205: + case 208: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 ? 1 : 2 : + binaryOperator === 62 ? 1 : 2 : 0; - case 203: - case 204: + case 206: + case 207: var unaryOperator = parent.operator; - return unaryOperator === 44 || unaryOperator === 45 ? 2 : 0; - case 227: - case 228: + return unaryOperator === 45 || unaryOperator === 46 ? 2 : 0; + case 230: + case 231: return parent.initializer === node ? 1 : 0; - case 196: - case 188: - case 209: - case 214: + case 199: + case 191: + case 212: + case 217: node = parent; break; - case 277: + case 280: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 276: + case 279: if (parent.name === node) { return 0; } @@ -8272,22 +8782,22 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219: - case 220: - case 232: - case 223: - case 233: - case 247: - case 272: - case 273: - case 234: - case 226: - case 227: - case 228: + case 222: case 224: - case 225: + case 235: + case 226: case 236: + case 250: case 275: + case 276: + case 237: + case 229: + case 230: + case 231: + case 227: + case 228: + case 239: + case 278: return true; } return false; @@ -8304,32 +8814,32 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178); + return walkUp(node, 181); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196); + return walkUp(node, 199); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196) { + while (node.kind === 199) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196) { + while (node.kind === 199) { node = node.parent; } return node; } function isDeleteTarget(node) { - if (node.kind !== 190 && node.kind !== 191) { + if (node.kind !== 193 && node.kind !== 194) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199; + return node && node.kind === 202; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -8349,10 +8859,11 @@ var ts; var parent = name.parent; switch (name.kind) { case 10: + case 14: case 8: if (ts.isComputedPropertyName(parent)) return parent.parent; - case 73: + case 75: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -8375,58 +8886,73 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 || node.kind === 8) && - node.parent.kind === 150 && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155: - case 154: + case 158: case 157: - case 156: - case 159: case 160: + case 159: + case 162: + case 163: + case 282: case 279: - case 276: - case 190: + case 193: return parent.name === node; - case 149: + case 152: if (parent.right === node) { - while (parent.kind === 149) { + while (parent.kind === 152) { parent = parent.parent; } - return parent.kind === 168 || parent.kind === 165; + return parent.kind === 171 || parent.kind === 168; } return false; - case 187: - case 254: + case 190: + case 257: return parent.propertyName === node; - case 258: - case 268: + case 261: + case 271: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 249 || - node.kind === 248 || - node.kind === 251 && !!node.name || - node.kind === 252 || - node.kind === 254 || - node.kind === 258 || - node.kind === 255 && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node); + return node.kind === 252 || + node.kind === 251 || + node.kind === 254 && !!node.name || + node.kind === 255 || + node.kind === 257 || + node.kind === 261 || + node.kind === 258 && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 && isAliasableExpression(node.parent.right) || + node.kind === 280 || + node.kind === 279 && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 ? node.name : node.kind === 279 ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -8439,23 +8965,23 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87); + var heritageClause = getHeritageClause(node.heritageClauses, 89); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110); + var heritageClause = getHeritageClause(node.heritageClauses, 112); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87); + var heritageClause = getHeritageClause(node.heritageClauses, 89); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -8482,22 +9008,31 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 <= token && token <= 148; + return 76 <= token && token <= 151; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 <= token && token <= 148; + return 121 <= token && token <= 151; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 112 <= token && token <= 120; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -8513,13 +9048,13 @@ var ts; } var flags = 0; switch (node.kind) { - case 240: - case 197: - case 157: + case 243: + case 200: + case 160: if (node.asteriskToken) { flags |= 1; } - case 198: + case 201: if (hasModifier(node, 256)) { flags |= 2; } @@ -8533,10 +9068,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240: - case 197: - case 198: - case 157: + case 243: + case 200: + case 201: + case 160: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256); @@ -8549,7 +9084,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 || node.operator === 39) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 || node.operator === 40) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; function hasDynamicName(declaration) { @@ -8558,10 +9093,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 || name.kind === 194)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; function isWellKnownSymbolSyntactically(node) { @@ -8570,12 +9108,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73: + case 75: return name.escapedText; case 10: case 8: return ts.escapeLeadingUnderscores(name.text); - case 150: + case 153: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -8591,7 +9129,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73: + case 75: case 10: case 14: case 8: @@ -8602,11 +9140,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 ? ts.idText(node) : node.text; + return node.kind === 75 ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -8618,7 +9156,7 @@ var ts; } ts.isKnownSymbol = isKnownSymbol; function isESSymbolIdentifier(node) { - return node.kind === 73 && node.escapedText === "Symbol"; + return node.kind === 75 && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -8627,11 +9165,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152; + return root.kind === 155; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187) { + while (node.kind === 190) { node = node.parent.parent; } return node; @@ -8639,15 +9177,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 - || kind === 197 - || kind === 240 - || kind === 198 - || kind === 157 - || kind === 159 + return kind === 161 + || kind === 200 + || kind === 243 + || kind === 201 || kind === 160 - || kind === 245 - || kind === 285; + || kind === 162 + || kind === 163 + || kind === 248 + || kind === 288; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -8661,38 +9199,38 @@ var ts; ts.getOriginalSourceFile = getOriginalSourceFile; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193: + case 196: return hasArguments ? 0 : 1; + case 206: case 203: - case 200: - case 201: - case 199: + case 204: case 202: - case 206: - case 208: - return 1; case 205: + case 209: + case 211: + return 1; + case 208: switch (operator) { - case 41: - case 60: - case 61: + case 42: case 62: - case 64: case 63: - case 65: + case 64: case 66: + case 65: case 67: case 68: case 69: case 70: - case 72: case 71: + case 72: + case 74: + case 73: return 1; } } @@ -8701,15 +9239,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205) { + if (expression.kind === 208) { return expression.operatorToken.kind; } - else if (expression.kind === 203 || expression.kind === 204) { + else if (expression.kind === 206 || expression.kind === 207) { return expression.operator; } else { @@ -8719,73 +9257,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316: + case 320: return 0; - case 209: + case 212: return 1; - case 208: + case 211: return 2; - case 206: + case 209: return 4; - case 205: + case 208: switch (operatorKind) { case 27: return 0; - case 60: - case 61: case 62: - case 64: case 63: - case 65: + case 64: case 66: + case 65: case 67: case 68: case 69: case 70: - case 72: case 71: + case 72: + case 74: + case 73: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } + case 206: case 203: - case 200: - case 201: - case 199: + case 204: case 202: + case 205: return 16; - case 204: + case 207: return 17; - case 192: + case 195: return 18; - case 193: + case 196: return hasArguments ? 19 : 18; + case 197: + case 193: case 194: - case 190: - case 191: return 19; + case 103: case 101: + case 75: case 99: - case 73: - case 97: - case 103: - case 88: + case 105: + case 90: case 8: case 9: case 10: - case 188: - case 189: - case 197: - case 198: - case 210: - case 261: - case 262: + case 191: + case 192: + case 200: + case 201: + case 213: + case 264: case 265: + case 268: case 13: case 14: - case 207: - case 196: - case 211: + case 210: + case 199: + case 214: return 20; default: return -1; @@ -8794,41 +9332,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55: + case 60: + return 4; + case 56: return 5; - case 54: + case 55: return 6; - case 50: - return 7; case 51: + return 7; + case 52: return 8; - case 49: + case 50: return 9; - case 33: case 34: case 35: case 36: + case 37: return 10; - case 28: - case 30: + case 29: case 31: case 32: - case 95: - case 94: - case 120: + case 33: + case 97: + case 96: + case 122: return 11; - case 46: case 47: case 48: + case 49: return 12; - case 38: case 39: - return 13; case 40: - case 42: + return 13; + case 41: case 43: + case 44: return 14; - case 41: + case 42: return 15; } return -1; @@ -8902,9 +9442,13 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -8929,16 +9473,17 @@ var ts; ts.escapeString = escapeString; function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 || + charCode === 34 || + charCode === 96; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0) { var lookAhead = input.charCodeAt(offset + c.length); @@ -8985,6 +9530,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -8996,7 +9542,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -9006,17 +9552,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -9030,6 +9588,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -9049,6 +9608,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -9063,12 +9624,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -9076,7 +9637,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -9132,7 +9693,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -9237,6 +9798,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); return parameter && parameter.type; @@ -9256,11 +9818,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 && identifierIsThisKeyword(node); + return !!node && node.kind === 75 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101; + return id.originalKeywordKind === 103; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -9270,10 +9832,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159) { + if (accessor.kind === 162) { getAccessor = accessor; } - else if (accessor.kind === 160) { + else if (accessor.kind === 163) { setAccessor = accessor; } else { @@ -9293,10 +9855,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 && !getAccessor) { + if (member.kind === 162 && !getAccessor) { getAccessor = member; } - if (member.kind === 160 && !setAccessor) { + if (member.kind === 163 && !setAccessor) { setAccessor = member; } } @@ -9333,7 +9895,7 @@ var ts; } ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 297 && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 && tag.parent.tags.some(isJSDocTypeAlias)); } function getEffectiveSetAccessorTypeAnnotationNode(node) { var parameter = getSetAccessorValueParameter(node); @@ -9525,7 +10087,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 || (node.kind === 73 && node.isInJSDocNamespace)) { + if (node.flags & 4 || (node.kind === 75 && node.isInJSDocNamespace)) { flags |= 1; } return flags; @@ -9533,29 +10095,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117: return 32; - case 116: return 4; - case 115: return 16; - case 114: return 8; - case 119: return 128; - case 86: return 1; - case 126: return 2; - case 78: return 2048; - case 81: return 512; - case 122: return 256; - case 134: return 64; + case 119: return 32; + case 118: return 4; + case 117: return 16; + case 116: return 8; + case 121: return 128; + case 88: return 1; + case 129: return 2; + case 80: return 2048; + case 83: return 512; + case 125: return 256; + case 137: return 64; } return 0; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 - || token === 54 - || token === 52; + return token === 56 + || token === 55 + || token === 53; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 && token <= 72; + return token >= 62 && token <= 74; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { @@ -9567,14 +10129,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 + ? node.operatorToken.kind === 62 : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -9582,8 +10144,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 189 - || kind === 188; + return kind === 192 + || kind === 191; } return false; } @@ -9593,9 +10155,15 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function isDottedName(node) { + return node.kind === 75 || node.kind === 103 || + node.kind === 193 && isDottedName(node.expression) || + node.kind === 199 && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -9611,21 +10179,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 && node.parent.right === node) || - (node.parent.kind === 190 && node.parent.name === node); + return (node.parent.kind === 152 && node.parent.right === node) || + (node.parent.kind === 193 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 && + return expression.kind === 192 && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 && + return expression.kind === 191 && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -9863,8 +10431,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244: - case 245: + case 247: + case 248: return parseNode === parseNode.parent.name; } } @@ -9930,32 +10498,32 @@ var ts; if (!parent) return 0; switch (parent.kind) { - case 196: + case 199: return accessKind(parent); - case 204: - case 203: + case 207: + case 206: var operator = parent.operator; - return operator === 44 || operator === 45 ? writeOrReadWrite() : 0; - case 205: + return operator === 45 || operator === 46 ? writeOrReadWrite() : 0; + case 208: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 ? 1 : writeOrReadWrite() + operatorToken.kind === 62 ? 1 : writeOrReadWrite() : 0; - case 190: + case 193: return parent.name !== node ? 0 : accessKind(parent); - case 276: { + case 279: { var parentAccess = accessKind(parent.parent); return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 277: + case 280: return node === parent.objectAssignmentInitializer ? 0 : accessKind(parent.parent); - case 188: + case 191: return accessKind(parent); default: return 0; } function writeOrReadWrite() { - return parent.parent && skipParenthesesUp(parent.parent).kind === 222 ? 1 : 2; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 ? 1 : 2; } } function reverseAccessKind(a) { @@ -9994,8 +10562,8 @@ var ts; map.clear(); } ts.clearMap = clearMap; - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); if (valueInNewMap === undefined) { @@ -10006,6 +10574,11 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + function mutateMap(map, newMap, options) { + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { map.set(key, createNewValue(key, valueInNewMap)); @@ -10095,32 +10668,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 && kind <= 184) - || kind === 121 - || kind === 144 - || kind === 136 - || kind === 147 - || kind === 137 + return (kind >= 167 && kind <= 187) || kind === 124 + || kind === 147 || kind === 139 + || kind === 150 || kind === 140 - || kind === 101 - || kind === 107 + || kind === 127 || kind === 142 - || kind === 97 - || kind === 133 - || kind === 212 - || kind === 290 - || kind === 291 - || kind === 292 + || kind === 143 + || kind === 103 + || kind === 109 + || kind === 145 + || kind === 99 + || kind === 136 + || kind === 215 || kind === 293 || kind === 294 || kind === 295 - || kind === 296; + || kind === 296 + || kind === 297 + || kind === 298 + || kind === 299; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 || node.kind === 191; + return node.kind === 193 || node.kind === 194; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -10133,6 +10706,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -10266,17 +10843,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151) { + if (d && d.kind === 154) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 158; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92) && parent.kind === 161; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -10306,14 +10883,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238) { + if (node.kind === 241) { node = node.parent; } - if (node && node.kind === 239) { + if (node && node.kind === 242) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220) { + if (node && node.kind === 224) { flags |= getFlags(node); } return flags; @@ -10424,27 +11001,30 @@ var ts; return getDeclarationIdentifier(hostNode); } switch (hostNode.kind) { - case 220: + case 224: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222: + case 225: var expr = hostNode.expression; + if (expr.kind === 208 && expr.operatorToken.kind === 62) { + expr = expr.left; + } switch (expr.kind) { - case 190: + case 193: return expr.name; - case 191: + case 194: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196: { + case 199: { return getDeclarationIdentifier(hostNode.expression); } - case 234: { + case 237: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -10456,6 +11036,16 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -10466,39 +11056,46 @@ var ts; ts.isNamedDeclaration = isNamedDeclaration; function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73: + case 75: return declaration; - case 312: - case 306: { + case 316: + case 310: { var name = declaration.name; - if (name.kind === 149) { + if (name.kind === 152) { return name.right; } break; } - case 192: - case 205: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195: + case 208: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1: case 4: case 5: case 3: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7: case 8: case 9: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 311: + case 315: return getNameOfJSDocTypedef(declaration); - case 255: { + case 309: + return nameForNamelessJSDocTypedef(declaration); + case 258: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -10521,8 +11118,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -10638,7 +11235,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297); + ts.Debug.assert(node.parent.kind === 301); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -10658,10 +11255,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -10703,191 +11299,209 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73; + return node.kind === 75; } ts.isIdentifier = isIdentifier; function isQualifiedName(node) { - return node.kind === 149; + return node.kind === 152; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150; + return node.kind === 153; } ts.isComputedPropertyName = isComputedPropertyName; function isTypeParameterDeclaration(node) { - return node.kind === 151; + return node.kind === 154; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152; + return node.kind === 155; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153; + return node.kind === 156; } ts.isDecorator = isDecorator; function isPropertySignature(node) { - return node.kind === 154; + return node.kind === 157; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155; + return node.kind === 158; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156; + return node.kind === 159; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157; + return node.kind === 160; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158; + return node.kind === 161; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159; + return node.kind === 162; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160; + return node.kind === 163; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161; + return node.kind === 164; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162; + return node.kind === 165; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163; + return node.kind === 166; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 || node.kind === 159; + return node.kind === 163 || node.kind === 162; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isTypePredicateNode(node) { - return node.kind === 164; + return node.kind === 167; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165; + return node.kind === 168; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166; + return node.kind === 169; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167; + return node.kind === 170; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168; + return node.kind === 171; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169; + return node.kind === 172; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170; + return node.kind === 173; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171; + return node.kind === 174; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174; + return node.kind === 177; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175; + return node.kind === 178; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176; + return node.kind === 179; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177; + return node.kind === 180; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178; + return node.kind === 181; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179; + return node.kind === 182; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180; + return node.kind === 183; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181; + return node.kind === 184; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182; + return node.kind === 185; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183; + return node.kind === 186; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184; + return node.kind === 187; } ts.isImportTypeNode = isImportTypeNode; function isObjectBindingPattern(node) { - return node.kind === 185; + return node.kind === 188; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186; + return node.kind === 189; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187; + return node.kind === 190; } ts.isBindingElement = isBindingElement; function isArrayLiteralExpression(node) { - return node.kind === 188; + return node.kind === 191; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189; + return node.kind === 192; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190; + return node.kind === 193; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191; + return node.kind === 194; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192; + return node.kind === 195; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + return isPropertyAccessChain(node) + || isElementAccessChain(node) + || isCallChain(node); + } + ts.isOptionalChain = isOptionalChain; function isNewExpression(node) { - return node.kind === 193; + return node.kind === 196; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194; + return node.kind === 197; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195; + return node.kind === 198; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -10896,368 +11510,368 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196; + return node.kind === 199; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315) { + while (node.kind === 319) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197; + return node.kind === 200; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198; + return node.kind === 201; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199; + return node.kind === 202; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200; + return node.kind === 203; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201; + return node.kind === 204; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202; + return node.kind === 205; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203; + return node.kind === 206; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204; + return node.kind === 207; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205; + return node.kind === 208; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206; + return node.kind === 209; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207; + return node.kind === 210; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208; + return node.kind === 211; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209; + return node.kind === 212; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210; + return node.kind === 213; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211; + return node.kind === 214; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212; + return node.kind === 215; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213; + return node.kind === 216; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214; + return node.kind === 217; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215; + return node.kind === 218; } ts.isMetaProperty = isMetaProperty; function isTemplateSpan(node) { - return node.kind === 217; + return node.kind === 220; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218; + return node.kind === 221; } ts.isSemicolonClassElement = isSemicolonClassElement; function isBlock(node) { - return node.kind === 219; + return node.kind === 222; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220; + return node.kind === 224; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221; + return node.kind === 223; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222; + return node.kind === 225; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223; + return node.kind === 226; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224; + return node.kind === 227; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225; + return node.kind === 228; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226; + return node.kind === 229; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227; + return node.kind === 230; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228; + return node.kind === 231; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229; + return node.kind === 232; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230; + return node.kind === 233; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 || node.kind === 229; + return node.kind === 233 || node.kind === 232; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231; + return node.kind === 234; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232; + return node.kind === 235; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233; + return node.kind === 236; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234; + return node.kind === 237; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235; + return node.kind === 238; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236; + return node.kind === 239; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237; + return node.kind === 240; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238; + return node.kind === 241; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239; + return node.kind === 242; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240; + return node.kind === 243; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241; + return node.kind === 244; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242; + return node.kind === 245; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243; + return node.kind === 246; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244; + return node.kind === 247; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245; + return node.kind === 248; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246; + return node.kind === 249; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247; + return node.kind === 250; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248; + return node.kind === 251; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249; + return node.kind === 252; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250; + return node.kind === 253; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251; + return node.kind === 254; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252; + return node.kind === 255; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253; + return node.kind === 256; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254; + return node.kind === 257; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255; + return node.kind === 258; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256; + return node.kind === 259; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257; + return node.kind === 260; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258; + return node.kind === 261; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259; + return node.kind === 262; } ts.isMissingDeclaration = isMissingDeclaration; function isExternalModuleReference(node) { - return node.kind === 260; + return node.kind === 263; } ts.isExternalModuleReference = isExternalModuleReference; function isJsxElement(node) { - return node.kind === 261; + return node.kind === 264; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262; + return node.kind === 265; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263; + return node.kind === 266; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264; + return node.kind === 267; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265; + return node.kind === 268; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266; + return node.kind === 269; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267; + return node.kind === 270; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268; + return node.kind === 271; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269; + return node.kind === 272; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270; + return node.kind === 273; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271; + return node.kind === 274; } ts.isJsxExpression = isJsxExpression; function isCaseClause(node) { - return node.kind === 272; + return node.kind === 275; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273; + return node.kind === 276; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274; + return node.kind === 277; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275; + return node.kind === 278; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 276; + return node.kind === 279; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277; + return node.kind === 280; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278; + return node.kind === 281; } ts.isSpreadAssignment = isSpreadAssignment; function isEnumMember(node) { - return node.kind === 279; + return node.kind === 282; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 285; + return node.kind === 288; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286; + return node.kind === 289; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287; + return node.kind === 290; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281; + return node.kind === 284; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282: - case 283: + case 285: + case 286: return true; default: return false; @@ -11266,110 +11880,110 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 || - node.kind === 284; + node.kind === 283 || + node.kind === 287; } ts.isUnparsedNode = isUnparsedNode; function isJSDocTypeExpression(node) { - return node.kind === 289; + return node.kind === 292; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290; + return node.kind === 293; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291; + return node.kind === 294; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292; + return node.kind === 295; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293; + return node.kind === 296; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294; + return node.kind === 297; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295; + return node.kind === 298; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296; + return node.kind === 299; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297; + return node.kind === 301; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302; + return node.kind === 306; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301; + return node.kind === 305; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303; + return node.kind === 307; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305; + return node.kind === 309; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308; + return node.kind === 312; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306; + return node.kind === 310; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307; + return node.kind === 311; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309; + return node.kind === 313; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310; + return node.kind === 314; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311; + return node.kind === 315; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312; + return node.kind === 316; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 || node.kind === 306; + return node.kind === 316 || node.kind === 310; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298; + return node.kind === 302; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304; + return node.kind === 308; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299; + return node.kind === 303; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); (function (ts) { function isSyntaxList(n) { - return n.kind === 313; + return n.kind === 317; } ts.isSyntaxList = isSyntaxList; function isNode(node) { @@ -11377,11 +11991,11 @@ var ts; } ts.isNode = isNode; function isNodeKind(kind) { - return kind >= 149; + return kind >= 152; } ts.isNodeKind = isNodeKind; function isToken(n) { - return n.kind >= 0 && n.kind <= 148; + return n.kind >= 0 && n.kind <= 151; } ts.isToken = isToken; function isNodeArray(array) { @@ -11424,17 +12038,17 @@ var ts; ts.isGeneratedIdentifier = isGeneratedIdentifier; function isModifierKind(token) { switch (token) { - case 119: - case 122: - case 78: - case 126: - case 81: - case 86: + case 121: + case 125: + case 80: + case 129: + case 83: + case 88: + case 118: case 116: - case 114: - case 115: - case 134: case 117: + case 137: + case 119: return true; } return false; @@ -11445,7 +12059,7 @@ var ts; } ts.isParameterPropertyModifier = isParameterPropertyModifier; function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117; + return isParameterPropertyModifier(idToken) || idToken === 119; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -11454,23 +12068,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 - || kind === 73; + return kind === 152 + || kind === 75; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 + return kind === 75 || kind === 10 || kind === 8 - || kind === 150; + || kind === 153; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 - || kind === 185 - || kind === 186; + return kind === 75 + || kind === 188 + || kind === 189; } ts.isBindingName = isBindingName; function isFunctionLike(node) { @@ -11483,13 +12097,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240: - case 157: - case 158: - case 159: + case 243: case 160: - case 197: - case 198: + case 161: + case 162: + case 163: + case 200: + case 201: return true; default: return false; @@ -11497,14 +12111,14 @@ var ts; } function isFunctionLikeKind(kind) { switch (kind) { - case 156: - case 161: - case 299: - case 162: - case 163: + case 159: + case 164: + case 303: + case 165: case 166: - case 295: - case 167: + case 169: + case 298: + case 170: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -11517,28 +12131,28 @@ var ts; ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; - return kind === 158 - || kind === 155 - || kind === 157 - || kind === 159 + return kind === 161 + || kind === 158 || kind === 160 + || kind === 162 || kind === 163 - || kind === 218; + || kind === 166 + || kind === 221; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 || node.kind === 210); + return node && (node.kind === 244 || node.kind === 213); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 || node.kind === 160); + return node && (node.kind === 162 || node.kind === 163); } ts.isAccessor = isAccessor; function isMethodOrAccessor(node) { switch (node.kind) { - case 157: - case 159: case 160: + case 162: + case 163: return true; default: return false; @@ -11547,11 +12161,11 @@ var ts; ts.isMethodOrAccessor = isMethodOrAccessor; function isTypeElement(node) { var kind = node.kind; - return kind === 162 - || kind === 161 - || kind === 154 - || kind === 156 - || kind === 163; + return kind === 165 + || kind === 164 + || kind === 157 + || kind === 159 + || kind === 166; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -11560,12 +12174,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 - || kind === 277 - || kind === 278 - || kind === 157 - || kind === 159 - || kind === 160; + return kind === 279 + || kind === 280 + || kind === 281 + || kind === 160 + || kind === 162 + || kind === 163; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNode(node) { @@ -11574,8 +12188,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166: - case 167: + case 169: + case 170: return true; } return false; @@ -11584,29 +12198,29 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 - || kind === 185; + return kind === 189 + || kind === 188; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 - || kind === 189; + return kind === 191 + || kind === 192; } ts.isAssignmentPattern = isAssignmentPattern; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 - || kind === 211; + return kind === 190 + || kind === 214; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238: - case 152: - case 187: + case 241: + case 155: + case 190: return true; } return false; @@ -11619,8 +12233,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185: - case 189: + case 188: + case 192: return true; } return false; @@ -11628,8 +12242,8 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186: - case 188: + case 189: + case 191: return true; } return false; @@ -11637,25 +12251,25 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 - || kind === 149 - || kind === 184; + return kind === 193 + || kind === 152 + || kind === 187; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 - || kind === 149; + return kind === 193 + || kind === 152; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263: - case 262: - case 192: - case 193: - case 194: - case 153: + case 266: + case 265: + case 195: + case 196: + case 197: + case 156: return true; default: return false; @@ -11663,12 +12277,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 || node.kind === 193; + return node.kind === 195 || node.kind === 196; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 + return kind === 210 || kind === 14; } ts.isTemplateLiteral = isTemplateLiteral; @@ -11678,34 +12292,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190: - case 191: case 193: - case 192: - case 261: - case 262: - case 265: case 194: - case 188: case 196: - case 189: - case 210: + case 195: + case 264: + case 265: + case 268: case 197: - case 73: + case 191: + case 199: + case 192: + case 213: + case 200: + case 75: case 13: case 8: case 9: case 10: case 14: - case 207: - case 88: - case 97: - case 101: - case 103: + case 210: + case 90: case 99: - case 214: - case 215: - case 93: + case 103: + case 105: + case 101: + case 217: + case 218: + case 95: return true; default: return false; @@ -11717,13 +12331,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { + case 206: + case 207: + case 202: case 203: case 204: - case 199: - case 200: - case 201: - case 202: - case 195: + case 205: + case 198: return true; default: return isLeftHandSideExpressionKind(kind); @@ -11731,11 +12345,11 @@ var ts; } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204: + case 207: return true; - case 203: - return expr.operator === 44 || - expr.operator === 45; + case 206: + return expr.operator === 45 || + expr.operator === 46; default: return false; } @@ -11747,15 +12361,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206: - case 208: - case 198: - case 205: case 209: - case 213: case 211: - case 316: - case 315: + case 201: + case 208: + case 212: + case 216: + case 214: + case 320: + case 319: return true; default: return isUnaryExpressionKind(kind); @@ -11763,18 +12377,22 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 - || kind === 213; + return kind === 198 + || kind === 216; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 315; + return node.kind === 319; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 314; + return node.kind === 318; } ts.isNotEmittedStatement = isNotEmittedStatement; + function isSyntheticReference(node) { + return node.kind === 323; + } + ts.isSyntheticReference = isSyntheticReference; function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -11782,20 +12400,36 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226: + case 229: + case 230: + case 231: case 227: case 228: - case 224: - case 225: return true; - case 234: + case 237: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + function isExternalModuleIndicator(result) { + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; function isForInOrOfStatement(node) { - return node.kind === 227 || node.kind === 228; + return node.kind === 230 || node.kind === 231; } ts.isForInOrOfStatement = isForInOrOfStatement; function isConciseBody(node) { @@ -11814,108 +12448,108 @@ var ts; ts.isForInitializer = isForInitializer; function isModuleBody(node) { var kind = node.kind; - return kind === 246 - || kind === 245 - || kind === 73; + return kind === 249 + || kind === 248 + || kind === 75; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 - || kind === 245; + return kind === 249 + || kind === 248; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 - || kind === 245; + return kind === 75 + || kind === 248; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 - || kind === 252; + return kind === 256 + || kind === 255; } ts.isNamedImportBindings = isNamedImportBindings; function isModuleOrEnumDeclaration(node) { - return node.kind === 245 || node.kind === 244; + return node.kind === 248 || node.kind === 247; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 - || kind === 187 - || kind === 241 - || kind === 210 - || kind === 158 + return kind === 201 + || kind === 190 || kind === 244 - || kind === 279 - || kind === 258 - || kind === 240 - || kind === 197 - || kind === 159 - || kind === 251 - || kind === 249 + || kind === 213 + || kind === 161 + || kind === 247 + || kind === 282 + || kind === 261 + || kind === 243 + || kind === 200 + || kind === 162 || kind === 254 - || kind === 242 - || kind === 268 - || kind === 157 - || kind === 156 + || kind === 252 + || kind === 257 || kind === 245 + || kind === 271 + || kind === 160 + || kind === 159 || kind === 248 - || kind === 252 - || kind === 152 - || kind === 276 + || kind === 251 + || kind === 255 || kind === 155 + || kind === 279 + || kind === 158 + || kind === 157 + || kind === 163 + || kind === 280 + || kind === 246 || kind === 154 - || kind === 160 - || kind === 277 - || kind === 243 - || kind === 151 - || kind === 238 - || kind === 311 - || kind === 304 - || kind === 312; + || kind === 241 + || kind === 315 + || kind === 308 + || kind === 316; } function isDeclarationStatementKind(kind) { - return kind === 240 - || kind === 259 - || kind === 241 - || kind === 242 - || kind === 243 + return kind === 243 + || kind === 262 || kind === 244 || kind === 245 - || kind === 250 - || kind === 249 - || kind === 256 - || kind === 255 - || kind === 248; + || kind === 246 + || kind === 247 + || kind === 248 + || kind === 253 + || kind === 252 + || kind === 259 + || kind === 258 + || kind === 251; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 + return kind === 233 + || kind === 232 + || kind === 240 + || kind === 227 + || kind === 225 + || kind === 223 + || kind === 230 + || kind === 231 || kind === 229 + || kind === 226 || kind === 237 + || kind === 234 + || kind === 236 + || kind === 238 + || kind === 239 || kind === 224 - || kind === 222 - || kind === 221 - || kind === 227 || kind === 228 - || kind === 226 - || kind === 223 - || kind === 234 - || kind === 231 - || kind === 233 || kind === 235 - || kind === 236 - || kind === 220 - || kind === 225 - || kind === 232 - || kind === 314 || kind === 318 - || kind === 317; + || kind === 322 + || kind === 321; } function isDeclaration(node) { - if (node.kind === 151) { - return (node.parent && node.parent.kind !== 310) || ts.isInJSFile(node); + if (node.kind === 154) { + return (node.parent && node.parent.kind !== 314) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -11936,10 +12570,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219) + if (node.kind !== 222) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 || node.parent.kind === 275) { + if (node.parent.kind === 239 || node.parent.kind === 278) { return false; } } @@ -11947,71 +12581,75 @@ var ts; } function isModuleReference(node) { var kind = node.kind; - return kind === 260 - || kind === 149 - || kind === 73; + return kind === 263 + || kind === 152 + || kind === 75; } ts.isModuleReference = isModuleReference; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 - || kind === 73 - || kind === 190; + return kind === 103 + || kind === 75 + || kind === 193; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 261 - || kind === 271 - || kind === 262 + return kind === 264 + || kind === 274 + || kind === 265 || kind === 11 - || kind === 265; + || kind === 268; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 - || kind === 270; + return kind === 271 + || kind === 273; } ts.isJsxAttributeLike = isJsxAttributeLike; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 - || kind === 271; + || kind === 274; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 - || kind === 262; + return kind === 266 + || kind === 265; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 - || kind === 273; + return kind === 275 + || kind === 276; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isJSDocNode(node) { - return node.kind >= 289 && node.kind <= 312; + return node.kind >= 292 && node.kind <= 316; } ts.isJSDocNode = isJSDocNode; function isJSDocCommentContainingNode(node) { - return node.kind === 297 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; function isJSDocTag(node) { - return node.kind >= 300 && node.kind <= 312; + return node.kind >= 304 && node.kind <= 316; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160; + return node.kind === 163; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159; + return node.kind === 162; } ts.isGetAccessor = isGetAccessor; + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; + } + ts.isOptionalChainRoot = isOptionalChainRoot; function hasJSDocNodes(node) { var jsDoc = node.jsDoc; return !!jsDoc && jsDoc.length > 0; @@ -12030,11 +12668,11 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 || node.kind === 270 || isObjectLiteralElementLike(node); + return node.kind === 271 || node.kind === 273 || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; function isTypeReferenceType(node) { - return node.kind === 165 || node.kind === 212; + return node.kind === 168 || node.kind === 215; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -12068,7 +12706,7 @@ var ts; })(ts || (ts = {})); (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 || node.kind === 257; + return node.kind === 256 || node.kind === 260; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -12490,7 +13128,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } function getPathComponents(path, currentDirectory) { if (currentDirectory === void 0) { currentDirectory = ""; } @@ -12548,6 +13186,35 @@ var ts; return ""; return pathComponents.slice(1).join(ts.directorySeparator); } + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); + } + return result; + } + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); + } + return [getPathFromPathComponents(aParts), getPathFromPathComponents(bParts)]; + } + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); + } })(ts || (ts = {})); (function (ts) { function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { @@ -12569,7 +13236,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -12636,7 +13303,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -13000,14 +13667,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"]; ts.supportedJSExtensions = [".js", ".jsx"]; ts.supportedJSAndJsonExtensions = [".js", ".jsx", ".json"]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json"]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json"]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -13021,7 +13688,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json"]); + return __spreadArrays(supportedExtensions, [".json"]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -13296,8 +13963,10 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + function skipTypeChecking(sourceFile, options, host) { + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { @@ -13389,10 +14058,10 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 285) { + if (kind === 288) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73) { + else if (kind === 75) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -13427,19 +14096,19 @@ var ts; } ts.isJSDocLikeText = isJSDocLikeText; function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 148) { + if (!node || node.kind <= 151) { return; } switch (node.kind) { - case 149: + case 152: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151: + case 154: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277: + case 280: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13447,9 +14116,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278: + case 281: return visitNode(cbNode, node.expression); - case 152: + case 155: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -13457,7 +14126,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155: + case 158: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13465,51 +14134,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154: + case 157: 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 276: + case 279: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 238: + case 241: 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 187: + case 190: 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 169: + case 170: + case 164: + case 165: case 166: - case 167: - case 161: - case 162: - case 163: 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 157: - case 156: - case 158: - case 159: case 160: - case 197: - case 240: - case 198: + case 159: + case 161: + case 162: + case 163: + case 200: + case 243: + case 201: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13521,345 +14190,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165: + case 168: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164: - return visitNode(cbNode, node.parameterName) || + case 167: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168: + case 171: return visitNode(cbNode, node.exprName); - case 169: + case 172: return visitNodes(cbNode, cbNodes, node.members); - case 170: + case 173: return visitNode(cbNode, node.elementType); - case 171: - return visitNodes(cbNode, cbNodes, node.elementTypes); case 174: - case 175: + return visitNodes(cbNode, cbNodes, node.elementTypes); + case 177: + case 178: return visitNodes(cbNode, cbNodes, node.types); - case 176: + case 179: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177: + case 180: return visitNode(cbNode, node.typeParameter); - case 184: + case 187: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178: - case 180: - return visitNode(cbNode, node.type); case 181: + case 183: + return visitNode(cbNode, node.type); + case 184: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182: + case 185: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183: - return visitNode(cbNode, node.literal); - case 185: case 186: - return visitNodes(cbNode, cbNodes, node.elements); + return visitNode(cbNode, node.literal); case 188: - return visitNodes(cbNode, cbNodes, node.elements); case 189: + return visitNodes(cbNode, cbNodes, node.elements); + case 191: + return visitNodes(cbNode, cbNodes, node.elements); + case 192: return visitNodes(cbNode, cbNodes, node.properties); - case 190: + case 193: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191: + case 194: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192: - case 193: + case 195: + case 196: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194: + case 197: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195: + case 198: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196: - return visitNode(cbNode, node.expression); case 199: return visitNode(cbNode, node.expression); - case 200: - return visitNode(cbNode, node.expression); - case 201: + case 202: return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression); + case 204: + return visitNode(cbNode, node.expression); + case 206: return visitNode(cbNode, node.operand); - case 208: + case 211: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202: + case 205: return visitNode(cbNode, node.expression); - case 204: + case 207: return visitNode(cbNode, node.operand); - case 205: + case 208: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213: + case 216: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214: + case 217: return visitNode(cbNode, node.expression); - case 215: + case 218: return visitNode(cbNode, node.name); - case 206: + case 209: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209: + case 212: return visitNode(cbNode, node.expression); - case 219: - case 246: + case 222: + case 249: return visitNodes(cbNode, cbNodes, node.statements); - case 285: + case 288: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220: + case 224: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239: + case 242: return visitNodes(cbNode, cbNodes, node.declarations); - case 222: + case 225: return visitNode(cbNode, node.expression); - case 223: + case 226: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224: + case 227: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225: + case 228: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226: + case 229: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227: + case 230: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228: + case 231: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229: - case 230: + case 232: + case 233: return visitNode(cbNode, node.label); - case 231: + case 234: return visitNode(cbNode, node.expression); - case 232: + case 235: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233: + case 236: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247: + case 250: return visitNodes(cbNode, cbNodes, node.clauses); - case 272: + case 275: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273: + case 276: return visitNodes(cbNode, cbNodes, node.statements); - case 234: + case 237: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235: + case 238: return visitNode(cbNode, node.expression); - case 236: + case 239: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275: + case 278: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153: + case 156: return visitNode(cbNode, node.expression); - case 241: - case 210: + case 244: + case 213: 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 242: + case 245: 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 243: + case 246: 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 244: + case 247: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279: + case 282: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245: + case 248: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249: + case 252: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250: + case 253: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251: + case 254: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248: + case 251: return visitNode(cbNode, node.name); - case 252: + case 255: return visitNode(cbNode, node.name); - case 253: - case 257: - return visitNodes(cbNode, cbNodes, node.elements); case 256: + case 260: + return visitNodes(cbNode, cbNodes, node.elements); + case 259: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254: - case 258: + case 257: + case 261: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255: + case 258: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207: + case 210: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217: + case 220: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150: + case 153: return visitNode(cbNode, node.expression); - case 274: + case 277: return visitNodes(cbNode, cbNodes, node.types); - case 212: + case 215: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260: + case 263: return visitNode(cbNode, node.expression); - case 259: + case 262: return visitNodes(cbNode, cbNodes, node.decorators); - case 316: + case 320: return visitNodes(cbNode, cbNodes, node.elements); - case 261: + case 264: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265: + case 268: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262: - case 263: + case 265: + case 266: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269: + case 272: return visitNodes(cbNode, cbNodes, node.properties); - case 268: + case 271: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270: + case 273: return visitNode(cbNode, node.expression); - case 271: + case 274: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264: + case 267: return visitNode(cbNode, node.tagName); - case 172: - case 173: - case 289: - case 293: + case 175: + case 176: case 292: - case 294: case 296: - return visitNode(cbNode, node.type); case 295: + case 297: + case 299: + return visitNode(cbNode, node.type); + case 298: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297: + case 301: return visitNodes(cbNode, cbNodes, node.tags); - case 306: - case 312: + case 310: + case 316: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302: + case 306: return visitNode(cbNode, node.tagName); - case 301: + case 305: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310: + case 314: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311: + case 315: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 + node.typeExpression.kind === 292 ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304: + case 308: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307: + case 311: + case 313: + case 312: case 309: - case 308: - case 305: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299: + case 303: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298: + case 302: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 300: - case 303: + case 304: + case 307: return visitNode(cbNode, node.tagName); - case 315: + case 319: return visitNode(cbNode, node.expression); } } @@ -13868,12 +14542,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, 6); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -13894,7 +14570,7 @@ var ts; function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { if (aggressiveChecks === void 0) { aggressiveChecks = false; } var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); - newSourceFile.flags |= (sourceFile.flags & 1572864); + newSourceFile.flags |= (sourceFile.flags & 3145728); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -13913,7 +14589,7 @@ var ts; var Parser; (function (Parser) { var scanner = ts.createScanner(99, true); - var disallowInAndDecoratorContext = 2048 | 8192; + var disallowInAndDecoratorContext = 4096 | 16384; var NodeConstructor; var TokenConstructor; var IdentifierConstructor; @@ -13927,6 +14603,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; var contextFlags; var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { @@ -13970,18 +14647,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222); + var statement = createNode(225); switch (token()) { case 22: statement.expression = parseArrayLiteralExpression(); break; - case 103: - case 88: - case 97: + case 105: + case 90: + case 99: statement.expression = parseTokenNode(); break; - case 39: - if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 57; })) { + case 40: + if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 58; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -13990,7 +14667,7 @@ var ts; break; case 8: case 10: - if (lookAhead(function () { return nextToken() !== 57; })) { + if (lookAhead(function () { return nextToken() !== 58; })) { statement.expression = parseLiteralNode(); break; } @@ -14005,6 +14682,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -14029,10 +14709,10 @@ var ts; switch (scriptKind) { case 1: case 2: - contextFlags = 65536; + contextFlags = 131072; break; case 6: - contextFlags = 65536 | 16777216; + contextFlags = 131072 | 33554432; break; default: contextFlags = 0; @@ -14052,11 +14732,12 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304; + contextFlags |= 8388608; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -14110,7 +14791,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { - var sourceFile = new SourceFileConstructor(285, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(288, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14131,16 +14812,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048); + setContextFlag(val, 4096); } function setYieldContext(val) { - setContextFlag(val, 4096); + setContextFlag(val, 8192); } function setDecoratorContext(val) { - setContextFlag(val, 8192); + setContextFlag(val, 16384); } function setAwaitContext(val) { - setContextFlag(val, 16384); + setContextFlag(val, 32768); } function doOutsideOfContext(context, func) { var contextFlagsToClear = context & contextFlags; @@ -14163,40 +14844,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048, func); + return doOutsideOfContext(4096, func); } function disallowInAnd(func) { - return doInsideOfContext(2048, func); + return doInsideOfContext(4096, func); } function doInYieldContext(func) { - return doInsideOfContext(4096, func); + return doInsideOfContext(8192, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192, func); + return doInsideOfContext(16384, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384, func); + return doInsideOfContext(32768, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384, func); + return doOutsideOfContext(32768, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 | 16384, func); + return doInsideOfContext(8192 | 32768, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096); + return inContext(8192); } function inDisallowInContext() { - return inContext(2048); + return inContext(4096); } function inDecoratorContext() { - return inContext(8192); + return inContext(16384); } function inAwaitContext() { - return inContext(16384); + return inContext(32768); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -14223,9 +14904,15 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -14273,16 +14960,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token() === 73) { + if (token() === 75) { return true; } - if (token() === 118 && inYieldContext()) { + if (token() === 120 && inYieldContext()) { return false; } - if (token() === 123 && inAwaitContext()) { + if (token() === 126 && inAwaitContext()) { return false; } - return token() > 109; + return token() > 111; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -14366,7 +15053,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 ? new NodeConstructor(kind, p, p) : - kind === 73 ? new IdentifierConstructor(kind, p, p) : + kind === 75 ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -14390,7 +15077,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768; + node.flags |= 65536; } return node; } @@ -14402,7 +15089,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73) { + if (kind === 75) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -14420,16 +15107,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73); - if (token() !== 73) { + var node = createNode(75); + if (token() !== 75) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } var reportAtCurrentPosition = token() === 1; - return createMissingNode(73, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(75, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -14457,7 +15144,7 @@ var ts; return parsePropertyNameWorker(true); } function parseComputedPropertyName() { - var node = createNode(150); + var node = createNode(153); parseExpected(22); node.expression = allowInAnd(parseExpression); parseExpected(23); @@ -14475,19 +15162,19 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78: - return nextToken() === 85; - case 86: + case 80: + return nextToken() === 87; + case 88: nextToken(); - if (token() === 81) { + if (token() === 83) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 && token() !== 120 && token() !== 18 && canFollowModifier(); - case 81: + return token() !== 41 && token() !== 122 && token() !== 18 && canFollowModifier(); + case 83: return nextTokenCanFollowDefaultKeyword(); - case 117: - case 127: - case 138: + case 119: + case 130: + case 141: nextToken(); return canFollowModifier(); default: @@ -14500,16 +15187,16 @@ var ts; function canFollowModifier() { return token() === 22 || token() === 18 - || token() === 40 + || token() === 41 || token() === 25 || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 || token() === 91 || - token() === 111 || - (token() === 119 && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 || token() === 93 || + token() === 113 || + (token() === 121 && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -14522,7 +15209,7 @@ var ts; case 3: return !(token() === 26 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 75 || token() === 81; + return token() === 77 || token() === 83; case 4: return lookAhead(isTypeMemberStart); case 5: @@ -14532,7 +15219,7 @@ var ts; case 12: switch (token()) { case 22: - case 40: + case 41: case 25: case 24: return true; @@ -14589,7 +15276,7 @@ var ts; ts.Debug.assert(token() === 18); if (nextToken() === 19) { var next = nextToken(); - return next === 27 || next === 18 || next === 87 || next === 110; + return next === 27 || next === 18 || next === 89 || next === 112; } return true; } @@ -14606,8 +15293,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 || - token() === 87) { + if (token() === 112 || + token() === 89) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -14635,13 +15322,13 @@ var ts; case 23: return token() === 19; case 3: - return token() === 19 || token() === 75 || token() === 81; + return token() === 19 || token() === 77 || token() === 83; case 7: - return token() === 18 || token() === 87 || token() === 110; + return token() === 18 || token() === 89 || token() === 112; case 8: return isVariableDeclaratorListTerminator(); case 19: - return token() === 30 || token() === 20 || token() === 18 || token() === 87 || token() === 110; + return token() === 31 || token() === 20 || token() === 18 || token() === 89 || token() === 112; case 11: return token() === 21 || token() === 26; case 15: @@ -14657,9 +15344,9 @@ var ts; case 22: return token() === 18 || token() === 19; case 13: - return token() === 30 || token() === 42; + return token() === 31 || token() === 43; case 14: - return token() === 28 && lookAhead(nextTokenIsSlash); + return token() === 29 && lookAhead(nextTokenIsSlash); default: return false; } @@ -14671,7 +15358,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 37) { + if (token() === 38) { return true; } return false; @@ -14719,7 +15406,7 @@ var ts; if (ts.nodeIsMissing(node) || node.intersectsChange || ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.flags & 12679168; + var nodeContextFlags = node.flags & 25358336; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -14777,17 +15464,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158: + case 161: + case 166: + case 162: case 163: - case 159: - case 160: - case 155: - case 218: + case 158: + case 221: return true; - case 157: + case 160: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 73 && - methodDeclaration.name.originalKeywordKind === 125; + var nameIsConstructor = methodDeclaration.name.kind === 75 && + methodDeclaration.name.originalKeywordKind === 128; return !nameIsConstructor; } } @@ -14796,8 +15483,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272: - case 273: + case 275: + case 276: return true; } } @@ -14806,65 +15493,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240: - case 220: - case 219: - case 223: + case 243: + case 224: case 222: - case 235: - case 231: + case 226: + case 225: + case 238: + case 234: + case 236: case 233: + case 232: case 230: + case 231: case 229: - case 227: case 228: - case 226: - case 225: - case 232: - case 221: - case 236: - case 234: - case 224: + case 235: + case 223: + case 239: case 237: - case 250: - case 249: - case 256: - case 255: - case 245: - case 241: - case 242: + case 227: + case 240: + case 253: + case 252: + case 259: + case 258: + case 248: case 244: - case 243: + case 245: + case 247: + case 246: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279; + return node.kind === 282; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162: - case 156: - case 163: - case 154: - case 161: + case 165: + case 159: + case 166: + case 157: + case 164: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238) { + if (node.kind !== 241) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152) { + if (node.kind !== 155) { return false; } var parameter = node; @@ -14925,7 +15612,7 @@ var ts; if (isListTerminator(kind)) { break; } - parseExpected(27); + parseExpected(27, getExpectedCommaDiagnostic(kind)); if (considerSemicolonAsDelimiter && token() === 26 && !scanner.hasPrecedingLineBreak()) { nextToken(); } @@ -14948,6 +15635,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -14968,7 +15658,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24)) { - if (token() === 28) { + if (token() === 29) { entity.jsdocDotPos = dotPos; break; } @@ -14978,7 +15668,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149, entity.pos); + var node = createNode(152, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -14987,13 +15677,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(73, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207); + var template = createNode(210); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15, "Template head has wrong token kind"); var list = []; @@ -15005,7 +15695,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217); + var span = createNode(220); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19) { @@ -15034,6 +15724,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14: + case 15: + case 16: + case 17: + var isLast = kind === 14 || kind === 17; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -15048,23 +15748,23 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(165); + var node = createNode(168); node.typeName = parseEntityName(true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28) { - node.typeArguments = parseBracketedList(20, parseType, 28, 30); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) { + node.typeArguments = parseBracketedList(20, parseType, 29, 31); } return finishNode(node); } function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165: + case 168: return ts.nodeIsMissing(node.typeName); - case 166: - case 167: { + case 169: + case 170: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178: + case 181: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -15072,20 +15772,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164, lhs.pos); + var node = createNode(167, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179); + var node = createNode(182); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290); + var result = createNode(293); if (postFixEquals) { - return createPostfixType(294, result); + return createPostfixType(297, result); } else { nextToken(); @@ -15093,7 +15793,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293); + var result = createNode(296); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -15104,63 +15804,80 @@ var ts; if (token() === 27 || token() === 19 || token() === 21 || - token() === 30 || - token() === 60 || - token() === 50) { - var result = createNode(291, pos); + token() === 31 || + token() === 62 || + token() === 51) { + var result = createNode(294, pos); return finishNode(result); } else { - var result = createNode(292, pos); + var result = createNode(295, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295); + var result = createNodeWithJSDoc(298); nextToken(); - fillSignature(57, 4 | 32, result); + fillSignature(58, 4 | 32, result); return finishNode(result); } - var node = createNode(165); + var node = createNode(168); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152); - if (token() === 101 || token() === 96) { + var parameter = createNode(155); + if (token() === 103 || token() === 98) { parameter.name = parseIdentifierName(); - parseExpected(57); + parseExpected(58); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(134); + if (moduleSpecifier) { + var moduleTag = createNode(300, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19: + case 1: + case 27: + case 5: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296, dotdotdot.pos); + var variadic = createNode(299, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60) { - return createPostfixType(294, type); + if (token() === 62) { + return createPostfixType(297, type); } return type; } function parseTypeQuery() { - var node = createNode(168); - parseExpected(105); + var node = createNode(171); + parseExpected(107); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151); + var node = createNode(154); node.name = parseIdentifier(); - if (parseOptional(87)) { + if (parseOptional(89)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -15168,18 +15885,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60)) { + if (parseOptional(62)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28) { - return parseBracketedList(19, parseTypeParameter, 28, 30); + if (token() === 29) { + return parseBracketedList(19, parseTypeParameter, 29, 31); } } function parseParameterType() { - if (parseOptional(57)) { + if (parseOptional(58)) { return parseType(); } return undefined; @@ -15188,12 +15905,12 @@ var ts; return token() === 25 || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 || + token() === 59 || isStartOfType(!isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152); - if (token() === 101) { + var node = createNodeWithJSDoc(155); + if (token() === 103) { node.name = createIdentifier(true); node.type = parseParameterType(); return finishNode(node); @@ -15205,7 +15922,7 @@ var ts; if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(56); + node.questionToken = parseOptionalToken(57); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -15223,15 +15940,15 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37) { + if (returnToken === 38) { parseExpected(returnToken); return true; } - else if (parseOptional(57)) { + else if (parseOptional(58)) { return true; } - else if (isType && token() === 37) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57)); + else if (isType && token() === 38) { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58)); nextToken(); return true; } @@ -15261,10 +15978,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162) { - parseExpected(96); + if (kind === 165) { + parseExpected(98); } - fillSignature(57, 4, node); + fillSignature(58, 4, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -15288,17 +16005,17 @@ var ts; else { nextToken(); } - if (token() === 57 || token() === 27) { + if (token() === 58 || token() === 27) { return true; } - if (token() !== 56) { + if (token() !== 57) { return false; } nextToken(); - return token() === 57 || token() === 27 || token() === 23; + return token() === 58 || token() === 27 || token() === 23; } function parseIndexSignatureDeclaration(node) { - node.kind = 163; + node.kind = 166; node.parameters = parseBracketedList(16, parseParameter, 22, 23); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -15306,15 +16023,15 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56); - if (token() === 20 || token() === 28) { - node.kind = 156; - fillSignature(57, 4, node); + node.questionToken = parseOptionalToken(57); + if (token() === 20 || token() === 29) { + node.kind = 159; + fillSignature(58, 4, node); } else { - node.kind = 154; + node.kind = 157; node.type = parseTypeAnnotation(); - if (token() === 60) { + if (token() === 62) { node.initializer = parseInitializer(); } } @@ -15322,7 +16039,7 @@ var ts; return finishNode(node); } function isTypeMemberStart() { - if (token() === 20 || token() === 28) { + if (token() === 20 || token() === 29) { return true; } var idToken = false; @@ -15339,20 +16056,20 @@ var ts; } if (idToken) { return token() === 20 || - token() === 28 || - token() === 56 || + token() === 29 || token() === 57 || + token() === 58 || token() === 27 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 || token() === 28) { - return parseSignatureMember(161); + if (token() === 20 || token() === 29) { + return parseSignatureMember(164); } - if (token() === 96 && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162); + if (token() === 98 && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165); } var node = createNodeWithJSDoc(0); node.modifiers = parseModifiers(); @@ -15363,7 +16080,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 || token() === 28; + return token() === 20 || token() === 29; } function nextTokenIsDot() { return nextToken() === 24; @@ -15371,14 +16088,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20: - case 28: + case 29: case 24: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169); + var node = createNode(172); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -15395,37 +16112,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 || token() === 39) { - return nextToken() === 134; + if (token() === 39 || token() === 40) { + return nextToken() === 137; } - if (token() === 134) { + if (token() === 137) { nextToken(); } - return token() === 22 && nextTokenIsIdentifier() && nextToken() === 94; + return token() === 22 && nextTokenIsIdentifier() && nextToken() === 96; } function parseMappedTypeParameter() { - var node = createNode(151); + var node = createNode(154); node.name = parseIdentifier(); - parseExpected(94); + parseExpected(96); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182); + var node = createNode(185); parseExpected(18); - if (token() === 134 || token() === 38 || token() === 39) { + if (token() === 137 || token() === 39 || token() === 40) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134) { - parseExpectedToken(134); + if (node.readonlyToken.kind !== 137) { + parseExpectedToken(137); } } parseExpected(22); node.typeParameter = parseMappedTypeParameter(); parseExpected(23); - if (token() === 56 || token() === 38 || token() === 39) { + if (token() === 57 || token() === 39 || token() === 40) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56) { - parseExpectedToken(56); + if (node.questionToken.kind !== 57) { + parseExpectedToken(57); } } node.type = parseTypeAnnotation(); @@ -15436,23 +16153,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25)) { - var node = createNode(173, pos); + var node = createNode(176, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152) && type.kind === 292 && type.pos === type.type.pos) { - type.kind = 172; + if (!(contextFlags & 4194304) && type.kind === 295 && type.pos === type.type.pos) { + type.kind = 175; } return type; } function parseTupleType() { - var node = createNode(171); + var node = createNode(174); node.elementTypes = parseBracketedList(21, parseTupleElementType, 22, 23); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178); + var node = createNode(181); parseExpected(20); node.type = parseType(); parseExpected(21); @@ -15460,9 +16177,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96) ? 167 : 166; + var kind = parseOptional(98) ? 170 : 169; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37, 4, node); + fillSignature(38, 4, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -15470,14 +16187,14 @@ var ts; return token() === 24 ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183); + var node = createNode(186); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203); - unaryMinusExpression.operator = 39; + unaryMinusExpression = createNode(206); + unaryMinusExpression.operator = 40; nextToken(); } - var expression = token() === 103 || token() === 88 + var expression = token() === 105 || token() === 90 ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -15490,23 +16207,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93; + return token() === 95; } function parseImportType() { - sourceFile.flags |= 524288; - var node = createNode(184); - if (parseOptional(105)) { + sourceFile.flags |= 1048576; + var node = createNode(187); + if (parseOptional(107)) { node.isTypeOf = true; } - parseExpected(93); + parseExpected(95); parseExpected(20); node.argument = parseType(); parseExpected(21); if (parseOptional(24)) { node.qualifier = parseEntityName(true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28) { - node.typeArguments = parseBracketedList(20, parseType, 28, 30); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) { + node.typeArguments = parseBracketedList(20, parseType, 29, 31); } return finishNode(node); } @@ -15516,49 +16233,51 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121: - case 144: + case 124: + case 147: + case 142: case 139: + case 150: + case 143: + case 127: + case 145: case 136: - case 147: case 140: - case 124: - case 142: - case 133: - case 137: return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40: + case 41: return parseJSDocAllType(false); - case 63: + case 65: return parseJSDocAllType(true); - case 56: + case 60: + scanner.reScanQuestionToken(); + case 57: return parseJSDocUnknownOrNullableType(); - case 91: + case 93: return parseJSDocFunctionType(); - case 52: + case 53: return parseJSDocNonNullableType(); case 14: case 10: case 8: case 9: - case 103: - case 88: + case 105: + case 90: return parseLiteralTypeNode(); - case 39: + case 40: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(true) : parseTypeReference(); - case 107: - case 97: + case 109: + case 99: return parseTokenNode(); - case 101: { + case 103: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105: + case 107: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -15566,51 +16285,54 @@ var ts; return parseTupleType(); case 20: return parseParenthesizedType(); - case 93: + case 95: return parseImportType(); + case 123: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121: - case 144: - case 139: - case 136: - case 147: case 124: - case 134: - case 140: + case 147: + case 142: + case 139: + case 150: + case 127: + case 137: case 143: + case 146: + case 109: + case 145: + case 99: + case 103: case 107: - case 142: - case 97: - case 101: - case 105: - case 133: + case 136: case 18: case 22: - case 28: + case 29: + case 51: case 50: - case 49: - case 96: + case 98: case 10: case 8: case 9: - case 103: - case 88: - case 137: - case 40: - case 56: - case 52: + case 105: + case 90: + case 140: + case 41: + case 57: + case 53: case 25: - case 128: - case 93: + case 131: + case 95: + case 123: return true; - case 91: + case 93: return !inStartOfParameter; - case 39: + case 40: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20: return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -15626,26 +16348,26 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52: - type = createPostfixType(293, type); + case 53: + type = createPostfixType(296, type); break; - case 56: - if (!(contextFlags & 2097152) && lookAhead(nextTokenIsStartOfType)) { + case 57: + if (!(contextFlags & 4194304) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292, type); + type = createPostfixType(295, type); break; case 22: parseExpected(22); if (isStartOfType()) { - var node = createNode(181, type.pos); + var node = createNode(184, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23); type = finishNode(node); } else { - var node = createNode(170, type.pos); + var node = createNode(173, type.pos); node.elementType = type; parseExpected(23); type = finishNode(node); @@ -15664,16 +16386,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180); + var node = createNode(183); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177); - parseExpected(128); - var typeParameter = createNode(151); + var node = createNode(180); + parseExpected(131); + var typeParameter = createNode(154); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -15681,11 +16403,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130: - case 143: - case 134: + case 133: + case 146: + case 137: return parseTypeOperator(operator); - case 128: + case 131: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -15706,13 +16428,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175, parseTypeOperatorOrHigher, 49); + return parseUnionOrIntersectionType(178, parseTypeOperatorOrHigher, 50); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174, parseIntersectionTypeOrHigher, 50); + return parseUnionOrIntersectionType(177, parseIntersectionTypeOrHigher, 51); } function isStartOfFunctionType() { - if (token() === 28) { + if (token() === 29) { return true; } return token() === 20 && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -15721,7 +16443,7 @@ var ts; if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 101) { + if (isIdentifier() || token() === 103) { nextToken(); return true; } @@ -15738,13 +16460,13 @@ var ts; return true; } if (skipParameterStart()) { - if (token() === 57 || token() === 27 || - token() === 56 || token() === 60) { + if (token() === 58 || token() === 27 || + token() === 57 || token() === 62) { return true; } if (token() === 21) { nextToken(); - if (token() === 37) { + if (token() === 38) { return true; } } @@ -15755,7 +16477,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164, typePredicateVariable.pos); + var node = createNode(167, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15766,41 +16489,48 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167); + node.assertsModifier = parseExpectedToken(123); + node.parameterName = token() === 103 ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132) ? parseType() : undefined; + return finishNode(node); + } function parseType() { - return doOutsideOfContext(20480, parseTypeWorker); + return doOutsideOfContext(40960, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96) { + if (isStartOfFunctionType() || token() === 98) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87)) { - var node = createNode(176, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89)) { + var node = createNode(179, type.pos); node.checkType = type; node.extendsType = parseTypeWorker(true); - parseExpected(56); - node.trueType = parseTypeWorker(); parseExpected(57); + node.trueType = parseTypeWorker(); + parseExpected(58); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57) ? parseType() : undefined; + return parseOptional(58) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { + case 103: case 101: case 99: - case 97: - case 103: - case 88: + case 105: + case 90: case 8: case 9: case 10: @@ -15809,14 +16539,14 @@ var ts; case 20: case 22: case 18: - case 91: - case 77: - case 96: - case 42: - case 65: - case 73: - return true; case 93: + case 79: + case 98: + case 43: + case 67: + case 75: + return true; + case 95: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -15827,18 +16557,18 @@ var ts; return true; } switch (token()) { - case 38: case 39: + case 40: + case 54: case 53: - case 52: - case 82: - case 105: + case 84: case 107: - case 44: + case 109: case 45: - case 28: - case 123: - case 118: + case 46: + case 29: + case 126: + case 120: return true; default: if (isBinaryOperator()) { @@ -15849,9 +16579,9 @@ var ts; } function isStartOfExpressionStatement() { return token() !== 18 && - token() !== 91 && - token() !== 77 && - token() !== 58 && + token() !== 93 && + token() !== 79 && + token() !== 59 && isStartOfExpression(); } function parseExpression() { @@ -15870,7 +16600,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { if (isYieldExpression()) { @@ -15881,7 +16611,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 73 && token() === 37) { + if (expr.kind === 75 && token() === 38) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -15890,7 +16620,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118) { + if (token() === 120) { if (inYieldContext()) { return true; } @@ -15903,11 +16633,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208); + var node = createNode(211); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 40 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40); + (token() === 41 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15916,20 +16646,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198, asyncModifier.pos); + node = createNode(201, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198, identifier.pos); + node = createNode(201, identifier.pos); } - var parameter = createNode(152, identifier.pos); + var parameter = createNode(155, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37); + node.equalsGreaterThanToken = parseExpectedToken(38); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -15946,28 +16676,28 @@ var ts; } var isAsync = ts.hasModifier(arrowFunction, 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(37); - arrowFunction.body = (lastToken === 37 || lastToken === 18) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38); + arrowFunction.body = (lastToken === 38 || lastToken === 18) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token() === 20 || token() === 28 || token() === 122) { + if (token() === 20 || token() === 29 || token() === 125) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37) { + if (token() === 38) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122) { + if (token() === 125) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 20 && token() !== 28) { + if (token() !== 20 && token() !== 29) { return 0; } } @@ -15977,8 +16707,8 @@ var ts; if (second === 21) { var third = nextToken(); switch (third) { - case 37: - case 57: + case 38: + case 58: case 18: return 1; default: @@ -15991,41 +16721,41 @@ var ts; if (second === 25) { return 1; } - if (ts.isModifierKind(second) && second !== 122 && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 && lookAhead(nextTokenIsIdentifier)) { return 1; } - if (!isIdentifier() && second !== 101) { + if (!isIdentifier() && second !== 103) { return 0; } switch (nextToken()) { - case 57: + case 58: return 1; - case 56: + case 57: nextToken(); - if (token() === 57 || token() === 27 || token() === 60 || token() === 21) { + if (token() === 58 || token() === 27 || token() === 62 || token() === 21) { return 1; } return 0; case 27: - case 60: + case 62: case 21: return 2; } return 0; } else { - ts.Debug.assert(first === 28); + ts.Debug.assert(first === 29); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87) { + if (third === 89) { var fourth = nextToken(); switch (fourth) { - case 60: - case 30: + case 62: + case 31: return false; default: return true; @@ -16045,10 +16775,18 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 122) { + if (token() === 125) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(0); @@ -16058,27 +16796,27 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 122) { + if (token() === 125) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 37) { + if (scanner.hasPrecedingLineBreak() || token() === 38) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 && token() === 37) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 && token() === 38) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198); + var node = createNodeWithJSDoc(201); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256) ? 2 : 0; - if (!fillSignature(57, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58, isAsync, node) && !allowAmbiguity) { return undefined; } var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 && (hasJSDocFunctionType || token() !== 18)) { + if (!allowAmbiguity && token() !== 38 && (hasJSDocFunctionType || token() !== 18)) { return undefined; } return node; @@ -16088,8 +16826,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 : 0); } if (token() !== 26 && - token() !== 91 && - token() !== 77 && + token() !== 93 && + token() !== 79 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(16 | (isAsync ? 2 : 0)); @@ -16099,18 +16837,18 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(56); + var questionToken = parseOptionalToken(57); if (!questionToken) { return leftOperand; } - var node = createNode(206, leftOperand.pos); + var node = createNode(209, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57); + node.colonToken = parseExpectedToken(58); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73, false, ts.Diagnostics._0_expected, ts.tokenToString(57)); + : createMissingNode(75, false, ts.Diagnostics._0_expected, ts.tokenToString(58)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -16118,22 +16856,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 || t === 148; + return t === 96 || t === 151; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = ts.getBinaryOperatorPrecedence(token()); - var consumeCurrentOperator = token() === 41 ? + var consumeCurrentOperator = token() === 42 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 && inDisallowInContext()) { + if (token() === 96 && inDisallowInContext()) { break; } - if (token() === 120) { + if (token() === 122) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -16149,51 +16887,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94) { + if (inDisallowInContext() && token() === 96) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205, left.pos); + var node = createNode(208, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213, left.pos); + var node = createNode(216, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203); + var node = createNode(206); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199); + var node = createNode(202); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200); + var node = createNode(203); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201); + var node = createNode(204); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123) { + if (token() === 126) { if (inAwaitContext()) { return true; } @@ -16202,7 +16940,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202); + var node = createNode(205); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -16210,16 +16948,16 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 ? + return token() === 42 ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41) { + if (token() === 42) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195) { + if (simpleUnaryExpression.kind === 198) { 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 { @@ -16230,20 +16968,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 38: case 39: + case 40: + case 54: case 53: - case 52: return parsePrefixUnaryExpression(); - case 82: + case 84: return parseDeleteExpression(); - case 105: - return parseTypeOfExpression(); case 107: + return parseTypeOfExpression(); + case 109: return parseVoidExpression(); - case 28: + case 29: return parseTypeAssertion(); - case 123: + case 126: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -16253,16 +16991,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 38: case 39: + case 40: + case 54: case 53: - case 52: - case 82: - case 105: + case 84: case 107: - case 123: + case 109: + case 126: return false; - case 28: + case 29: if (sourceFile.languageVariant !== 1) { return false; } @@ -16271,20 +17009,20 @@ var ts; } } function parseUpdateExpression() { - if (token() === 44 || token() === 45) { - var node = createNode(203); + if (token() === 45 || token() === 46) { + var node = createNode(206); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 28 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 && token() === 29 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { return parseJsxElementOrSelfClosingElementOrFragment(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 || token() === 45) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204, expression.pos); + if ((token() === 45 || token() === 46) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -16294,37 +17032,37 @@ var ts; } function parseLeftHandSideExpressionOrHigher() { var expression; - if (token() === 93) { + if (token() === 95) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { - sourceFile.flags |= 524288; + sourceFile.flags |= 1048576; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { var fullStart = scanner.getStartPos(); nextToken(); nextToken(); - var node = createNode(215, fullStart); - node.keywordToken = 93; + var node = createNode(218, fullStart); + node.keywordToken = 95; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576; + sourceFile.flags |= 2097152; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 ? parseSuperExpression() : parseMemberExpressionOrHigher(); } return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28) { + if (token() === 29) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -16334,7 +17072,7 @@ var ts; if (token() === 20 || token() === 24 || token() === 22) { return expression; } - var node = createNode(190, expression.pos); + var node = createNode(193, expression.pos); node.expression = expression; parseExpectedToken(24, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -16343,8 +17081,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263) { - var node = createNode(261, opening.pos); + if (opening.kind === 266) { + var node = createNode(264, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16353,22 +17091,22 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266) { - var node = createNode(265, opening.pos); + else if (opening.kind === 269) { + var node = createNode(268, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262); + ts.Debug.assert(opening.kind === 265); result = opening; } - if (inExpressionContext && token() === 28) { + if (inExpressionContext && token() === 29) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205, result.pos); + var badNode = createNode(208, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -16396,7 +17134,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29: + case 30: case 7: return undefined; case 11: @@ -16404,7 +17142,7 @@ var ts; return parseJsxText(); case 18: return parseJsxExpression(false); - case 28: + case 29: return parseJsxElementOrSelfClosingElementOrFragment(false); default: return ts.Debug.assertNever(token); @@ -16425,15 +17163,15 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269); + var jsxAttributes = createNode(272); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28); - if (token() === 30) { - var node_1 = createNode(266, fullStart); + parseExpected(29); + if (token() === 31) { + var node_1 = createNode(269, fullStart); scanJsxText(); return finishNode(node_1); } @@ -16441,20 +17179,20 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30) { - node = createNode(263, fullStart); + if (token() === 31) { + node = createNode(266, fullStart); scanJsxText(); } else { - parseExpected(42); + parseExpected(43); if (inExpressionContext) { - parseExpected(30); + parseExpected(31); } else { - parseExpected(30, undefined, false); + parseExpected(31, undefined, false); scanJsxText(); } - node = createNode(262, fullStart); + node = createNode(265, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -16463,10 +17201,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 101 ? + var expression = token() === 103 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24)) { - var propertyAccess = createNode(190, expression.pos); + var propertyAccess = createNode(193, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -16474,7 +17212,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271); + var node = createNode(274); if (!parseExpected(18)) { return undefined; } @@ -16497,9 +17235,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268); + var node = createNode(271); node.name = parseIdentifierName(); - if (token() === 60) { + if (token() === 62) { switch (scanJsxAttributeValue()) { case 10: node.initializer = parseLiteralNode(); @@ -16512,7 +17250,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270); + var node = createNode(273); parseExpected(18); parseExpected(25); node.expression = parseExpression(); @@ -16520,77 +17258,109 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264); - parseExpected(29); + var node = createNode(267); + parseExpected(30); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30); + parseExpected(31); } else { - parseExpected(30, undefined, false); + parseExpected(31, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267); - parseExpected(29); + var node = createNode(270); + parseExpected(30); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30); + parseExpected(31); } else { - parseExpected(30, undefined, false); + parseExpected(31, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195); - parseExpected(28); + var node = createNode(198); + parseExpected(29); node.type = parseType(); - parseExpected(30); + parseExpected(31); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(true); + if (questionDotToken || expression.flags & 32) { + propertyAccess.flags |= 32; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23) { + indexedAccess.argumentExpression = createMissingNode(75, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23); + if (questionDotToken || expression.flags & 32) { + indexedAccess.flags |= 32; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24); - if (dotToken) { - var propertyAccess = createNode(190, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214, expression.pos); + var nonNullExpression = createNode(217, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(22)) { - var indexedAccess = createNode(191, expression.pos); - indexedAccess.expression = expression; - if (token() === 23) { - indexedAccess.argumentExpression = createMissingNode(73, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, undefined); continue; } return expression; @@ -16599,43 +17369,64 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 || token() === 15; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32) { + tagExpression.flags |= 32; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); - if (token() === 28 || token() === 46) { + expression = parseMemberExpressionRest(expression, true); + var questionDotToken = parseOptionalToken(28); + if (token() === 29 || token() === 47) { var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32) { + callExpr.flags |= 32; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20) { - var callExpr = createNode(192, expression.pos); + var callExpr = createNode(195, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32) { + callExpr.flags |= 32; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + var propertyAccess = createNode(193, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75, false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20); @@ -16644,12 +17435,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28) { + if (reScanLessThanToken() !== 29) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20, parseType); - if (!parseExpected(30)) { + if (!parseExpected(31)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -16664,18 +17455,19 @@ var ts; case 24: case 21: case 23: - case 57: + case 58: case 26: - case 56: - case 33: - case 35: + case 57: case 34: case 36: - case 54: + case 35: + case 37: case 55: - case 51: - case 49: + case 56: + case 60: + case 52: case 50: + case 51: case 19: case 1: return true; @@ -16692,11 +17484,11 @@ var ts; case 10: case 14: return parseLiteralNode(); + case 103: case 101: case 99: - case 97: - case 103: - case 88: + case 105: + case 90: return parseTokenNode(); case 20: return parseParenthesizedExpression(); @@ -16704,19 +17496,19 @@ var ts; return parseArrayLiteralExpression(); case 18: return parseObjectLiteralExpression(); - case 122: + case 125: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 77: + case 79: return parseClassExpression(); - case 91: + case 93: return parseFunctionExpression(); - case 96: + case 98: return parseNewExpressionOrNewDotTarget(); - case 42: - case 65: + case 43: + case 67: if (reScanSlashToken() === 13) { return parseLiteralNode(); } @@ -16727,28 +17519,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196); + var node = createNodeWithJSDoc(199); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209); + var node = createNode(212); parseExpected(25); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 ? parseSpreadElement() : - token() === 27 ? createNode(211) : + token() === 27 ? createNode(214) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188); + var node = createNode(191); parseExpected(22); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16760,44 +17552,44 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0); if (parseOptionalToken(25)) { - node.kind = 278; + node.kind = 281; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127)) { - return parseAccessorDeclaration(node, 159); + if (parseContextualModifier(130)) { + return parseAccessorDeclaration(node, 162); } - if (parseContextualModifier(138)) { - return parseAccessorDeclaration(node, 160); + if (parseContextualModifier(141)) { + return parseAccessorDeclaration(node, 163); } - var asteriskToken = parseOptionalToken(40); + var asteriskToken = parseOptionalToken(41); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56); - node.exclamationToken = parseOptionalToken(52); - if (asteriskToken || token() === 20 || token() === 28) { + node.questionToken = parseOptionalToken(57); + node.exclamationToken = parseOptionalToken(53); + if (asteriskToken || token() === 20 || token() === 29) { return parseMethodDeclaration(node, asteriskToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58); if (isShorthandPropertyAssignment) { - node.kind = 277; - var equalsToken = parseOptionalToken(60); + node.kind = 280; + var equalsToken = parseOptionalToken(62); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276; - parseExpected(57); + node.kind = 279; + parseExpected(58); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189); + var node = createNode(192); parseExpected(18); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16811,10 +17603,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNodeWithJSDoc(197); + var node = createNodeWithJSDoc(200); node.modifiers = parseModifiers(); - parseExpected(91); - node.asteriskToken = parseOptionalToken(40); + parseExpected(93); + node.asteriskToken = parseOptionalToken(41); var isGenerator = node.asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; node.name = @@ -16822,7 +17614,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57, isGenerator | isAsync, node); + fillSignature(58, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(true); @@ -16834,26 +17626,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96); + parseExpected(98); if (parseOptional(24)) { - var node_2 = createNode(215, fullStart); - node_2.keywordToken = 96; + var node_2 = createNode(218, fullStart); + node_2.keywordToken = 98; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193, fullStart); + var node = createNode(196, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20) { @@ -16862,7 +17654,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219); + var node = createNode(222); if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16893,25 +17685,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221); + var node = createNode(223); parseExpected(26); return finishNode(node); } function parseIfStatement() { - var node = createNode(223); - parseExpected(92); + var node = createNode(226); + parseExpected(94); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224); - parseExpected(83); + var node = createNode(227); + parseExpected(85); node.statement = parseStatement(); - parseExpected(108); + parseExpected(110); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -16919,8 +17711,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225); - parseExpected(108); + var node = createNode(228); + parseExpected(110); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -16929,12 +17721,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90); - var awaitToken = parseOptionalToken(123); + parseExpected(92); + var awaitToken = parseOptionalToken(126); parseExpected(20); var initializer; if (token() !== 26) { - if (token() === 106 || token() === 112 || token() === 78) { + if (token() === 108 || token() === 114 || token() === 80) { initializer = parseVariableDeclarationList(true); } else { @@ -16942,23 +17734,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148) : parseOptional(148)) { - var forOfStatement = createNode(228, pos); + if (awaitToken ? parseExpected(151) : parseOptional(151)) { + var forOfStatement = createNode(231, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94)) { - var forInStatement = createNode(227, pos); + else if (parseOptional(96)) { + var forInStatement = createNode(230, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226, pos); + var forStatement = createNode(229, pos); forStatement.initializer = initializer; parseExpected(26); if (token() !== 26 && token() !== 21) { @@ -16976,7 +17768,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 ? 74 : 79); + parseExpected(kind === 233 ? 76 : 81); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16984,8 +17776,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231); - parseExpected(98); + var node = createNode(234); + parseExpected(100); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -16993,39 +17785,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232); - parseExpected(109); + var node = createNode(235); + parseExpected(111); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); - node.statement = doInsideOfContext(8388608, parseStatement); + node.statement = doInsideOfContext(16777216, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272); - parseExpected(75); + var node = createNode(275); + parseExpected(77); node.expression = allowInAnd(parseExpression); - parseExpected(57); + parseExpected(58); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273); - parseExpected(81); - parseExpected(57); + var node = createNode(276); + parseExpected(83); + parseExpected(58); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 ? parseCaseClause() : parseDefaultClause(); + return token() === 77 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233); - parseExpected(100); + var node = createNode(236); + parseExpected(102); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); - var caseBlock = createNode(247); + var caseBlock = createNode(250); parseExpected(18); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(19); @@ -17033,26 +17825,26 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(235); - parseExpected(102); + var node = createNode(238); + parseExpected(104); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(236); - parseExpected(104); + var node = createNode(239); + parseExpected(106); node.tryBlock = parseBlock(false); - node.catchClause = token() === 76 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 89) { - parseExpected(89); + node.catchClause = token() === 78 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 91) { + parseExpected(91); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275); - parseExpected(76); + var result = createNode(278); + parseExpected(78); if (parseOptional(20)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21); @@ -17064,21 +17856,21 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237); - parseExpected(80); + var node = createNode(240); + parseExpected(82); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var node = createNodeWithJSDoc(0); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 && parseOptional(57)) { - node.kind = 234; + if (expression.kind === 75 && parseOptional(58)) { + node.kind = 237; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222; + node.kind = 225; node.expression = expression; parseSemicolon(); } @@ -17090,11 +17882,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 && !scanner.hasPrecedingLineBreak(); + return token() === 79 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 && !scanner.hasPrecedingLineBreak(); + return token() === 93 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -17103,47 +17895,47 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106: - case 112: - case 78: - case 91: - case 77: - case 85: + case 108: + case 114: + case 80: + case 93: + case 79: + case 87: return true; - case 111: - case 141: + case 113: + case 144: return nextTokenIsIdentifierOnSameLine(); - case 131: - case 132: + case 134: + case 135: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119: - case 122: - case 126: - case 114: - case 115: + case 121: + case 125: + case 129: case 116: - case 134: + case 117: + case 118: + case 137: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146: + case 149: nextToken(); - return token() === 18 || token() === 73 || token() === 86; - case 93: + return token() === 18 || token() === 75 || token() === 88; + case 95: nextToken(); - return token() === 10 || token() === 40 || + return token() === 10 || token() === 41 || token() === 18 || ts.tokenIsIdentifierOrKeyword(token()); - case 86: + case 88: nextToken(); - if (token() === 60 || token() === 40 || - token() === 18 || token() === 81 || - token() === 120) { + if (token() === 62 || token() === 41 || + token() === 18 || token() === 83 || + token() === 122) { return true; } continue; - case 117: + case 119: nextToken(); continue; default: @@ -17156,47 +17948,47 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58: + case 59: case 26: case 18: - case 106: - case 112: - case 91: - case 77: - case 85: - case 92: - case 83: case 108: - case 90: + case 114: + case 93: case 79: - case 74: - case 98: - case 109: + case 87: + case 94: + case 85: + case 110: + case 92: + case 81: + case 76: case 100: + case 111: case 102: case 104: - case 80: - case 76: - case 89: + case 106: + case 82: + case 78: + case 91: return true; - case 93: + case 95: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78: - case 86: + case 80: + case 88: return isStartOfDeclaration(); - case 122: - case 126: - case 111: - case 131: - case 132: - case 141: - case 146: + case 125: + case 129: + case 113: + case 134: + case 135: + case 144: + case 149: return true; + case 118: case 116: - case 114: - case 115: case 117: - case 134: + case 119: + case 137: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -17215,62 +18007,62 @@ var ts; return parseEmptyStatement(); case 18: return parseBlock(false); - case 106: - return parseVariableStatement(createNodeWithJSDoc(238)); - case 112: + case 108: + return parseVariableStatement(createNodeWithJSDoc(241)); + case 114: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238)); + return parseVariableStatement(createNodeWithJSDoc(241)); } break; - case 91: - return parseFunctionDeclaration(createNodeWithJSDoc(240)); - case 77: - return parseClassDeclaration(createNodeWithJSDoc(241)); - case 92: + case 93: + return parseFunctionDeclaration(createNodeWithJSDoc(243)); + case 79: + return parseClassDeclaration(createNodeWithJSDoc(244)); + case 94: return parseIfStatement(); - case 83: + case 85: return parseDoStatement(); - case 108: + case 110: return parseWhileStatement(); - case 90: + case 92: return parseForOrForInOrForOfStatement(); - case 79: - return parseBreakOrContinueStatement(229); - case 74: - return parseBreakOrContinueStatement(230); - case 98: + case 81: + return parseBreakOrContinueStatement(232); + case 76: + return parseBreakOrContinueStatement(233); + case 100: return parseReturnStatement(); - case 109: + case 111: return parseWithStatement(); - case 100: - return parseSwitchStatement(); case 102: - return parseThrowStatement(); + return parseSwitchStatement(); case 104: - case 76: - case 89: + return parseThrowStatement(); + case 106: + case 78: + case 91: return parseTryStatement(); - case 80: + case 82: return parseDebuggerStatement(); - case 58: + case 59: return parseDeclaration(); - case 122: - case 111: - case 141: - case 131: - case 132: - case 126: - case 78: - case 85: - case 86: - case 93: - case 114: - case 115: + case 125: + case 113: + case 144: + case 134: + case 135: + case 129: + case 80: + case 87: + case 88: + case 95: case 116: - case 119: case 117: - case 134: - case 146: + case 118: + case 121: + case 119: + case 137: + case 149: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -17279,59 +18071,75 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126; + return modifier.kind === 129; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304; + m.flags |= 8388608; } - return doInsideOfContext(4194304, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106: - case 112: - case 78: + case 108: + case 114: + case 80: return parseVariableStatement(node); - case 91: + case 93: return parseFunctionDeclaration(node); - case 77: + case 79: return parseClassDeclaration(node); - case 111: + case 113: return parseInterfaceDeclaration(node); - case 141: + case 144: return parseTypeAliasDeclaration(node); - case 85: + case 87: return parseEnumDeclaration(node); - case 146: - case 131: - case 132: + case 149: + case 134: + case 135: return parseModuleDeclaration(node); - case 93: + case 95: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86: + case 88: nextToken(); switch (token()) { - case 81: - case 60: + case 83: + case 62: return parseExportAssignment(node); - case 120: + case 122: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); } default: if (node.decorators || node.modifiers) { - var missing = createMissingNode(259, true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262, true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -17353,24 +18161,24 @@ var ts; } function parseArrayBindingElement() { if (token() === 27) { - return createNode(211); + return createNode(214); } - var node = createNode(187); + var node = createNode(190); node.dotDotDotToken = parseOptionalToken(25); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187); + var node = createNode(190); node.dotDotDotToken = parseOptionalToken(25); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57) { + if (tokenIsIdentifier && token() !== 58) { node.name = propertyName; } else { - parseExpected(57); + parseExpected(58); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -17378,14 +18186,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185); + var node = createNode(188); parseExpected(18); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(19); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186); + var node = createNode(189); parseExpected(22); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(23); @@ -17407,10 +18215,10 @@ var ts; return parseVariableDeclaration(true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238); + var node = createNode(241); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 && - token() === 52 && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 && + token() === 53 && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -17420,21 +18228,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239); + var node = createNode(242); switch (token()) { - case 106: + case 108: break; - case 112: + case 114: node.flags |= 1; break; - case 78: + case 80: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 148 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -17449,25 +18257,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21; } function parseVariableStatement(node) { - node.kind = 220; + node.kind = 224; node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240; - parseExpected(91); - node.asteriskToken = parseOptionalToken(40); + node.kind = 243; + parseExpected(93); + node.asteriskToken = parseOptionalToken(41); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; - fillSignature(57, isGenerator | isAsync, node); + fillSignature(58, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125) { - return parseExpected(125); + if (token() === 128) { + return parseExpected(128); } if (token() === 10 && lookAhead(nextToken) === 20) { return tryParse(function () { @@ -17479,39 +18287,39 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158; - fillSignature(57, 0, node); + node.kind = 161; + fillSignature(58, 0, node); node.body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157; + node.kind = 160; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; - fillSignature(57, isGenerator | isAsync, node); + fillSignature(58, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155; - if (!node.questionToken && token() === 52 && !scanner.hasPrecedingLineBreak()) { + node.kind = 158; + if (!node.questionToken && token() === 53 && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); node.initializer = ts.hasModifier(node, 32) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 | 2048, parseInitializer); + : doOutsideOfContext(8192 | 4096, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40); + var asteriskToken = parseOptionalToken(41); node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56); - if (asteriskToken || token() === 20 || token() === 28) { + node.questionToken = parseOptionalToken(57); + if (asteriskToken || token() === 20 || token() === 29) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -17519,13 +18327,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57, 0, node); + fillSignature(58, 0, node); node.body = parseFunctionBlockOrSemicolon(0); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58) { + if (token() === 59) { return true; } while (ts.isModifierKind(token())) { @@ -17535,7 +18343,7 @@ var ts; } nextToken(); } - if (token() === 40) { + if (token() === 41) { return true; } if (isLiteralPropertyName()) { @@ -17546,16 +18354,16 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 138 || idToken === 127) { + if (!ts.isKeyword(idToken) || idToken === 141 || idToken === 130) { return true; } switch (token()) { case 20: - case 28: - case 52: + case 29: + case 53: + case 58: + case 62: case 57: - case 60: - case 56: return true; default: return canParseSemicolon(); @@ -17568,10 +18376,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58)) { + if (!parseOptional(59)) { break; } - var decorator = createNode(153, decoratorStart); + var decorator = createNode(156, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -17584,7 +18392,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 && permitInvalidConstAsModifier) { + if (token() === 80 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -17601,7 +18409,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122) { + if (token() === 125) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -17612,20 +18420,20 @@ var ts; } function parseClassElement() { if (token() === 26) { - var result = createNode(218); + var result = createNode(221); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0); node.decorators = parseDecorators(); node.modifiers = parseModifiers(true); - if (parseContextualModifier(127)) { - return parseAccessorDeclaration(node, 159); + if (parseContextualModifier(130)) { + return parseAccessorDeclaration(node, 162); } - if (parseContextualModifier(138)) { - return parseAccessorDeclaration(node, 160); + if (parseContextualModifier(141)) { + return parseAccessorDeclaration(node, 163); } - if (token() === 125 || token() === 10) { + if (token() === 128 || token() === 10) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -17637,25 +18445,35 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 || token() === 8 || - token() === 40 || + token() === 41 || token() === 22) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608; + } + return doInsideOfContext(8388608, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { - node.name = createMissingNode(73, true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75, 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), 210); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 213); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241); + return parseClassDeclarationOrExpression(node, 244); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77); + parseExpected(79); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -17674,7 +18492,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { if (isHeritageClause()) { @@ -17684,33 +18502,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 || tok === 110); - var node = createNode(274); + ts.Debug.assert(tok === 89 || tok === 112); + var node = createNode(277); node.token = tok; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212); + var node = createNode(215); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 - ? parseBracketedList(20, parseType, 28, 30) - : undefined; + return token() === 29 ? + parseBracketedList(20, parseType, 29, 31) : undefined; } function isHeritageClause() { - return token() === 87 || token() === 110; + return token() === 89 || token() === 112; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242; - parseExpected(111); + node.kind = 245; + parseExpected(113); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -17718,24 +18535,24 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243; - parseExpected(141); + node.kind = 246; + parseExpected(144); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60); + parseExpected(62); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNodeWithJSDoc(279); + var node = createNodeWithJSDoc(282); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244; - parseExpected(85); + node.kind = 247; + parseExpected(87); node.name = parseIdentifier(); if (parseExpected(18)) { node.members = parseDelimitedList(6, parseEnumMember); @@ -17747,7 +18564,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246); + var node = createNode(249); if (parseExpected(18)) { node.statements = parseList(1, parseStatement); parseExpected(19); @@ -17758,7 +18575,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245; + node.kind = 248; var namespaceFlag = flags & 16; node.flags |= flags; node.name = parseIdentifier(); @@ -17768,10 +18585,10 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245; - if (token() === 146) { + node.kind = 248; + if (token() === 149) { node.name = parseIdentifier(); - node.flags |= 512; + node.flags |= 1024; } else { node.name = parseLiteralNode(); @@ -17787,14 +18604,14 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146) { + if (token() === 149) { return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132)) { + else if (parseOptional(135)) { flags |= 16; } else { - parseExpected(131); + parseExpected(134); if (token() === 10) { return parseAmbientExternalModuleDeclaration(node); } @@ -17802,60 +18619,60 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 && + return token() === 138 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20; } function nextTokenIsSlash() { - return nextToken() === 42; + return nextToken() === 43; } function parseNamespaceExportDeclaration(node) { - node.kind = 248; - parseExpected(120); - parseExpected(132); + node.kind = 251; + parseExpected(122); + parseExpected(135); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93); + parseExpected(95); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 && token() !== 145) { + if (token() !== 27 && token() !== 148) { return parseImportEqualsDeclaration(node, identifier); } } - node.kind = 250; + node.kind = 253; if (identifier || - token() === 40 || + token() === 41 || token() === 18) { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145); + parseExpected(148); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249; + node.kind = 252; node.name = identifier; - parseExpected(60); + parseExpected(62); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(251, fullStart); + var importClause = createNode(254, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(27)) { - importClause.namedBindings = token() === 40 ? parseNamespaceImport() : parseNamedImportsOrExports(253); + importClause.namedBindings = token() === 41 ? parseNamespaceImport() : parseNamedImportsOrExports(256); } return finishNode(importClause); } @@ -17865,8 +18682,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(260); - parseExpected(135); + var node = createNode(263); + parseExpected(138); parseExpected(20); node.expression = parseModuleSpecifier(); parseExpected(21); @@ -17883,22 +18700,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(252); - parseExpected(40); - parseExpected(120); + var namespaceImport = createNode(255); + parseExpected(41); + parseExpected(122); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(23, kind === 253 ? parseImportSpecifier : parseExportSpecifier, 18, 19); + node.elements = parseBracketedList(23, kind === 256 ? parseImportSpecifier : parseExportSpecifier, 18, 19); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258); + return parseImportOrExportSpecifier(261); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254); + return parseImportOrExportSpecifier(257); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17906,9 +18723,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120) { + if (token() === 122) { node.propertyName = identifierName; - parseExpected(120); + parseExpected(122); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -17917,21 +18734,21 @@ var ts; else { node.name = identifierName; } - if (kind === 254 && checkIdentifierIsKeyword) { + if (kind === 257 && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256; - if (parseOptional(40)) { - parseExpected(145); + node.kind = 259; + if (parseOptional(41)) { + parseExpected(148); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257); - if (token() === 145 || (token() === 10 && !scanner.hasPrecedingLineBreak())) { - parseExpected(145); + node.exportClause = parseNamedImportsOrExports(260); + if (token() === 148 || (token() === 10 && !scanner.hasPrecedingLineBreak())) { + parseExpected(148); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17939,12 +18756,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255; - if (parseOptional(60)) { + node.kind = 258; + if (parseOptional(62)) { node.isExportEquals = true; } else { - parseExpected(81); + parseExpected(83); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -17957,15 +18774,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1) - || node.kind === 249 && node.moduleReference.kind === 260 - || node.kind === 250 - || node.kind === 255 - || node.kind === 256 - ? node - : undefined; + || node.kind === 252 && node.moduleReference.kind === 263 + || node.kind === 253 + || node.kind === 258 + || node.kind === 259 ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 ? + return sourceFile.flags & 2097152 ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -17973,7 +18788,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 && node.name.escapedText === "meta"; } var JSDocParser; (function (JSDocParser) { @@ -17989,9 +18804,9 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289); + var result = createNode(292); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18); - result.type = doInsideOfContext(2097152, parseJSDocType); + result.type = doInsideOfContext(4194304, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19); } @@ -18002,7 +18817,7 @@ var ts; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99, undefined, 1); sourceFile = { languageVariant: 0, text: content }; - var jsDoc = parseJSDocCommentWorker(start, length); + var jsDoc = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -18013,11 +18828,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536) { + if (contextFlags & 131072) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -18064,7 +18879,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58: + case 59: if (state === 0 || state === 1) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -18080,7 +18895,7 @@ var ts; state = 0; indent = 0; break; - case 40: + case 41: var asterisk = scanner.getTokenText(); if (state === 1 || state === 2) { state = 2; @@ -18125,7 +18940,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297, start); + var result = createNode(301, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -18160,14 +18975,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40) || token() === 5 || token() === 4) { + while ((precedingLineBreak && token() === 41) || token() === 5 || token() === 4) { indentText += scanner.getTokenText(); if (token() === 4) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40) { + else if (token() === 41) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -18175,7 +18990,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58); + ts.Debug.assert(token() === 59); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(undefined); @@ -18256,7 +19071,7 @@ var ts; } indent = 0; break; - case 58: + case 59: if (state === 3) { comments.push(scanner.getTokenText()); break; @@ -18278,7 +19093,7 @@ var ts; break; case 18: state = 2; - if (lookAhead(function () { return nextTokenJSDoc() === 58 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -18286,7 +19101,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59: + case 61: if (state === 3) { state = 2; } @@ -18295,7 +19110,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40: + case 41: if (state === 0) { state = 1; indent += 1; @@ -18315,7 +19130,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300, start); + var result = createNode(304, start); result.tagName = tagName; return finishNode(result); } @@ -18341,14 +19156,14 @@ var ts; if (isBracketed) { skipWhitespace(); } - var isBackquoted = parseOptionalJsdoc(59); + var isBackquoted = parseOptionalJsdoc(61); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59); + parseExpectedTokenJSDoc(61); } if (isBracketed) { skipWhitespace(); - if (parseOptionalToken(60)) { + if (parseOptionalToken(62)) { parseExpression(); } parseExpected(23); @@ -18357,9 +19172,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137: + case 140: return true; - case 170: + case 173: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -18375,8 +19190,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 ? - createNode(312, start) : - createNode(306, start); + createNode(316, start) : + createNode(310, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -18393,20 +19208,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 || child.kind === 312) { + if (child.kind === 310 || child.kind === 316) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298, start_2); + jsdocTypeLiteral = createNode(302, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170) { + if (typeExpression.type.kind === 173) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -18418,7 +19233,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307, start); + var result = createNode(311, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -18427,13 +19242,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309, start); + var result = createNode(313, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302, start); + var result = createNode(306, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -18455,20 +19270,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73: + case 75: case 5: case 24: - case 58: + case 59: comments.push(scanner.getTokenText()); break; - case 28: + case 29: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30: + case 31: if (!seenLessThan || seenGreaterThan) { return; } @@ -18487,14 +19302,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301, start); + var result = createNode(305, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18); - var node = createNode(212); + var node = createNode(215); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -18506,7 +19321,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24)) { - var prop = createNode(190, node.pos); + var prop = createNode(193, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -18514,19 +19329,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303, start); + var tag = createNode(307, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308, start); + var tag = createNode(312, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305, start); + var tag = createNode(309, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); @@ -18535,7 +19350,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311, start); + var typedefTag = createNode(315, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -18549,9 +19364,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298, start); + jsdocTypeLiteral = createNode(302, start); } - if (child.kind === 309) { + if (child.kind === 313) { if (childTypeTag) { break; } @@ -18564,7 +19379,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170) { + if (typeExpression && typeExpression.type.kind === 173) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -18582,7 +19397,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24)) { - var jsDocNamespaceNode = createNode(245, pos); + var jsDocNamespaceNode = createNode(248, pos); if (nested) { jsDocNamespaceNode.flags |= 4; } @@ -18596,22 +19411,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304, start); + var callbackTag = createNode(308, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299, start); + var jsdocSignature = createNode(303, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(58)) { + if (parseOptionalJsdoc(59)) { var tag = parseTag(indent); - if (tag && tag.kind === 307) { + if (tag && tag.kind === 311) { return tag; } } @@ -18653,10 +19468,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58: + case 59: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 || child.kind === 312) && + if (child && (child.kind === 310 || child.kind === 316) && target !== 4 && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -18669,13 +19484,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40: + case 41: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73: + case 75: canParseTag = false; break; case 1: @@ -18684,7 +19499,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58); + ts.Debug.assert(token() === 59); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -18719,13 +19534,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151); + var typeParameter = createNode(154); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27)); - var result = createNode(310, start); + var result = createNode(314, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -18755,18 +19570,21 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73, !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75, !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + var result = createNode(75, pos); + if (token() !== 75) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -18840,7 +19658,7 @@ var ts; switch (node.kind) { case 10: case 8: - case 73: + case 75: return true; } return false; @@ -19255,10 +20073,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73) { + if (lhs.kind === 75) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101) { + if (lhs.kind === 103) { return true; } return lhs.name.escapedText === rhs.name.escapedText && @@ -19385,12 +20203,21 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -19399,7 +20226,7 @@ var ts; description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us }, ]; - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -19500,7 +20327,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -19537,6 +20365,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -19545,6 +20374,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -19552,6 +20382,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -19570,6 +20401,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -19597,6 +20429,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -19606,6 +20439,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -19622,6 +20456,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -19641,7 +20476,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, { name: "strict", @@ -19770,7 +20606,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { name: "rootDirs", @@ -19783,7 +20620,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -19807,7 +20645,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -19900,6 +20739,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -19949,14 +20789,16 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + transpileOptionValue: true }, { name: "stripInternal", @@ -19972,6 +20814,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -19992,6 +20840,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -20007,7 +20856,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -20065,6 +20915,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -20088,7 +20945,10 @@ var ts; ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) { return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -20147,7 +21007,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; function convertEnableAutoDiscoveryToEnable(typeAcquisition) { @@ -20592,7 +21453,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 !== 276) { + if (element.kind !== 279) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -20642,13 +21503,13 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103: + case 105: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88: + case 90: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97: + case 99: reportInvalidOptionValue(option && option.name === "extends"); return null; case 10: @@ -20667,13 +21528,13 @@ var ts; case 8: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203: - if (valueExpression.operator !== 39 || valueExpression.operand.kind !== 8) { + case 206: + if (valueExpression.operator !== 40 || valueExpression.operand.kind !== 8) { break; } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189: + case 192: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; if (option) { @@ -20683,7 +21544,7 @@ var ts; else { return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined); } - case 188: + case 191: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -20726,13 +21587,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), 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 config = __assign(__assign({ compilerOptions: __assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? 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 }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -21072,7 +21933,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -22004,6 +22865,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -22014,6 +22876,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -22149,7 +23014,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined); @@ -22185,7 +23050,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; } @@ -22625,30 +23490,60 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { switch (node.kind) { - case 242: - case 243: + case 245: + case 246: return 0; - case 244: + case 247: if (ts.isEnumConst(node)) { return 2; } break; - case 250: - case 249: + case 253: + case 252: if (!(ts.hasModifier(node, 1))) { return 0; } break; - case 246: { + case 259: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1) { + return state; + } + } + return state; + } + break; + case 249: { var state_1 = 0; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0: return; @@ -22664,20 +23559,52 @@ var ts; }); return state_1; } - case 245: - return getModuleInstanceState(node); - case 73: + case 248: + return getModuleInstanceState(node, visited); + case 75: if (node.isInJSDocNamespace) { return 0; } } return 1; } + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1; + } var flowNodeCreated = ts.identity; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -22766,7 +23693,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 | 384 | 1536 | 3) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -22776,7 +23703,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 | 32 | 256))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415) { + if (symbolFlags & 111551) { setValueDeclaration(symbol, node); } } @@ -22789,7 +23716,7 @@ var ts; } } function getDeclarationName(node) { - if (node.kind === 255) { + if (node.kind === 258) { return node.isExportEquals ? "export=" : "default"; } var name = ts.getNameOfDeclaration(node); @@ -22798,7 +23725,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150) { + if (name.kind === 153) { var nameExpression = name.expression; if (ts.isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); @@ -22809,34 +23736,37 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158: - return "__constructor"; - case 166: case 161: - case 299: + return "__constructor"; + case 169: + case 164: + case 303: return "__call"; - case 167: - case 162: + case 170: + case 165: return "__new"; - case 163: + case 166: return "__index"; - case 256: + case 259: return "__export"; - case 285: + case 288: return "export="; - case 205: + case 208: if (ts.getAssignmentDeclarationKind(node) === 2) { return "export="; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295: + case 298: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); - case 152: - ts.Debug.assert(node.parent.kind === 295, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + case 155: + ts.Debug.assert(node.parent.kind === 298, "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; @@ -22891,7 +23821,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (node.kind === 255 && !node.isExportEquals)) { + (node.kind === 258 && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -22909,7 +23839,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0, name); } } @@ -22926,7 +23856,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 2097152) { - if (node.kind === 258 || (node.kind === 249 && hasExportModifier)) { + if (node.kind === 261 || (node.kind === 252 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -22936,11 +23866,11 @@ var ts; else { if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512) && !getDeclarationName(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64)) || ts.isJSDocTypeAlias(node)) { + if (!container.locals || (ts.hasModifier(node, 512) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } - var exportKind = symbolFlags & 67220415 ? 1048576 : 0; + var exportKind = symbolFlags & 111551 ? 1048576 : 0; var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -22956,7 +23886,7 @@ var ts; var saveThisParentContainer = thisParentContainer; var savedBlockScopeContainer = blockScopeContainer; if (containerFlags & 1) { - if (node.kind !== 198) { + if (node.kind !== 201) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -22982,29 +23912,30 @@ var ts; if (!isIIFE) { currentFlow = { flags: 2 }; if (containerFlags & (16 | 128)) { - currentFlow.container = node; + currentFlow.node = node; } } - currentReturnTarget = isIIFE || node.kind === 158 ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; hasExplicitReturn = false; flowNodeCreated = ts.identity; bindChildren(node); - node.flags &= ~1408; + node.flags &= ~2816; if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) { - node.flags |= 128; + node.flags |= 256; if (hasExplicitReturn) - node.flags |= 256; + node.flags |= 512; + node.endFlowNode = currentFlow; } - if (node.kind === 285) { + if (node.kind === 288) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158) { + if (node.kind === 161) { node.returnFlowNode = currentFlow; } } @@ -23021,7 +23952,7 @@ var ts; else if (containerFlags & 64) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 : node.flags & ~64; + node.flags = seenThisKeyword ? node.flags | 128 : node.flags & ~128; } else { bindChildren(node); @@ -23048,8 +23979,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -23081,78 +24012,92 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 && node.kind <= 240 && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225: + case 228: bindWhileStatement(node); break; - case 224: + case 227: bindDoStatement(node); break; - case 226: + case 229: bindForStatement(node); break; - case 227: - case 228: + case 230: + case 231: bindForInOrForOfStatement(node); break; - case 223: + case 226: bindIfStatement(node); break; - case 231: - case 235: + case 234: + case 238: bindReturnOrThrow(node); break; - case 230: - case 229: + case 233: + case 232: bindBreakOrContinueStatement(node); break; - case 236: + case 239: bindTryStatement(node); break; - case 233: + case 236: bindSwitchStatement(node); break; - case 247: + case 250: bindCaseBlock(node); break; - case 272: + case 275: bindCaseClause(node); break; - case 234: + case 225: + bindExpressionStatement(node); + break; + case 237: bindLabeledStatement(node); break; - case 203: + case 206: bindPrefixUnaryExpressionFlow(node); break; - case 204: + case 207: bindPostfixUnaryExpressionFlow(node); break; - case 205: + case 208: bindBinaryExpressionFlow(node); break; - case 199: + case 202: bindDeleteExpressionFlow(node); break; - case 206: + case 209: bindConditionalExpressionFlow(node); break; - case 238: + case 241: bindVariableDeclarationFlow(node); break; - case 192: + case 193: + case 194: + bindAccessExpressionFlow(node); + break; + case 195: bindCallExpressionFlow(node); break; - case 311: - case 304: + case 315: + case 308: + case 309: bindJSDocTypeAlias(node); break; - case 285: { + case 307: + bindJSDocClassTag(node); + break; + case 288: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219: - case 246: + case 222: + case 249: bindEachFunctionsFirst(node.statements); break; default: @@ -23163,29 +24108,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73: - case 101: - case 190: - case 191: + case 75: + case 103: + case 193: + case 194: return isNarrowableReference(expr); - case 192: + case 195: return hasNarrowableArgument(expr); - case 196: + case 199: return isNarrowingExpression(expr.expression); - case 205: + case 208: return isNarrowingBinaryExpression(expr); + case 206: + return expr.operator === 53 && isNarrowingExpression(expr.operand); case 203: - return expr.operator === 52 && isNarrowingExpression(expr.operand); - case 200: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 || expr.kind === 101 || expr.kind === 99 || + return expr.kind === 75 || expr.kind === 103 || expr.kind === 101 || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && + ts.isElementAccessExpression(expr) && + ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { @@ -23197,7 +24142,7 @@ var ts; } } } - if (expr.expression.kind === 190 && + if (expr.expression.kind === 193 && isNarrowableReference(expr.expression.expression)) { return true; } @@ -23211,17 +24156,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60: + case 62: return isNarrowableReference(expr.left); - case 33: case 34: case 35: case 36: + case 37: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95: + case 97: return isNarrowableOperand(expr.left); - case 94: + case 96: return isNarrowableInOperands(expr.left, expr.right); case 27: return isNarrowingExpression(expr.right); @@ -23230,11 +24175,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196: + case 199: return isNarrowableOperand(expr.expression); - case 205: + case 208: switch (expr.operatorToken.kind) { - case 60: + case 62: return isNarrowableOperand(expr.left); case 27: return isNarrowableOperand(expr.right); @@ -23243,19 +24188,13 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4, - antecedents: undefined - }; + return { flags: 4, antecedents: undefined }; } function createLoopLabel() { - return { - flags: 8, - antecedents: undefined - }; + return { flags: 8, antecedents: undefined }; } function setFlowNodeReferenced(flow) { - flow.flags |= flow.flags & 512 ? 1024 : 512; + flow.flags |= flow.flags & 1024 ? 2048 : 1024; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) { @@ -23270,31 +24209,36 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 103 && flags & 64 || - expression.kind === 88 && flags & 32) { - return unreachableFlow; + if (expression.kind === 105 && flags & 64 || + expression.kind === 90 && flags & 32) { + if (!ts.isOptionalChainRoot(expression.parent)) { + return unreachableFlow; + } } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -23309,47 +24253,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223: - case 225: - case 224: - return parent.expression === node; case 226: - case 206: + case 228: + case 227: + return parent.expression === node; + case 229: + case 209: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196) { + if (node.kind === 199) { node = node.expression; } - else if (node.kind === 203 && node.operator === 52) { + else if (node.kind === 206 && node.operator === 53) { node = node.operand; } else { - return node.kind === 205 && (node.operatorToken.kind === 54 || - node.operatorToken.kind === 55); + return node.kind === 208 && (node.operatorToken.kind === 55 || + node.operatorToken.kind === 56 || + node.operatorToken.kind === 60); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 || - node.parent.kind === 203 && - node.parent.operator === 52) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node)); } @@ -23377,7 +24326,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 + var enclosingLabeledStatement = node.parent.kind === 237 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -23407,15 +24356,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228) { + if (node.kind === 231) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239) { + if (node.initializer.kind !== 242) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -23437,7 +24386,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231) { + if (node.kind === 234) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -23457,7 +24406,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -23517,7 +24466,7 @@ var ts; preFinallyPrior = finishFlowLabel(preFinallyFlow_1); } } - var preFinallyFlow = { flags: 2048, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = { flags: 4096, antecedent: preFinallyPrior, lock: {} }; addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -23529,7 +24478,7 @@ var ts; } } if (!(currentFlow.flags & 1)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -23547,7 +24496,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -23601,6 +24550,15 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + if (node.expression.kind === 195) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -23612,13 +24570,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224) { + if (!node.statement || node.statement.kind !== 227) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 && node.operatorToken.kind === 60) { + if (node.kind === 208 && node.operatorToken.kind === 62) { bindAssignmentTargetFlow(node.left); } else { @@ -23629,10 +24587,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188) { + else if (node.kind === 191) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209) { + if (e.kind === 212) { bindAssignmentTargetFlow(e.expression); } else { @@ -23640,16 +24598,16 @@ var ts; } } } - else if (node.kind === 189) { + else if (node.kind === 192) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276) { + if (p.kind === 279) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277) { + else if (p.kind === 280) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278) { + else if (p.kind === 281) { bindAssignmentTargetFlow(p.expression); } } @@ -23657,7 +24615,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54) { + if (node.operatorToken.kind === 55) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -23668,7 +24626,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52) { + if (node.operator === 53) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -23678,20 +24636,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 || node.operator === 45) { + if (node.operator === 45 || node.operator === 46) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 || node.operator === 45) { + if (node.operator === 45 || node.operator === 46) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 || operator === 55) { + if (operator === 55 || operator === 56 || operator === 60) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -23705,7 +24663,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 && node.left.kind === 191) { + if (operator === 62 && node.left.kind === 194) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -23716,7 +24674,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190) { + if (node.expression.kind === 193) { bindAssignmentTargetFlow(node.expression); } } @@ -23755,24 +24713,88 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 309 && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - var expr = node.expression; - while (expr.kind === 196) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160) { + addDeclarationToSymbol(host.symbol, host, 32); + } + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node)); } - if (expr.kind === 197 || expr.kind === 198) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193: + bind(node.name); + break; + case 194: + bind(node.argumentExpression); + break; + case 195: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node)); + } + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 || expr.kind === 201) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -23781,53 +24803,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210: - case 241: + case 213: case 244: - case 189: - case 169: - case 298: - case 269: + case 247: + case 192: + case 172: + case 302: + case 272: return 1; - case 242: - return 1 | 64; case 245: - case 243: - case 182: + return 1 | 64; + case 248: + case 246: + case 185: return 1 | 32; - case 285: + case 288: return 1 | 4 | 32; - case 157: + case 160: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 158: - case 240: - case 156: - case 159: - case 160: case 161: - case 299: - case 295: - case 166: + case 243: + case 159: case 162: case 163: - case 167: + case 164: + case 303: + case 298: + case 169: + case 165: + case 166: + case 170: return 1 | 4 | 32 | 8; - case 197: - case 198: + case 200: + case 201: return 1 | 4 | 32 | 8 | 16; - case 246: + case 249: return 4; - case 155: + case 158: return node.initializer ? 4 : 0; - case 275: - case 226: - case 227: - case 228: - case 247: + case 278: + case 229: + case 230: + case 231: + case 250: return 2; - case 219: + case 222: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -23840,40 +24862,40 @@ var ts; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 245: + case 248: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285: + case 288: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210: - case 241: - return declareClassMember(node, symbolFlags, symbolExcludes); + case 213: case 244: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 247: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169: - case 298: - case 189: - case 242: - case 269: + case 172: + case 302: + case 192: + case 245: + case 272: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + case 169: + case 170: + case 164: + case 165: + case 303: case 166: - case 167: + case 160: + case 159: case 161: case 162: - case 299: case 163: - case 157: - case 156: - case 158: - case 159: - case 160: - case 240: - case 197: - case 198: - case 295: - case 311: - case 304: case 243: - case 182: + case 200: + case 201: + case 298: + case 315: + case 308: + case 246: + case 185: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -23892,11 +24914,11 @@ var ts; return !!body && body.statements.some(function (s) { return ts.isExportDeclaration(s) || ts.isExportAssignment(s); }); } function setExportContextFlag(node) { - if (node.flags & 4194304 && !hasExportDeclarations(node)) { - node.flags |= 32; + if (node.flags & 8388608 && !hasExportDeclarations(node)) { + node.flags |= 64; } else { - node.flags &= ~32; + node.flags &= ~64; } } function bindModuleDeclaration(node) { @@ -23952,11 +24974,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 === 278 || prop.name.kind !== 73) { + if (prop.kind === 281 || prop.name.kind !== 75) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 276 || prop.kind === 277 || prop.kind === 157 + var currentKind = prop.kind === 279 || prop.kind === 280 || prop.kind === 160 ? 1 : 2; var existingKind = seen.get(identifier.escapedText); @@ -23988,10 +25010,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245: + case 248: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285: + case 288: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -24021,9 +25043,36 @@ var ts; currentFlow = { flags: 2 }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1: + case 2: + container = file; + break; + case 4: + container = declName.parent.expression; + break; + case 3: + container = declName.parent.expression.name; + break; + case 5: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288, 788968); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288, 67897832); + bindBlockScopedDeclaration(typeAlias, 524288, 788968); } else { bind(typeAlias.fullName); @@ -24037,9 +25086,10 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 && - node.originalKeywordKind <= 118 && + node.originalKeywordKind >= 112 && + node.originalKeywordKind <= 120 && !ts.isIdentifierName(node) && + !(node.flags & 8388608) && !(node.flags & 4194304)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -24066,7 +25116,7 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 73) { + if (inStrictMode && node.expression.kind === 75) { 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)); } @@ -24075,7 +25125,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73) { + if (name && name.kind === 75) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -24108,8 +25158,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 285 && - blockScopeContainer.kind !== 245 && + if (blockScopeContainer.kind !== 288 && + blockScopeContainer.kind !== 248 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -24128,7 +25178,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 44 || node.operator === 45) { + if (node.operator === 45 || node.operator === 46) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -24161,7 +25211,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -24171,7 +25221,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 148) { + if (node.kind > 151) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -24211,8 +25261,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -24229,36 +25279,37 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 73: + case 75: if (node.isInJSDocNamespace) { var parentNode = node.parent; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288, 67897832); + bindBlockScopedDeclaration(parentNode, 524288, 788968); break; } - case 101: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277)) { + case 103: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190: - case 191: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193: + case 194: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, undefined, node.expression, 1 | 134217728, 67220414); + declareSymbol(file.locals, undefined, expr.expression, 1 | 134217728, 111550); } break; - case 205: + case 208: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1: @@ -24285,72 +25336,72 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275: + case 278: return checkStrictModeCatchClause(node); - case 199: + case 202: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 204: + case 207: return checkStrictModePostfixUnaryExpression(node); - case 203: + case 206: return checkStrictModePrefixUnaryExpression(node); - case 232: + case 235: return checkStrictModeWithStatement(node); - case 234: + case 237: return checkStrictModeLabeledStatement(node); - case 179: + case 182: seenThisKeyword = true; return; - case 164: + case 167: break; - case 151: + case 154: return bindTypeParameter(node); - case 152: + case 155: return bindParameter(node); - case 238: + case 241: return bindVariableDeclarationOrBindingElement(node); - case 187: + case 190: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155: - case 154: + case 158: + case 157: return bindPropertyWorker(node); - case 276: - case 277: - return bindPropertyOrMethodOrAccessor(node, 4, 0); case 279: - return bindPropertyOrMethodOrAccessor(node, 8, 68008959); - case 161: - case 162: - case 163: + case 280: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 282: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 164: + case 165: + case 166: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 157: - case 156: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 67212223); - case 240: + case 160: + case 159: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 103359); + case 243: return bindFunctionDeclaration(node); - case 158: + case 161: return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 159: - return bindPropertyOrMethodOrAccessor(node, 32768, 67154879); - case 160: - return bindPropertyOrMethodOrAccessor(node, 65536, 67187647); - case 166: - case 295: - case 299: - case 167: - return bindFunctionOrConstructorType(node); + case 162: + return bindPropertyOrMethodOrAccessor(node, 32768, 46015); + case 163: + return bindPropertyOrMethodOrAccessor(node, 65536, 78783); case 169: case 298: - case 182: + case 303: + case 170: + return bindFunctionOrConstructorType(node); + case 172: + case 302: + case 185: return bindAnonymousTypeWorker(node); - case 189: + case 192: return bindObjectLiteralExpression(node); - case 197: - case 198: + case 200: + case 201: return bindFunctionExpression(node); - case 192: + case 195: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7: @@ -24368,59 +25419,60 @@ var ts; bindCallExpression(node); } break; - case 210: - case 241: + case 213: + case 244: inStrictMode = true; return bindClassLikeDeclaration(node); - case 242: - return bindBlockScopedDeclaration(node, 64, 67897736); - case 243: - return bindBlockScopedDeclaration(node, 524288, 67897832); - case 244: - return bindEnumDeclaration(node); case 245: + return bindBlockScopedDeclaration(node, 64, 788872); + case 246: + return bindBlockScopedDeclaration(node, 524288, 788968); + case 247: + return bindEnumDeclaration(node); + case 248: return bindModuleDeclaration(node); - case 269: + case 272: return bindJsxAttributes(node); - case 268: + case 271: return bindJsxAttribute(node, 4, 0); - case 249: case 252: - case 254: - case 258: + case 255: + case 257: + case 261: return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); - case 248: - return bindNamespaceExportDeclaration(node); case 251: + return bindNamespaceExportDeclaration(node); + case 254: return bindImportClause(node); - case 256: + case 259: return bindExportDeclaration(node); - case 255: + case 258: return bindExportAssignment(node); - case 285: + case 288: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219: + case 222: if (!ts.isFunctionLike(node.parent)) { return; } - case 246: + case 249: return updateStrictModeStatementList(node.statements); - case 306: - if (node.parent.kind === 299) { + case 310: + if (node.parent.kind === 303) { return bindParameter(node); } - if (node.parent.kind !== 298) { + if (node.parent.kind !== 302) { break; } - case 312: + case 316: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 ? 4 | 16777216 : 4; return declareSymbolAndAddToSymbolTable(propTag, flags, 0); - case 311: - case 304: + case 315: + case 308: + case 309: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -24517,8 +25569,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 | 67108864); } @@ -24528,7 +25579,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 | 1048576 | 32 : 4 | 1048576; - declareSymbol(symbol.exports, symbol, lhs, flags, 0); + declareSymbol(symbol.exports, symbol, node.left, flags, 0); } } function bindModuleExportsAssignment(node) { @@ -24548,46 +25599,67 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, false); switch (thisContainer.kind) { - case 240: - case 197: + case 243: + case 200: var constructorSymbol = thisContainer.symbol; - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 60) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } if (constructorSymbol) { constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4, 0 & ~4); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 | 67108864, 0 & ~4); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32); } break; + case 161: case 158: - case 155: - case 157: - case 159: case 160: + case 162: + case 163: var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members; - declareSymbol(symbolTable, containingClass.symbol, node, 4, 0, true); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 | 67108864, 0, true); + } break; - case 285: + case 288: if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 | 1048576, 0); } else { - declareSymbolAndAddToSymbolTable(node, 1, 67220414); + declareSymbolAndAddToSymbolTable(node, 1, 111550); } break; default: ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4, "__computed"); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101) { + if (node.expression.kind === 103) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -24599,8 +25671,7 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, false); + bindPropertyAssignment(node.left.expression, node.left, false, true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -24612,35 +25683,41 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, true); + bindPropertyAssignment(constructorFunction, lhs, true, true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false); + var isToplevel = node.parent.parent.kind === 288; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false, false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 | 67108864, "__computed"); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, false); + bindPropertyAssignment(node.expression, node, false, false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { var flags_1 = 1536 | 67108864; var excludeFlags_1 = 110735 & ~67108864; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { @@ -24655,6 +25732,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -24664,17 +25744,43 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 : 4; - var excludes = isMethod ? 67212223 : 0; + var includes = 0; + var excludes = 0; + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192; + excludes = 103359; + } + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + includes |= 65536 | 4; + excludes |= 78783; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 | 4; + excludes |= 46015; + } + } + if (includes === 0) { + includes = 4; + excludes = 0; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864, excludes & ~67108864); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 + : propertyAccess.parent.parent.kind === 288; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 - : propertyAccess.parent.parent.kind === 285; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } function isExpandoSymbol(symbol) { @@ -24693,7 +25799,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 === 55 ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 || init.operatorToken.kind === 60) ? init.right : init, isPrototypeAssignment); } return false; } @@ -24710,7 +25816,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -24722,7 +25828,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -24731,8 +25837,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241) { - bindBlockScopedDeclaration(node, 32, 68008383); + if (node.kind === 244) { + bindBlockScopedDeclaration(node, 32, 899503); } else { var bindingName = node.name ? node.name.escapedText : "__class"; @@ -24755,65 +25861,62 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128, 68008831) - : bindBlockScopedDeclaration(node, 256, 68008191); + ? bindBlockScopedDeclaration(node, 128, 899967) + : bindBlockScopedDeclaration(node, 256, 899327); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 : 0); - var enumExcludes = (isEnum ? 68008191 : 0); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 | enumFlags, 67220415 | enumExcludes); + bindBlockScopedDeclaration(node, 2, 111551); } else if (ts.isParameterDeclaration(node)) { - declareSymbolAndAddToSymbolTable(node, 1, 67220415); + declareSymbolAndAddToSymbolTable(node, 1, 111551); } else { - declareSymbolAndAddToSymbolTable(node, 1 | enumFlags, 67220414 | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1, 111550); } } } function bindParameter(node) { - if (node.kind === 306 && container.kind !== 299) { + if (node.kind === 310 && container.kind !== 303) { return; } - if (inStrictMode && !(node.flags & 4194304)) { + if (inStrictMode && !(node.flags & 8388608)) { checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { bindAnonymousDeclaration(node, 1, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1, 67220415); + declareSymbolAndAddToSymbolTable(node, 1, 111551); } - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 16777216 : 0), 0); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304)) { + if (!file.isDeclarationFile && !(node.flags & 8388608)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024; + emitFlags |= 2048; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16, 67219887); + bindBlockScopedDeclaration(node, 16, 110991); } else { - declareSymbolAndAddToSymbolTable(node, 16, 67219887); + declareSymbolAndAddToSymbolTable(node, 16, 110991); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304)) { + if (!file.isDeclarationFile && !(node.flags & 8388608)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024; + emitFlags |= 2048; } } if (currentFlow) { @@ -24824,8 +25927,8 @@ var ts; return bindAnonymousDeclaration(node, 16, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304) && ts.isAsyncFunction(node)) { - emitFlags |= 1024; + if (!file.isDeclarationFile && !(node.flags & 8388608) && ts.isAsyncFunction(node)) { + emitFlags |= 2048; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -24845,26 +25948,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, undefined, node, 262144, 67635688); + declareSymbol(container_1.locals, undefined, node, 262144, 526824); } else { - declareSymbolAndAddToSymbolTable(node, 262144, 67635688); + declareSymbolAndAddToSymbolTable(node, 262144, 526824); } } - else if (node.parent.kind === 177) { + else if (node.parent.kind === 180) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, undefined, node, 262144, 67635688); + declareSymbol(container_2.locals, undefined, node, 262144, 526824); } else { bindAnonymousDeclaration(node, 262144, getDeclarationName(node)); } } else { - declareSymbolAndAddToSymbolTable(node, 262144, 67635688); + declareSymbolAndAddToSymbolTable(node, 262144, 526824); } } function shouldReportErrorOnModuleDeclaration(node) { @@ -24876,14 +25979,14 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 221) || - node.kind === 241 || - (node.kind === 245 && shouldReportErrorOnModuleDeclaration(node)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 223) || + node.kind === 244 || + (node.kind === 248 && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304) && + !(node.flags & 8388608) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -24910,12 +26013,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242: - case 243: - return true; case 245: + case 246: + return true; + case 248: return getModuleInstanceState(s) !== 1; - case 244: + case 247: return ts.hasModifier(s, 2048); default: return false; @@ -24927,7 +26030,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -24958,58 +26061,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192: + case 195: return computeCallExpression(node, subtreeFlags); - case 193: + case 196: return computeNewExpression(node, subtreeFlags); - case 245: + case 248: return computeModuleDeclaration(node, subtreeFlags); - case 196: + case 199: return computeParenthesizedExpression(node, subtreeFlags); - case 205: + case 208: return computeBinaryExpression(node, subtreeFlags); - case 222: + case 225: return computeExpressionStatement(node, subtreeFlags); - case 152: + case 155: return computeParameter(node, subtreeFlags); - case 198: + case 201: return computeArrowFunction(node, subtreeFlags); - case 197: + case 200: return computeFunctionExpression(node, subtreeFlags); - case 240: + case 243: return computeFunctionDeclaration(node, subtreeFlags); - case 238: + case 241: return computeVariableDeclaration(node, subtreeFlags); - case 239: + case 242: return computeVariableDeclarationList(node, subtreeFlags); - case 220: + case 224: return computeVariableStatement(node, subtreeFlags); - case 234: + case 237: return computeLabeledStatement(node, subtreeFlags); - case 241: + case 244: return computeClassDeclaration(node, subtreeFlags); - case 210: + case 213: return computeClassExpression(node, subtreeFlags); - case 274: + case 277: return computeHeritageClause(node, subtreeFlags); - case 275: + case 278: return computeCatchClause(node, subtreeFlags); - case 212: + case 215: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158: + case 161: return computeConstructor(node, subtreeFlags); - case 155: + case 158: return computePropertyDeclaration(node, subtreeFlags); - case 157: - return computeMethod(node, subtreeFlags); - case 159: case 160: + return computeMethod(node, subtreeFlags); + case 162: + case 163: return computeAccessor(node, subtreeFlags); - case 249: + case 252: return computeImportEquals(node, subtreeFlags); - case 190: + case 193: return computePropertyAccess(node, subtreeFlags); - case 191: + case 194: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -25020,6 +26123,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32) { + transformFlags |= 4; + } if (node.typeArguments) { transformFlags |= 1; } @@ -25029,7 +26135,7 @@ var ts; transformFlags |= 2048; } } - if (expression.kind === 93) { + if (expression.kind === 95) { transformFlags |= 524288; } node.transformFlags = transformFlags | 536870912; @@ -25050,14 +26156,17 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 && leftKind === 189) { + if (operatorTokenKind === 60) { + transformFlags |= 4; + } + else if (operatorTokenKind === 62 && leftKind === 192) { transformFlags |= 16 | 128 | 512; } - else if (operatorTokenKind === 60 && leftKind === 188) { + else if (operatorTokenKind === 62 && leftKind === 191) { transformFlags |= 128 | 512; } - else if (operatorTokenKind === 41 - || operatorTokenKind === 64) { + else if (operatorTokenKind === 42 + || operatorTokenKind === 66) { transformFlags |= 64; } node.transformFlags = transformFlags | 536870912; @@ -25090,8 +26199,8 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 213 - || expressionKind === 195) { + if (expressionKind === 216 + || expressionKind === 198) { transformFlags |= 1; } node.transformFlags = transformFlags | 536870912; @@ -25124,10 +26233,10 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87: + case 89: transformFlags |= 128; break; - case 110: + case 112: transformFlags |= 1; break; default: @@ -25278,7 +26387,10 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.kind === 99) { + if (node.flags & 32) { + transformFlags |= 4; + } + if (node.expression.kind === 101) { transformFlags |= 32 | 16; } node.transformFlags = transformFlags | 536870912; @@ -25286,7 +26398,10 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.kind === 99) { + if (node.flags & 32) { + transformFlags |= 4; + } + if (node.expression.kind === 101) { transformFlags |= 32 | 16; } node.transformFlags = transformFlags | 536870912; @@ -25365,51 +26480,51 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912; switch (kind) { - case 122: - case 202: + case 125: + case 205: transformFlags |= 16 | 32; break; - case 195: - case 213: - case 315: + case 198: + case 216: + case 319: transformFlags |= 1; excludeFlags = 536870912; break; + case 118: case 116: - case 114: - case 115: - case 119: - case 126: - case 78: - case 244: - case 279: - case 214: - case 134: + case 117: + case 121: + case 129: + case 80: + case 247: + case 282: + case 217: + case 137: transformFlags |= 1; break; - case 261: - case 262: - case 263: - case 11: case 264: case 265: case 266: + case 11: case 267: case 268: case 269: case 270: case 271: + case 272: + case 273: + case 274: transformFlags |= 2; break; case 14: case 15: case 16: case 17: - case 207: - case 194: - case 277: - case 117: - case 215: + case 210: + case 197: + case 280: + case 119: + case 218: transformFlags |= 128; break; case 10: @@ -25425,30 +26540,27 @@ var ts; case 9: transformFlags |= 4; break; - case 228: + case 231: if (node.awaitModifier) { transformFlags |= 16; } transformFlags |= 128; break; - case 208: + case 211: transformFlags |= 16 | 128 | 131072; break; - case 121: - case 136: - case 147: - case 133: - case 137: - case 139: case 124: + case 139: + case 150: + case 136: case 140: - case 107: - case 151: + case 142: + case 127: + case 143: + case 109: case 154: - case 156: - case 161: - case 162: - case 163: + case 157: + case 159: case 164: case 165: case 166: @@ -25464,54 +26576,57 @@ var ts; case 176: case 177: case 178: - case 242: - case 243: case 179: case 180: case 181: + case 245: + case 246: case 182: case 183: - case 248: + case 184: + case 185: + case 186: + case 251: transformFlags = 1; excludeFlags = -2; break; - case 150: + case 153: transformFlags |= 16384; break; - case 209: + case 212: transformFlags |= 128 | 4096; break; - case 278: + case 281: transformFlags |= 16 | 8192; break; - case 99: + case 101: transformFlags |= 128; excludeFlags = 536870912; break; - case 101: + case 103: transformFlags |= 2048; break; - case 185: + case 188: transformFlags |= 128 | 65536; if (subtreeFlags & 4096) { transformFlags |= 16 | 8192; } excludeFlags = 536875008; break; - case 186: + case 189: transformFlags |= 128 | 65536; excludeFlags = 536875008; break; - case 187: + case 190: transformFlags |= 128; if (node.dotDotDotToken) { transformFlags |= 4096; } break; - case 153: + case 156: transformFlags |= 1 | 1024; break; - case 189: + case 192: excludeFlags = 536896512; if (subtreeFlags & 16384) { transformFlags |= 128; @@ -25520,24 +26635,24 @@ var ts; transformFlags |= 16; } break; - case 188: + case 191: excludeFlags = 536875008; break; - case 224: - case 225: - case 226: case 227: + case 228: + case 229: + case 230: if (subtreeFlags & 32768) { transformFlags |= 128; } break; - case 285: + case 288: break; - case 231: + case 234: transformFlags |= 262144 | 16; break; - case 229: - case 230: + case 232: + case 233: transformFlags |= 262144; break; } @@ -25548,67 +26663,67 @@ var ts; return transformFlags | (node.transformFlags & 2048); } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 && kind <= 184) { + if (kind >= 167 && kind <= 187) { return -2; } switch (kind) { - case 192: - case 193: - case 188: + case 195: + case 196: + case 191: return 536875008; - case 245: + case 248: return 537168896; - case 152: + case 155: return 536870912; - case 198: + case 201: return 537371648; - case 197: - case 240: + case 200: + case 243: return 537373696; - case 239: + case 242: return 536944640; - case 241: - case 210: + case 244: + case 213: return 536888320; - case 158: + case 161: return 537372672; - case 157: - case 159: case 160: + case 162: + case 163: return 537372672; - case 121: - case 136: - case 147: - case 133: - case 139: - case 137: case 124: + case 139: + case 150: + case 136: + case 142: case 140: - case 107: - case 151: + case 127: + case 143: + case 109: case 154: - case 156: - case 161: - case 162: - case 163: - case 242: - case 243: + case 157: + case 159: + case 164: + case 165: + case 166: + case 245: + case 246: return -2; - case 189: + case 192: return 536896512; - case 275: + case 278: return 536879104; - case 185: - case 186: + case 188: + case 189: return 536875008; - case 195: - case 213: - case 315: - case 196: - case 99: + case 198: + case 216: + case 319: + case 199: + case 101: return 536870912; - case 190: - case 191: + case 193: + case 194: return 536870912; default: return 536870912; @@ -25622,7 +26737,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -25692,7 +26807,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -25770,7 +26885,7 @@ var ts; symbol.exports.forEach(visitSymbol); } ts.forEach(symbol.declarations, function (d) { - if (d.type && d.type.kind === 168) { + if (d.type && d.type.kind === 171) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -25789,6 +26904,27 @@ var ts; var nextNodeId = 1; var nextMergeId = 1; var nextFlowId = 1; + var typeofEQFacts = ts.createMapFromTemplate({ + string: 1, + number: 2, + bigint: 4, + boolean: 8, + symbol: 16, + undefined: 65536, + object: 32, + function: 64 + }); + var typeofNEFacts = ts.createMapFromTemplate({ + string: 256, + number: 512, + bigint: 1024, + boolean: 2048, + symbol: 4096, + undefined: 524288, + object: 8192, + function: 16384 + }); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -25862,6 +26998,7 @@ var ts; var argumentsSymbol = createSymbol(4, "arguments"); var requireSymbol = createSymbol(4, "require"); var apparentArgumentCount; + var pooledOptionalTypeResult = { isOptional: false, type: undefined }; var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -25905,8 +27042,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -26023,7 +27163,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -26037,6 +27177,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -26055,6 +27198,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -26083,7 +27227,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -26091,7 +27235,7 @@ var ts; cancellationToken = ct; checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0) || !unusedIsError(1))) { addUnusedDiagnostics(); } @@ -26103,7 +27247,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -26143,6 +27287,7 @@ var ts; var unknownType = createIntrinsicType(2, "unknown"); var undefinedType = createIntrinsicType(32768, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768, "undefined", 262144); + var optionalType = createIntrinsicType(32768, "undefined"); var nullType = createIntrinsicType(65536, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536, "null", 262144); var stringType = createIntrinsicType(4, "string"); @@ -26170,6 +27315,7 @@ var ts; var silentNeverType = createIntrinsicType(131072, "never"); var nonInferrableType = createIntrinsicType(131072, "never", 1048576); var implicitNeverType = createIntrinsicType(131072, "never"); + var unreachableNeverType = createIntrinsicType(131072, "never"); var nonPrimitiveType = createIntrinsicType(67108864, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -26191,7 +27337,7 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); + var noTypePredicate = createTypePredicate(1, "<>", 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); @@ -26279,6 +27425,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -26291,38 +27440,18 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - var suggestionDiagnostics = ts.createMultiMap(); - var typeofEQFacts = ts.createMapFromTemplate({ - string: 1, - number: 2, - bigint: 4, - boolean: 8, - symbol: 16, - undefined: 65536, - object: 32, - function: 64 - }); - var typeofNEFacts = ts.createMapFromTemplate({ - string: 256, - number: 512, - bigint: 1024, - boolean: 2048, - symbol: 4096, - undefined: 524288, - object: 8192, - function: 16384 - }); + var suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -26342,7 +27471,6 @@ var ts; var enumRelation = ts.createMap(); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -26405,7 +27533,7 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { @@ -26431,35 +27559,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2) - result |= 67220415; + result |= 111551; if (flags & 1) - result |= 67220414; + result |= 111550; if (flags & 4) result |= 0; if (flags & 8) - result |= 68008959; + result |= 900095; if (flags & 16) - result |= 67219887; + result |= 110991; if (flags & 32) - result |= 68008383; + result |= 899503; if (flags & 64) - result |= 67897736; + result |= 788872; if (flags & 256) - result |= 68008191; + result |= 899327; if (flags & 128) - result |= 68008831; + result |= 899967; if (flags & 512) result |= 110735; if (flags & 8192) - result |= 67212223; + result |= 103359; if (flags & 32768) - result |= 67154879; + result |= 46015; if (flags & 65536) - result |= 67187647; + result |= 78783; if (flags & 262144) - result |= 67635688; + result |= 526824; if (flags & 524288) - result |= 67897832; + result |= 788968; if (flags & 2097152) result |= 2097152; return result; @@ -26490,7 +27618,9 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864) { - ts.Debug.assert(source !== target); + if (source === target) { + return target; + } if (!(target.flags & 33554432)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -26607,7 +27737,7 @@ var ts; mergeSymbolTable(globals, moduleAugmentation.symbol.exports); } else { - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, true); @@ -26657,7 +27787,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -26679,8 +27809,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -26693,7 +27823,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304) { + declaration.flags & 8388608) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { @@ -26703,15 +27833,15 @@ var ts; return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 187) { - var errorBindingElement = ts.getAncestor(usage, 187); + if (declaration.kind === 190) { + var errorBindingElement = ts.getAncestor(usage, 190); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 238), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241), usage); } - else if (declaration.kind === 238) { + else if (declaration.kind === 241) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } else if (ts.isClassDeclaration(declaration)) { @@ -26722,20 +27852,20 @@ var ts; } return true; } - if (usage.parent.kind === 258 || (usage.parent.kind === 255 && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 || (usage.parent.kind === 258 && usage.parent.isExportEquals)) { return true; } - if (usage.kind === 255 && usage.isExportEquals) { + if (usage.kind === 258 && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220: - case 226: - case 228: + case 224: + case 229: + case 231: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } @@ -26753,16 +27883,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 && + current.parent.kind === 158 && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32)) { - if (declaration.kind === 157) { + if (declaration.kind === 160) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 && !ts.hasModifier(declaration, 32); + var isDeclarationInstanceProperty = declaration.kind === 158 && !ts.hasModifier(declaration, 32); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -26780,14 +27910,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198: - case 155: + case 201: + case 158: return true; - case 219: + case 222: switch (node.parent.kind) { - case 159: - case 157: + case 162: case 160: + case 163: return true; default: return false; @@ -26819,11 +27949,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 !== 297) { + if (meaning & result.flags & 788968 && lastLocation.kind !== 301) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 152 || - lastLocation.kind === 151 + lastLocation.kind === 155 || + lastLocation.kind === 154 : false; } if (meaning & result.flags & 3) { @@ -26834,13 +27964,13 @@ var ts; } else if (result.flags & 1) { useResult = - lastLocation.kind === 152 || + lastLocation.kind === 155 || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176) { + else if (location.kind === 179) { useResult = lastLocation === location.trueType; } if (useResult) { @@ -26853,13 +27983,13 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285: + case 288: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 245: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 || ts.isAmbientModule(location)) { + case 248: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 || (ts.isModuleDeclaration(location) && location.flags & 8388608 && !ts.isGlobalScopeAugmentation(location))) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { @@ -26870,7 +28000,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 && - ts.getDeclarationOfKind(moduleExport, 258)) { + ts.getDeclarationOfKind(moduleExport, 261)) { break; } } @@ -26883,25 +28013,25 @@ var ts; } } break; - case 244: + case 247: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 155: + case 158: if (!ts.hasModifier(location, 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415)) { + if (lookup(ctor.locals, name, meaning & 111551)) { propertyWithInvalidInitializer = location; } } } break; - case 241: - case 210: - case 242: - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832)) { + case 244: + case 213: + case 245: + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; break; @@ -26912,7 +28042,7 @@ var ts; } break loop; } - if (location.kind === 210 && meaning & 32) { + if (location.kind === 213 && meaning & 32) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -26920,10 +28050,10 @@ var ts; } } break; - case 212: - if (lastLocation === location.expression && location.parent.token === 87) { + case 215: + if (lastLocation === location.expression && location.parent.token === 89) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -26931,30 +28061,30 @@ var ts; } } break; - case 150: + case 153: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242) { - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832)) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 198: + case 201: if (compilerOptions.target >= 2) { break; } - case 157: - case 158: - case 159: case 160: - case 240: + case 161: + case 162: + case 163: + case 243: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197: + case 200: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -26967,27 +28097,28 @@ var ts; } } break; - case 153: - if (location.parent && location.parent.kind === 152) { + case 156: + if (location.parent && location.parent.kind === 155) { location = location.parent; } - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244)) { location = location.parent; } break; - case 311: - case 304: + case 315: + case 308: + case 309: location = ts.getJSDocHost(location); break; - case 152: + case 155: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187: + case 190: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152) { + if (root.kind === 155) { associatedDeclarationForContainingInitializer = location; } } @@ -27004,7 +28135,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285); + ts.Debug.assert(lastLocation.kind === 288); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -27056,19 +28187,19 @@ var ts; } if (errorLocation && (meaning & 2 || - ((meaning & 32 || meaning & 384) && (meaning & 67220415) === 67220415))) { + ((meaning & 32 || meaning & 384) && (meaning & 111551) === 111551))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } - if (result && isInExternalModule && (meaning & 67220415) === 67220415 && !(originalLocation.flags & 2097152)) { + if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 4194304)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415) === 67220415) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551) === 111551) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializer)) { @@ -27082,9 +28213,9 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 && location.kind !== 197) { + if (location.kind !== 201 && location.kind !== 200) { return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 && !ts.hasModifier(location, 32))) && (!lastLocation || lastLocation !== location.name)); + (location.kind === 158 && !ts.hasModifier(location, 32))) && (!lastLocation || lastLocation !== location.name)); } if (lastLocation && lastLocation === location.name) { return false; @@ -27096,12 +28227,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240: - case 241: - case 242: - case 244: case 243: + case 244: case 245: + case 247: + case 246: + case 248: return true; default: return false; @@ -27113,7 +28244,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 === 151) { + if (decl.kind === 154) { 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)); @@ -27161,10 +28292,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73: - case 190: + case 75: + case 193: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212: + case 215: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -27173,9 +28304,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 | (ts.isInJSFile(errorLocation) ? 67220415 : 0); + var namespaceMeaning = 1920 | (ts.isInJSFile(errorLocation) ? 111551 : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 & ~namespaceMeaning, undefined, undefined, false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~namespaceMeaning, undefined, undefined, false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -27194,8 +28325,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 & ~1920)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 & 67220415, undefined, undefined, false)); + if (meaning & (788968 & ~1920)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 & 111551, undefined, undefined, false)); if (symbol && !(symbol.flags & 1920)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -27204,12 +28335,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 & ~1024)) { + if (meaning & (111551 & ~1024)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 & ~67220415, undefined, undefined, false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~111551, undefined, undefined, false)); if (symbol && !(symbol.flags & 1024)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later @@ -27233,15 +28364,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 & ~1024 & ~67897832)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~67220415, undefined, undefined, false)); + if (meaning & (111551 & ~1024 & ~788968)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~111551, undefined, undefined, false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 & ~1024 & ~67220415)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 | 1024) & ~67897832, undefined, undefined, false)); + else if (meaning & (788968 & ~1024 & ~111551)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 | 1024) & ~788968, undefined, undefined, false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -27251,10 +28382,13 @@ 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 === 244) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + if (result.flags & (16 | 1 | 67108864) && result.flags & 32) { + return; + } + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2) { @@ -27282,13 +28416,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249: + case 252: return node; - case 251: + case 254: return node.parent; - case 252: + case 255: return node.parent.parent; - case 254: + case 257: return node.parent.parent.parent; default: return undefined; @@ -27298,7 +28432,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260) { + if (node.moduleReference.kind === 263) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -27352,7 +28486,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -27363,13 +28502,13 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, false); } function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 | 1920)) { + if (valueSymbol.flags & (788968 | 1920)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -27399,9 +28538,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -27433,7 +28573,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default")) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -27453,40 +28598,62 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; } - var aliasLike = resolveEntityName(expression, 67220415 | 67897832 | 1920, true, dontResolveAlias); + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; + } + var aliasLike = resolveEntityName(expression, 111551 | 788968 | 1920, true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249: + case 252: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251: + case 254: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252: + case 255: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254: + case 257: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); + case 261: + return getTargetOfExportSpecifier(node, 111551 | 788968 | 1920, dontRecursivelyResolve); case 258: - return getTargetOfExportSpecifier(node, 67220415 | 67897832 | 1920, dontRecursivelyResolve); - case 255: - case 205: + case 208: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248: + case 251: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280: + return resolveEntityName(node.name, 111551 | 788968 | 1920, true, dontRecursivelyResolve); + case 279: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } } function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 | 67897832 | 1920; } + if (excludes === void 0) { excludes = 111551 | 788968 | 1920; } if (!symbol) return false; return (symbol.flags & (2097152 | excludes)) === 2097152 || !!(symbol.flags & 2097152 && symbol.flags & 67108864); @@ -27520,7 +28687,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -27533,27 +28700,24 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255) { - checkExpressionCached(node.expression); - } - else if (node.kind === 258) { - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - checkExpressionCached(node.moduleReference); + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551) { + checkExpressionCached(node.moduleReference); + } } } } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { - if (entityName.kind === 73 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 73 || entityName.parent.kind === 149) { + if (entityName.kind === 75 || entityName.parent.kind === 152) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 249); - return resolveEntityName(entityName, 67220415 | 67897832 | 1920, false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 252); + return resolveEntityName(entityName, 111551 | 788968 | 1920, false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -27563,9 +28727,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 67220415 : 0); + var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 111551 : 0); var symbol; - if (name.kind === 73) { + if (name.kind === 75) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, true); @@ -27573,9 +28737,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 || name.kind === 190) { - var left = name.kind === 149 ? name.left : name.expression; - var right = name.kind === 149 ? name.right : name.name; + else if (name.kind === 152 || name.kind === 193) { + var left = name.kind === 152 ? name.left : name.expression; + var right = name.kind === 152 ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -27621,7 +28785,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -27658,6 +28822,14 @@ var ts; undefined; return initializer || decl; } + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -27669,9 +28841,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -27762,7 +28931,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -27771,9 +28940,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512; if (merged.exports === undefined) { - merged.flags = merged.flags | 512; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -27781,12 +28954,13 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 285)) { + if (!suppressInteropError && !(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 288)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -27859,7 +29033,7 @@ var ts; return type.flags & 131068 ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") : + return symbol.flags & 6256 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") : symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -27981,7 +29155,7 @@ var ts; } function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + if (container && !(symbol.flags & 262144)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920, false)) { @@ -27990,7 +29164,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -27998,40 +29183,44 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export="); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { if (container === getParentOfSymbol(symbol)) { return symbol; } + var exportEquals = container.exports && container.exports.get("export="); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 67220415); + return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 && ts.nodeIsPresent(member.body)) { return member; } } @@ -28105,28 +29294,47 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285: + case 288: if (!ts.isExternalOrCommonJsModule(location)) { break; } + case 248: + var sym = getSymbolOfNode(location); + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244: + case 213: case 245: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + var table_1; + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 & ~67108864)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } function getQualifiedLeftMeaning(rightMeaning) { - return rightMeaning === 67220415 ? 67220415 : 1920; + return rightMeaning === 111551 ? 111551 : 1920; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -28152,9 +29360,9 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { if (isAccessible(symbols.get(symbol.escapedName), undefined, ignoreQualification)) { @@ -28166,7 +29374,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, 258))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -28195,7 +29403,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 258)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -28209,10 +29417,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155: - case 157: - case 159: + case 158: case 160: + case 162: + case 163: continue; default: return false; @@ -28223,11 +29431,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832, false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968, false); return access.accessibility === 0; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415, false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551, false); return access.accessibility === 0; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -28253,7 +29461,7 @@ var ts; } var containers = getContainersOfSymbol(symbol, enclosingDeclaration); var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -28300,14 +29508,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -28343,17 +29551,17 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 168 || + if (entityName.parent.kind === 171 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150) { - meaning = 67220415 | 1048576; + entityName.parent.kind === 153) { + meaning = 111551 | 1048576; } - else if (entityName.kind === 149 || entityName.kind === 190 || - entityName.parent.kind === 249) { + else if (entityName.kind === 152 || entityName.kind === 193 || + entityName.parent.kind === 252) { meaning = 1920; } else { - meaning = 67897832; + meaning = 788968; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false); @@ -28394,15 +29602,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144) { - sigOutput = kind === 1 ? 167 : 166; + sigOutput = kind === 1 ? 170 : 169; } else { - sigOutput = kind === 1 ? 162 : 161; + sigOutput = kind === 1 ? 165 : 164; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); + printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); return writer; } } @@ -28425,14 +29633,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, undefined, 64); rightStr = typeToString(right, undefined, 64); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0; } return flags & 9469291; @@ -28463,6 +29674,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); @@ -28472,7 +29686,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -28500,37 +29715,37 @@ var ts; } if (type.flags & 1) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121); + return ts.createKeywordTypeNode(124); } if (type.flags & 2) { - return ts.createKeywordTypeNode(144); + return ts.createKeywordTypeNode(147); } if (type.flags & 4) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139); + return ts.createKeywordTypeNode(142); } if (type.flags & 8) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136); + return ts.createKeywordTypeNode(139); } if (type.flags & 64) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147); + return ts.createKeywordTypeNode(150); } if (type.flags & 16) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124); + return ts.createKeywordTypeNode(127); } if (type.flags & 1024 && !(type.flags & 1048576)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832); + var parentName = symbolToTypeNode(parentSymbol, context, 788968); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), undefined)); return enumLiteralName; } if (type.flags & 1056) { - return symbolToTypeNode(type.symbol, context, 67897832); + return symbolToTypeNode(type.symbol, context, 788968); } if (type.flags & 128) { context.approximateLength += (type.value.length + 2); @@ -28539,7 +29754,7 @@ var ts; if (type.flags & 256) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -28553,38 +29768,38 @@ var ts; if (!(context.flags & 1048576)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415); + return symbolToTypeNode(type.symbol, context, 111551); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143, ts.createKeywordTypeNode(140)); + return ts.createTypeOperatorNode(146, ts.createKeywordTypeNode(143)); } if (type.flags & 16384) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107); + return ts.createKeywordTypeNode(109); } if (type.flags & 32768) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142); + return ts.createKeywordTypeNode(145); } if (type.flags & 65536) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97); + return ts.createKeywordTypeNode(99); } if (type.flags & 131072) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133); + return ts.createKeywordTypeNode(136); } if (type.flags & 4096) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140); + return ts.createKeywordTypeNode(143); } if (type.flags & 67108864) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137); + return ts.createKeywordTypeNode(140); } if (isThisTypeParameter(type)) { if (context.flags & 4194304) { @@ -28598,10 +29813,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4) { ts.Debug.assert(!!(type.flags & 524288)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 || objectFlags & 3) { if (type.flags & 262144 && ts.contains(context.inferTypeParameters, type)) { @@ -28609,21 +29830,16 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, undefined)); } if (context.flags & 4 && + type.flags & 262144 && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; return ts.createTypeReferenceNode(ts.createIdentifier(ts.idText(name)), undefined); } return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832) + ? symbolToTypeNode(type.symbol, context, 788968) : ts.createTypeReferenceNode(ts.createIdentifier("?"), undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832, typeArgumentNodes); - } if (type.flags & (1048576 | 2097152)) { var types = type.flags & 1048576 ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -28631,7 +29847,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 ? 174 : 175, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 ? 177 : 178, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -28692,45 +29908,27 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 : 67220415; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 : 111551; return symbolToTypeNode(symbol, context, isInstanceType); } - else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 210 && context.flags & 2048) || + else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 && context.flags & 2048) || symbol.flags & (384 | 512) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415); + return symbolToTypeNode(symbol, context, 111551); } else if (context.visitedTypes && context.visitedTypes.has(typeId)) { var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { - return symbolToTypeNode(typeAlias, context, 67897832); + return symbolToTypeNode(typeAlias, context, 788968); } else { return createElidedInformationPlaceholder(context); } } else { - if (!context.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -28742,7 +29940,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 || declaration.parent.kind === 246; + return declaration.parent.kind === 288 || declaration.parent.kind === 249; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return (!!(context.flags & 4096) || (context.visitedTypes && context.visitedTypes.has(typeId))) && @@ -28750,6 +29948,34 @@ var ts; } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32; + var id = ts.getObjectFlags(type) & 4 && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -28762,12 +29988,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170, context); return signatureNode; } } @@ -28780,7 +30006,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024) ? 0 : 1); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -28788,7 +30014,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137, arrayType); } else if (type.target.objectFlags & 8) { if (typeArguments.length > 0) { @@ -28802,12 +30028,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; @@ -28815,6 +30041,7 @@ var ts; else if (context.flags & 2048 && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && + ts.findAncestor(type.symbol.valueDeclaration, function (d) { return d === ts.getSourceFileOfNode(context.enclosingDeclaration); }) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return createAnonymousTypeNode(type); } @@ -28834,7 +30061,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16; - var ref = symbolToTypeNode(parent, context, 67897832, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -28847,7 +30074,7 @@ var ts; } var flags = context.flags; context.flags |= 16; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -28895,11 +30122,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -28946,7 +30173,7 @@ var ts; if (!(context.flags & 1)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), undefined); } - return ts.createKeywordTypeNode(121); + return ts.createKeywordTypeNode(124); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192); @@ -28957,24 +30184,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } - var propertyName = symbolToName(propertySymbol, context, 67220415, true); + var propertyName = symbolToName(propertySymbol, context, 111551, true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 ? ts.createToken(56) : undefined; + var optionalToken = propertySymbol.flags & 16777216 ? ts.createToken(57) : undefined; if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768); }), 0); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -28985,18 +30217,28 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, undefined); - if (propertySymbol.valueDeclaration) { - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } } - typeElements.push(propertySignature); + else if (propertySymbol.valueDeclaration) { + ts.setCommentRange(node, propertySymbol.valueDeclaration); + } + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -29037,14 +30279,14 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 139 : 136); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 142 : 139); 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(134)] : undefined, [indexingParameter], typeNode); + return ts.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.createToken(137)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -29055,7 +30297,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 === 158); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -29063,23 +30305,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 ? + var assertsModifier = typePredicate.kind === 2 || typePredicate.kind === 3 ? + ts.createToken(123) : + undefined; + var parameterName = typePredicate.kind === 1 || typePredicate.kind === 3 ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256) { - if (returnTypeNode && returnTypeNode.kind === 121) { + if (returnTypeNode && returnTypeNode.kind === 124) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121); + returnTypeNode = ts.createKeywordTypeNode(124); } context.approximateLength += 3; return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -29099,9 +30344,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -29111,15 +30356,14 @@ var ts; var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768; var dotDotDotToken = isRest ? ts.createToken(25) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) : - parameterDeclaration.name.kind === 149 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) : + parameterDeclaration.name.kind === 152 ? 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) & 16384; - var questionToken = isOptional ? ts.createToken(56) : undefined; + var questionToken = isOptional ? ts.createToken(57) : undefined; var parameterNode = ts.createParameter(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined); context.approximateLength += ts.symbolName(parameterSymbol).length + 3; return parameterNode; @@ -29127,28 +30371,31 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187) { + if (clone.kind === 190) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 | 16777216); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; - var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 | 1048576, undefined, undefined, true); + var firstIdentifier = getFirstIdentifier(accessExpression); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 | 1048576, undefined, undefined, true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { var chain; var isTypeParameter = symbol.flags & 262144; if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64) && !(context.flags & 134217728)) { @@ -29178,6 +30425,11 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false); if (parentChain) { + if (parent.exports && parent.exports.get("export=") && + getSymbolIfSameReference(parent.exports.get("export="), symbol)) { + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -29248,7 +30500,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285); + var file = ts.getDeclarationOfKind(symbol, 288); if (file && file.moduleName !== undefined) { return file.moduleName; } @@ -29278,7 +30530,7 @@ var ts; if (!specifier) { var isBundle_1 = (compilerOptions.out || compilerOptions.outFile); var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -29287,7 +30539,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384)); - var isTypeOf = meaning === 67220415; + var isTypeOf = meaning === 111551; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); @@ -29331,16 +30583,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216; } - var parent = chain[index - 1]; - if (!(context.flags & 16) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=") { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { return ts.createIndexedAccessTypeNode(LHS, ts.createLiteralTypeNode(ts.createLiteral(symbolName))); @@ -29362,7 +30630,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832, undefined, escapedName, false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968, undefined, escapedName, false); } function typeParameterToName(type, context) { if (context.flags & 4 && context.typeParameterNames) { @@ -29371,7 +30639,10 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832, true); + var result = symbolToName(type.symbol, context, 788968, true); + if (!(result.kind & 75)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4) { var rawtext = result.escapedText; var i = 0; @@ -29417,9 +30688,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216; } @@ -29428,6 +30696,9 @@ var ts; context.flags ^= 16777216; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216); @@ -29455,12 +30726,843 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160, true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159, false); + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.mapMap(symbolTable, function (_symbol, name) { return [ts.unescapeLeadingUnderscores(name), true]; }), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, false); + if (accessibleResult.accessibility === 0) { + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export="); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152) { + symbolTable = ts.createSymbolTable(); + symbolTable.set("export=", exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(undefined, id); })), undefined)])); + } + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0); + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), undefined)]); + } + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1) & ~2; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + var skipMembershipCheck = !isPrivate; + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default"; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + context.encounteredError = true; + return; + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 + || (symbol.flags & 16 && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152); + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 : 0) | (isDefault && !needsPostExportDefault ? 512 : 0); + if (symbol.flags & 16) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + if (symbol.flags & (2 | 1 | 4) + && symbol.escapedName !== "export=" + && !(symbol.flags & 4194304) + && !(symbol.flags & 32)) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32) { + if (symbol.flags & 4) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if (symbol.flags & (512 | 1024)) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 && symbol.escapedName === "export=") { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(undefined, undefined, undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(undefined, undefined, false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0); + } + } + function includePrivateSymbol(symbol) { + ts.Debug.assertDefined(deferredPrivates); + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0; + if (additionalModifierFlags & 1 && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + newModifierFlags |= 1; + } + if (addingDeclare && !(newModifierFlags & 1) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + newModifierFlags |= 2; + } + if ((additionalModifierFlags & 512) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0, interfaceType, baseType, 164); + var constructSignatures = serializeSignatures(1, interfaceType, baseType, 165); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304) || (p.escapedName === "prototype")); }); + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, false); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + ts.forEach(mergedMembers, includePrivateSymbol); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export="; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + return ts.createExportSpecifier(name === localName ? undefined : localName, name); + })))]); + addResult(ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), nsBody, 16), 0); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration(undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8); }), function (p) { + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + var flags = !(symbol.flags & 2) ? undefined + : isConstVariable(symbol) ? 2 + : 1; + var name = (needsPostExportDefault || !(symbol.flags & 4)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 : modifierFlags); + if (name !== localName && !isPrivate) { + addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + var decl = signatureToSignatureDeclarationHelper(sig, 243, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + if (!(symbol.flags & (512 | 1024) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + var fakespace = ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16); + fakespace.flags ^= 8; + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8; + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, false, baseTypes[0]); }); + var staticMembers = symbol.flags & (16 | 512) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, true, staticBaseType); }); + var constructors = serializeSignatures(1, staticType, baseTypes[0], 161); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration(undefined, undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + verbatimTargetName = "default"; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); + switch (node.kind) { + case 252: + var isLocalImport = !(target.flags & 512); + addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863, false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0); + break; + case 251: + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0); + break; + case 254: + addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(ts.createIdentifier(localName), undefined), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0); + break; + case 255: + addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0); + break; + case 257: + addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0); + break; + case 261: + var specifier = node.parent.parent.moduleSpecifier; + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258: + serializeMaybeAliasAssignment(symbol); + break; + case 208: + if (symbol.escapedName === "default" || symbol.escapedName === "export=") { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + case 193: + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export="; + var isDefault = name === "default"; + var isExportAssignment = isExportEquals || isDefault; + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true); + if (target) { + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863, true, true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, symbolToExpression(target, context, 67108863))); + } + else { + if (first_1 === expr) { + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863, false)), 0); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + var varName = getUnusedName(name, symbol); + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 : 1); + } + else { + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2)); + addResult(statement, name === varName ? 1 : 0); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 | 32) && + !getIndexInfoOfType(typeToSerialize, 0) && + !getIndexInfoOfType(typeToSerialize, 1) && + !ts.length(getSignaturesOfType(typeToSerialize, 1)) && + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 | 1920 | 2097152))) { + return []; + } + if (p.flags & 4194304 || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 && useAccessors) { + var result = []; + if (p.flags & 65536) { + result.push(ts.setTextRange(ts.createSetAccessor(undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter(undefined, undefined, undefined, "arg", undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768) { + result.push(ts.setTextRange(ts.createGetAccessor(undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + else if (p.flags & (4 | 3)) { + return ts.setTextRange(createProperty(undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | staticFlag), name, p.flags & 16777216 ? ts.createToken(57) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 | 16)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216) { + decl.questionToken = ts.createToken(57); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 && + type.symbol === symbol) { + context.flags |= 1048576; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature(undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "x", undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter(undefined, undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter(undefined, undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863, true, true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; + } + if (baseType) { + var baseSigs = getSignaturesOfType(baseType, 1); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], false, false, true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0, 1]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2)); + addResult(statement, 0); + return ts.createExpressionWithTypeArguments(undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551, false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551, false)) { + reference = symbolToExpression(t.symbol, context, 788968); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (input === "default") { + input = "_default"; + } + else if (input === "export=") { + input = "_exports"; + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + if (localName === "default" || localName === "__class" || localName === "__function") { + var flags = context.flags; + context.flags |= 16777216; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = ts.isIdentifierText(nameCandidate, languageVersion) && !ts.isStringANonContextualKeyword(nameCandidate) ? nameCandidate : getUnusedName("_default", symbol); + } + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 || typePredicate.kind === 3 ? ts.createToken(123) : undefined, typePredicate.kind === 1 || typePredicate.kind === 3 ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512)); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4, predicate, sourceFile, writer); @@ -29505,8 +31607,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 !== 178; }); - if (node.kind === 243) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181; }); + if (node.kind === 246) { return getSymbolOfNode(node); } } @@ -29514,11 +31616,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 && + node.parent.kind === 249 && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 || ts.isAmbientModule(location); + return location.kind === 288 || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -29546,9 +31648,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -29560,17 +31662,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238) { + if (!declaration) { + declaration = symbol.declarations[0]; + } + if (declaration.parent && declaration.parent.kind === 241) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210: - case 197: - case 198: + case 213: + case 200: + case 201: if (context && !context.encounteredError && !(context.flags & 131072)) { context.encounteredError = true; } - return declaration.kind === 210 ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -29587,66 +31692,67 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304: - case 311: + case 308: + case 315: + case 309: return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187: + case 190: return isDeclarationVisible(node.parent.parent); - case 238: + case 241: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } + case 248: + case 244: case 245: - case 241: - case 242: + case 246: case 243: - case 240: - case 244: - case 249: + case 247: + case 252: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 249 && parent.kind !== 285 && parent.flags & 4194304)) { + !(node.kind !== 252 && parent.kind !== 288 && parent.flags & 8388608)) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); - case 155: - case 154: - case 159: - case 160: + case 158: case 157: - case 156: + case 162: + case 163: + case 160: + case 159: if (ts.hasModifier(node, 8 | 16)) { return false; } - case 158: - case 162: case 161: - case 163: - case 152: - case 246: + case 165: + case 164: case 166: - case 167: + case 155: + case 249: case 169: - case 165: case 170: - case 171: + case 172: + case 168: + case 173: case 174: - case 175: + case 177: case 178: + case 181: return isDeclarationVisible(node.parent); - case 251: - case 252: case 254: + case 255: + case 257: return false; - case 151: - case 285: - case 248: + case 154: + case 288: + case 251: return true; - case 255: + case 258: return false; default: return false; @@ -29655,14 +31761,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255) { - exportSymbol = resolveName(node, node.escapedText, 67220415 | 67897832 | 1920 | 2097152, undefined, node, false); + if (node.parent && node.parent.kind === 258) { + exportSymbol = resolveName(node, node.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, node, false); } - else if (node.parent.kind === 258) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 | 67897832 | 1920 | 2097152); + else if (node.parent.kind === 261) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 | 788968 | 1920 | 2097152); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -29679,8 +31788,10 @@ var ts; if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 | 67897832 | 1920, undefined, undefined, false); - if (importSymbol) { + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 | 788968 | 1920, undefined, undefined, false); + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -29739,12 +31850,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238: - case 239: + case 241: + case 242: + case 257: + case 256: + case 255: case 254: - case 253: - case 252: - case 251: return false; default: return true; @@ -29770,7 +31881,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 150 && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304); }); @@ -29813,7 +31924,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191, node.pos, node.end); + var result = ts.createNode(194, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10, node.pos, node.end); @@ -29828,23 +31939,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187: - case 276: + case 190: + case 279: return getSyntheticElementAccess(ancestor); - case 188: + case 191: return getSyntheticElementAccess(node.parent); - case 238: + case 241: return ancestor.initializer; - case 205: + case 208: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 && parent.kind === 185) { + if (node.kind === 190 && parent.kind === 188) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 || node.kind === 277) { + if (node.kind === 279 || node.kind === 280) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -29859,11 +31970,11 @@ var ts; if (!parentType || isTypeAny(parentType)) { return parentType; } - if (strictNullChecks && declaration.flags & 4194304 && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 8388608 && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185) { + if (pattern.kind === 188) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -29922,27 +32033,27 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 || expr.kind === 73 && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 || expr.kind === 75 && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 && expr.elements.length === 0; + return expr.kind === 191 && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 && - (node.parent.kind === 197 || node.parent.kind === 198) && + return node.kind === 155 && + (node.parent.kind === 200 || node.parent.kind === 201) && !!getContextualType(node.parent); } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230) { 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 === 228) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231) { var forOfStatement = declaration.parent.parent; return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } @@ -29956,8 +32067,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 4194304)) { + declaration.kind === 241 && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 8388608)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } @@ -29965,10 +32076,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152) { + if (declaration.kind === 155) { var func = declaration.parent; - if (func.kind === 160 && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159); + if (func.kind === 163 && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -30025,12 +32136,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -30048,6 +32161,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; if (definedInMethod) { var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol); @@ -30072,9 +32188,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -30164,9 +32280,9 @@ var ts; } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, false); - return thisContainer.kind === 158 || - thisContainer.kind === 240 || - (thisContainer.kind === 197 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 || + thisContainer.kind === 243 || + (thisContainer.kind === 200 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -30234,7 +32350,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } @@ -30250,7 +32366,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 + return pattern.kind === 188 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -30277,7 +32393,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 ? root.parent : root; + var memberDeclaration = root.kind === 155 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -30330,16 +32446,20 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255) { + if (declaration.kind === 258) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -30377,6 +32497,9 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } @@ -30390,7 +32513,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159) { + if (accessor.kind === 162) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -30417,55 +32540,61 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159); - var setter = ts.getDeclarationOfKind(symbol, 160); + if (!pushTypeResolution(symbol, 0)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162); + var setter = ts.getDeclarationOfKind(symbol, 163); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0)) { - return errorType; - } - var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159); - 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)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 ? baseConstructorType : + baseConstructorType.flags & 2097152 ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -30473,18 +32602,9 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -30496,8 +32616,9 @@ var ts; if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 || - declaration.kind === 190 && declaration.parent.kind === 205) { + else if (declaration.kind === 208 || + (declaration.kind === 193 || declaration.kind === 194) && + declaration.parent.kind === 208) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -30531,7 +32652,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.type) { var targetSymbol = resolveAlias(symbol); - links.type = targetSymbol.flags & 67220415 + links.type = targetSymbol.flags & 111551 ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -30557,7 +32678,7 @@ var ts; error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); return errorType; } - if (noImplicitAny && (declaration.kind !== 152 || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } return anyType; @@ -30630,55 +32751,66 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; + if (node && ts.isBinaryExpression(node)) { + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 || assignmentKind === 3) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241: - case 210: - case 242: - case 161: - case 162: - case 156: - case 166: - case 167: - case 295: - case 240: - case 157: - case 197: - case 198: + case 244: + case 213: + case 245: + case 164: + case 165: + case 159: + case 169: + case 170: + case 298: case 243: - case 310: - case 311: - case 304: - case 182: - case 176: + case 160: + case 200: + case 201: + case 246: + case 314: + case 315: + case 309: + case 308: + case 185: + case 179: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182) { + if (node.kind === 185) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176) { + else if (node.kind === 179) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 || node.kind === 210 || node.kind === 242) && + (node.kind === 244 || node.kind === 213 || node.kind === 245 || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245); 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 === 242 || - node.kind === 241 || - node.kind === 210 || + if (node.kind === 245 || + node.kind === 244 || + node.kind === 213 || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -30693,19 +32825,19 @@ var ts; var signatures = getSignaturesOfType(type, 1); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1).length > 0) { + if (getSignaturesOfType(type, 1).length > 0) { return true; } if (type.flags & 8650752) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -30788,21 +32920,15 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 && areAllOuterTypeParametersApplied(originalBaseType)) { - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode); if (!constructors.length) { @@ -30831,12 +32957,18 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } function isValidBaseType(type) { + if (type.flags & 262144) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } return !!(type.flags & (524288 | 67108864 | 1)) && !isGenericMappedType(type) || !!(type.flags & 2097152) && ts.every(type.types, isValidBaseType); } @@ -30844,7 +32976,7 @@ var ts; 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 === 242 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -30873,8 +33005,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242) { - if (declaration.flags & 64) { + if (declaration.kind === 245) { + if (declaration.flags & 128) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -30882,7 +33014,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832, true); + var baseSymbol = resolveEntityName(node.expression, 788968, true); if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -30895,9 +33027,14 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 ? 1 : 2; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (outerTypeParameters || localTypeParameters || kind === 1 || !isThislessInterface(symbol)) { @@ -30908,7 +33045,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -30922,9 +33059,10 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("Type alias symbol with no valid declaration found"); + } var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; if (popTypeResolution()) { @@ -30937,17 +33075,17 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205) { + else if (expr.kind === 208) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -30955,18 +33093,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304); + return !(member.flags & 8388608); } switch (expr.kind) { case 10: case 8: + case 14: return true; - case 203: - return expr.operator === 39 && + case 206: + return expr.operator === 40 && expr.operand.kind === 8; - case 73: + case 75: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205: + case 208: return isStringConcatExpression(expr); default: return false; @@ -30980,10 +33119,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244) { + if (declaration.kind === 247) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1; } if (!isLiteralEnumMember(member)) { @@ -31007,7 +33146,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244) { + if (declaration.kind === 247) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -31074,23 +33213,23 @@ var ts; } function isThislessType(node) { switch (node.kind) { - case 121: - case 144: - case 139: - case 136: - case 147: case 124: - case 140: - case 137: - case 107: + case 147: case 142: - case 97: - case 133: - case 183: + case 139: + case 150: + case 127: + case 143: + case 140: + case 109: + case 145: + case 99: + case 136: + case 186: return true; - case 170: + case 173: return isThislessType(node.elementType); - case 165: + case 168: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -31106,7 +33245,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -31115,14 +33254,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155: - case 154: - return isThislessVariableLikeDeclaration(declaration); - case 157: - case 156: case 158: - case 159: + case 157: + return isThislessVariableLikeDeclaration(declaration); case 160: + case 159: + case 161: + case 162: + case 163: return isThislessFunctionLikeDeclaration(declaration); } } @@ -31163,9 +33302,12 @@ var ts; return !!(type.flags & 8576); } function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 && @@ -31201,7 +33343,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415) { + if (symbolFlags & 111551) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -31212,7 +33354,8 @@ var ts; var links = getNodeLinks(decl); if (!links.resolvedSymbol) { links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -31222,9 +33365,9 @@ var ts; var earlySymbol = earlySymbols && earlySymbols.get(memberName); if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) { var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0, memberName, 4096); } lateSymbol.nameType = type; @@ -31261,12 +33404,27 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 + || assignmentKind === 4 + || assignmentKind === 9 + || assignmentKind === 6; + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; } function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 + return symbol.flags & 6256 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers") : symbol.members || emptySymbols; } @@ -31289,7 +33447,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -31352,9 +33510,9 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { var sig = new Signature(checker); @@ -31384,13 +33542,18 @@ var ts; result.mapper = undefined; return result; } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.isOptionalCall = true; + return result; + } function getExpandedParameters(sig) { if (sig.hasRestParameter) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -31452,7 +33615,7 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, true, true); + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, false, true); if (!match) { return undefined; } @@ -31471,7 +33634,7 @@ var ts; } for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; - if (!result || !findMatchingSignature(result, signature, false, true, true)) { + if (!result || !findMatchingSignature(result, signature, false, false, true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -31479,7 +33642,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -31493,7 +33656,7 @@ var ts; if (!ts.length(result) && indexWithLengthOverOne !== -1) { var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -31505,8 +33668,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -31517,7 +33680,7 @@ var ts; if (!left || !right) { return left || right; } - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2); + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -31622,7 +33785,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; if (!mixinFlags[i]) { var signatures = getSignaturesOfType(t, 1); @@ -31640,24 +33803,24 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, false, false, false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); @@ -31708,13 +33871,17 @@ var ts; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } if (symbol.flags & 32) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor")) : ts.emptyArray; + if (symbol.flags & 16) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -31841,8 +34008,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 180 && - constraintDeclaration.operator === 130; + return constraintDeclaration.kind === 183 && + constraintDeclaration.operator === 133; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -31860,8 +34027,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 ? 2 : 1 : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 39 ? 8 : 4 : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 ? 2 : 1 : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 ? 8 : 4 : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -32054,11 +34221,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; if (t.flags & 63176704) { var constraint = getConstraintOfType(t); while (constraint && constraint.flags & (262144 | 4194304 | 16777216)) { @@ -32066,6 +34233,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908) { @@ -32074,8 +34244,8 @@ var ts; } if (constraints && (targetIsUnion || hasDisjointDomainType)) { if (hasDisjointDomainType) { - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908) { constraints = ts.append(constraints, t); } @@ -32148,8 +34318,8 @@ var ts; if (t.flags & 3145728) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -32450,10 +34620,10 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - return ts.isInJSFile(node) && (node.type && node.type.kind === 294 + return ts.isInJSFile(node) && (node.type && node.type.kind === 297 || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -32486,13 +34656,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297; } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; - } - function createThisTypePredicate(type) { - return { kind: 0, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } function getMinTypeArgumentCount(typeParameters) { var minTypeArgumentCount = 0; @@ -32549,7 +34716,7 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415, undefined, undefined, false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551, undefined, undefined, false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this") { @@ -32559,7 +34726,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183) { + if (type && type.kind === 186) { hasLiteralTypes = true; } var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -32571,16 +34738,16 @@ var ts; minArgumentCount = parameters.length; } } - if ((declaration.kind === 159 || declaration.kind === 160) && + if ((declaration.kind === 162 || declaration.kind === 163) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 ? 160 : 159; + var otherKind = declaration.kind === 162 ? 163 : 162; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 ? + var classType = declaration.kind === 161 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -32630,13 +34797,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73: + case 75: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155: - case 157: - case 159: + case 158: case 160: - return node.name.kind === 150 + case 162: + case 163: + return node.name.kind === 153 && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -32676,9 +34843,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -32707,13 +34871,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 ? + createTypePredicate(node.assertsModifier ? 2 : 0, undefined, undefined, type) : + createTypePredicate(node.assertsModifier ? 3 : 1, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -32723,8 +34884,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signature.isOptionalCall) { + type = propagateOptionalTypeMarker(type, true); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -32749,7 +34912,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158) { + if (declaration.kind === 161) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -32759,12 +34922,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -32843,7 +35006,7 @@ var ts; function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0; - var isConstructor = kind === 158 || kind === 162 || kind === 167; + var isConstructor = kind === 161 || kind === 165 || kind === 170; var type = createObjectType(16); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -32857,7 +35020,7 @@ var ts; return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 136 : 139; + var syntaxKind = kind === 1 ? 139 : 142; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -32884,17 +35047,16 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177) { + if (declaration.parent.kind === 180) { var grandParent = declaration.parent.parent; - if (grandParent.kind === 165) { + if (grandParent.kind === 168) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -32911,7 +35073,7 @@ var ts; } } } - else if (grandParent.kind === 152 && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -32934,7 +35096,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -32963,8 +35125,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -32979,7 +35141,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -32988,13 +35150,35 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; + return type; + } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; return type; } + function getTypeArguments(type) { + if (!type.resolvedTypeArguments) { + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -33004,20 +35188,23 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, undefined, 2); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { return errorType; } } - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + if (node.kind === 168 && isAliasedType(node)) { + return createDeferredTypeReference(type, node, undefined); + } + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -33033,27 +35220,27 @@ var ts; } return instantiation; } - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165: + case 168: return node.typeName; - case 212: + case 215: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -33061,33 +35248,22 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 | 64)) { + return getTypeFromClassOrInterfaceReference(node, symbol); } - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288) { + return getTypeFromTypeAliasReference(node, symbol); } var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { @@ -33095,46 +35271,26 @@ var ts; res.flags & 262144 ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - resolveTypeReferenceName(getTypeReferenceName(node), 67897832); - return getTypeOfSymbol(symbol); - } - function getJSDocTypeReference(node, symbol, typeArguments) { - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 | 64)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } + if (symbol.flags & 111551 && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); + else { + resolveTypeReferenceName(getTypeReferenceName(node), 788968); + return getTypeOfSymbol(symbol); } } + return errorType; + } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; + } } function getSubstitutionType(typeVariable, substitute) { if (substitute.flags & 3 || substitute === typeVariable) { @@ -33152,7 +35308,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 && node.elementTypes.length === 1; + return node.kind === 174 && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -33161,9 +35317,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297) { + while (node && !ts.isStatement(node) && node.kind !== 301) { var parent = node.parent; - if (parent.kind === 176 && node === parent.trueType) { + if (parent.kind === 179 && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -33174,7 +35330,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152) && (node.kind === 165 || node.kind === 184); + return !!(node.flags & 4194304) && (node.kind === 168 || node.kind === 187); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -33211,10 +35367,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -33226,7 +35382,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -33239,10 +35395,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832; + var meaning = 788968; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -33269,9 +35434,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241: - case 242: case 244: + case 245: + case 247: return declaration; } } @@ -33291,10 +35456,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { return resolveName(undefined, name, meaning, diagnostic, name, false); @@ -33362,7 +35527,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832, undefined); + var symbol = getGlobalSymbol(name, 788968, undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -33386,15 +35551,52 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, undefined); + } + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181: + case 168: + case 177: + case 178: + case 184: + case 179: + case 183: + return isAliasedType(parent); + case 246: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, undefined); + } + else { + var elementTypes = node.kind === 173 ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134; + return ts.isTypeOperatorNode(node) && node.operator === 137; } function createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames) { var typeParameters; @@ -33424,7 +35626,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -33458,26 +35660,12 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 && n !== restElement_1; }) + 1; - var elementTypes = ts.map(node.elementTypes, function (n) { - var type = getTypeFromTypeNode(n); - return n === restElement_1 && getIndexTypeOfType(type, 1) || type; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -33523,8 +35711,8 @@ var ts; return includes; } function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -33553,8 +35741,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { var estimatedCount = (count / (len - i)) * len; @@ -33627,10 +35815,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 || pred.kind === 3) { continue; } if (first) { @@ -33647,14 +35835,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { if (types.length === 0) { @@ -33710,8 +35894,8 @@ var ts; return includes; } function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -33746,6 +35930,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 131072); }); @@ -33832,6 +36025,12 @@ var ts; if (intersectUnionsOfPrimitiveTypes(typeSet)) { result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1, aliasSymbol, aliasTypeArguments); + } else { var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 ? t.types.length : 1); }, 1); if (size >= 100000) { @@ -33933,17 +36132,19 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130: + case 133: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143: - links.resolvedType = node.type.kind === 140 + case 146: + links.resolvedType = node.type.kind === 143 ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134: + case 137: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } return links.resolvedType; @@ -33973,7 +36174,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -33983,13 +36184,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 101); + markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 103); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -34120,13 +36321,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 - ? accessNode.argumentExpression - : accessNode.kind === 181 - ? accessNode.indexType - : accessNode.kind === 150 - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 ? accessNode.argumentExpression : + accessNode.kind === 184 ? accessNode.indexType : + accessNode.kind === 153 ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 | 131072); @@ -34219,7 +36417,7 @@ var ts; if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 4 | 8)) { indexType = stringType; } - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184) && isGenericObjectType(objectType)) { if (objectType.flags & 3) { return objectType; } @@ -34407,7 +36605,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 : node.flags & 2097152 ? 67220415 | 67897832 : 67897832; + var targetMeaning = node.isTypeOf ? 111551 : node.flags & 4194304 ? 111551 | 788968 : 788968; var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; @@ -34429,14 +36627,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 + var errorMessage = targetMeaning === 111551 ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -34450,11 +36648,11 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415) { - return links.resolvedType = getTypeOfSymbol(symbol); + if (meaning === 111551) { + return getTypeOfSymbol(symbol); } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); + return getTypeReferenceType(node, resolvedSymbol); } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -34477,7 +36675,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -34652,12 +36854,22 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245)) { if (!ts.hasModifier(container, 32) && - (container.kind !== 158 || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + var host = node.flags & 4194304 ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -34670,87 +36882,87 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121: - case 290: - case 291: + case 124: + case 293: + case 294: return anyType; - case 144: + case 147: return unknownType; - case 139: + case 142: return stringType; - case 136: + case 139: return numberType; - case 147: + case 150: return bigintType; - case 124: + case 127: return booleanType; - case 140: + case 143: return esSymbolType; - case 107: + case 109: return voidType; - case 142: + case 145: return undefinedType; - case 97: + case 99: return nullType; - case 133: + case 136: return neverType; - case 137: - return node.flags & 65536 ? anyType : nonPrimitiveType; - case 179: - case 101: + case 140: + return node.flags & 131072 ? anyType : nonPrimitiveType; + case 182: + case 103: return getTypeFromThisTypeNode(node); - case 183: + case 186: return getTypeFromLiteralTypeNode(node); - case 165: + case 168: return getTypeFromTypeReference(node); - case 164: - return booleanType; - case 212: + case 167: + return node.assertsModifier ? voidType : booleanType; + case 215: return getTypeFromTypeReference(node); - case 168: - return getTypeFromTypeQueryNode(node); - case 170: - return getTypeFromArrayTypeNode(node); case 171: - return getTypeFromTupleTypeNode(node); - case 172: - return getTypeFromOptionalTypeNode(node); + return getTypeFromTypeQueryNode(node); + case 173: case 174: - return getTypeFromUnionTypeNode(node); + return getTypeFromArrayOrTupleTypeNode(node); case 175: + return getTypeFromOptionalTypeNode(node); + case 177: + return getTypeFromUnionTypeNode(node); + case 178: return getTypeFromIntersectionTypeNode(node); - case 292: + case 295: return getTypeFromJSDocNullableTypeNode(node); - case 294: + case 297: return addOptionality(getTypeFromTypeNode(node.type)); - case 178: - case 173: - case 293: - case 289: - return getTypeFromTypeNode(node.type); + case 181: case 296: + case 292: + return getTypeFromTypeNode(node.type); + case 176: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299: return getTypeFromJSDocVariadicType(node); - case 166: - case 167: case 169: + case 170: + case 172: + case 302: case 298: - case 295: - case 299: + case 303: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180: + case 183: return getTypeFromTypeOperatorNode(node); - case 181: + case 184: return getTypeFromIndexedAccessTypeNode(node); - case 182: + case 185: return getTypeFromMappedTypeNode(node); - case 176: + case 179: return getTypeFromConditionalTypeNode(node); - case 177: + case 180: return getTypeFromInferTypeNode(node); - case 184: + case 187: return getTypeFromImportTypeNode(node); - case 73: - case 149: + case 75: + case 152: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -34835,20 +37047,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -34887,13 +37086,13 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -34909,7 +37108,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 || target.symbol.flags & 2048) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -34919,13 +37118,14 @@ var ts; } } if (typeParameters.length) { - var combinedMapper = type.objectFlags & 64 ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -34933,14 +37133,15 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 || - node.parent.kind === 165 && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 152 || + node.parent.kind === 168 && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 || n.kind === 176 && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 || n.kind === 179 && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -34949,12 +37150,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179: + case 182: return !!tp.isThisType; - case 73: + case 75: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168: + case 171: return true; } return !!ts.forEachChild(node, containsReference); @@ -34998,7 +37199,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -35081,15 +37282,18 @@ var ts; var objectFlags = type.objectFlags; if (objectFlags & 16) { return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -35146,34 +37350,34 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197: - case 198: - case 157: - case 240: + case 200: + case 201: + case 160: + case 243: return isContextSensitiveFunctionLikeDeclaration(node); - case 189: + case 192: return ts.some(node.properties, isContextSensitive); - case 188: + case 191: return ts.some(node.elements, isContextSensitive); - case 206: + case 209: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205: - return node.operatorToken.kind === 55 && + case 208: + return (node.operatorToken.kind === 56 || node.operatorToken.kind === 60) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276: + case 279: return isContextSensitive(node.initializer); - case 196: + case 199: return isContextSensitive(node.expression); - case 269: + case 272: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268: { + case 271: { var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 271: { + case 274: { var expression = node.expression; return !!expression && isContextSensitive(expression); } @@ -35190,7 +37394,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198) { + if (node.kind !== 201) { var parameter = ts.firstOrUndefined(node.parameters); if (!(parameter && ts.parameterIsThisKeyword(parameter))) { return true; @@ -35199,7 +37403,7 @@ var ts; return hasContextSensitiveReturnExpression(node); } function hasContextSensitiveReturnExpression(node) { - return !!node.body && node.body.kind !== 219 && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -35279,23 +37483,23 @@ var ts; return true; } switch (node.kind) { - case 271: - case 196: + case 274: + case 199: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205: + case 208: switch (node.operatorToken.kind) { - case 60: + case 62: case 27: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189: + case 192: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188: + case 191: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269: + case 272: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198: + case 201: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -35456,16 +37660,16 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271: + case 274: return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11: if (child.containsOnlyTriviaWhiteSpaces) { break; } return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261: - case 262: + case 264: case 265: + case 268: return { errorNode: child, innerExpression: child, nameType: nameType }; default: return ts.Debug.assertNever(child, "Found invalid jsx child"); @@ -35536,7 +37740,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -35602,11 +37806,11 @@ var ts; } _b = prop.kind; switch (_b) { + case 163: return [3, 2]; + case 162: return [3, 2]; case 160: return [3, 2]; - case 159: return [3, 2]; - case 157: return [3, 2]; - case 277: return [3, 2]; - case 276: return [3, 4]; + case 280: return [3, 2]; + case 279: return [3, 4]; } return [3, 6]; case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -35636,14 +37840,14 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, 0, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0; + return compareSignaturesRelated(source, target, 0, ignoreReturnTypes, false, undefined, undefined, compareTypesAssignable) !== 0; } function isAnySignature(s) { return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 && s.hasRestParameter && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && isTypeAny(getReturnTypeOfSignature(s)); } - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { if (source === target) { return -1; } @@ -35665,8 +37869,8 @@ var ts; return 0; } var kind = target.declaration ? target.declaration.kind : 0; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 && - kind !== 156 && kind !== 158; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 && + kind !== 159 && kind !== 161; var result = -1; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -35690,10 +37894,10 @@ var ts; var targetType = i === restIndex ? getRestTypeAtPosition(target, i) : getTypeAtPosition(target, i); var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (getFalsyFlags(sourceType) & 98304) === (getFalsyFlags(targetType) & 98304); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 : 1, false, reportErrors, errorReporter, compareTypes) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 : 1, false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -35704,13 +37908,15 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { var sourceTypePredicate = getTypePredicateOfSignature(source); @@ -35727,6 +37933,9 @@ var ts; else { result &= callbackCheck === 1 && compareTypes(targetReturnType, sourceReturnType, false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -35739,7 +37948,7 @@ var ts; } return 0; } - if (source.kind === 1) { + if (source.kind === 1 || source.kind === 3) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -35748,7 +37957,9 @@ var ts; return 0; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0; if (related === 0 && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -35793,12 +38004,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 && errorReporter)) { - return relation === 1; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4) && entry & 2 && errorReporter)) { + return !!(entry & 1); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256) || !(targetSymbol.flags & 256)) { - enumRelation.set(id, 3); + enumRelation.set(id, 2 | 4); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -35809,7 +38020,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), undefined, 64)); - enumRelation.set(id, 3); + enumRelation.set(id, 2 | 4); } else { enumRelation.set(id, 2); @@ -35885,7 +38096,7 @@ var ts; if (source.flags & 524288 && target.flags & 524288) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { - return related === 1; + return !!(related & 1); } } if (source.flags & 66846720 || target.flags & 66846720) { @@ -35906,9 +38117,14 @@ var ts; var depth = 0; var expandingFlags = 0; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -35936,7 +38152,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -35949,8 +38165,119 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; + lastSkippedInfo = undefined; + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + reportRelationError.apply(void 0, __spreadArrays([undefined], info)); + } + return; + } + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + if (path.length === 0) { + path = "" + str; + } + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + reportRelationError.apply(void 0, __spreadArrays([undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -35963,6 +38290,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -35981,8 +38310,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -36049,7 +38378,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -36059,11 +38388,11 @@ var ts; return 0; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = 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, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0); var constructs = getSignaturesOfType(source, 1); @@ -36078,19 +38407,19 @@ var ts; return 0; } var result = 0; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); var isIntersectionConstituent = !!isApparentIntersectionConstituent; if (source.flags & 1048576) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068)); } else { if (target.flags & 1048576) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, undefined, isIntersectionConstituent)) { return 0; } } @@ -36098,37 +38427,41 @@ var ts; else if (target.flags & 2097152) { isIntersectionConstituent = true; result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { - if (!propertiesRelatedTo(source, target, reportErrors, undefined)) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { + if (!propertiesRelatedTo(source, target, reportErrors, undefined, false)) { return 0; } } } else if (source.flags & 2097152) { - result = someTypeRelatedToType(source, target, false); + result = someTypeRelatedToType(source, target, false, true); } if (!result && (source.flags & 66846720 || target.flags & 66846720)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152) { - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + if (!result && source.flags & (2097152 | 262144)) { + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576)); + if (constraint && (source.flags & 2097152 || target.flags & 1048576)) { + if (everyType(constraint, function (c) { return c !== source; })) { + if (result = isRelatedTo(constraint, target, false, undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 && target.flags & 524288) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 && target.flags & 131068) { @@ -36147,6 +38480,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; return result; } reportRelationError(headMessage, source, target); @@ -36181,13 +38515,16 @@ var ts; if (discriminant) { return hasExcessProperties(source, discriminant, undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { var errorTarget = filterType(target, isExcessPropertyCheckTarget); if (!errorNode) return { value: ts.Debug.fail() }; if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) { + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -36215,9 +38552,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -36348,14 +38685,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 && containsType(sourceTypes, target)) { return -1; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, undefined, isIntersectionConstituent); if (related) { return related; } @@ -36375,7 +38712,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -36395,21 +38732,21 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, false) : compareTypesIdentical(s, t); } else if (variance === 1) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, undefined, isIntersectionConstituent); } else if (variance === 2) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, undefined, isIntersectionConstituent); } else if (variance === 3) { related = isRelatedTo(t, s, false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, undefined, isIntersectionConstituent); } } else { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, undefined, isIntersectionConstituent); } } if (!related) { @@ -36420,37 +38757,26 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } function recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { if (overflow) { return 0; } var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2) { + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 && !(entry & 4)) { } else { if (outofbandVarianceMarkerHandler) { - if (source.flags & (524288 | 16777216) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24; + if (saved & 8) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 ? -1 : 0; + return entry & 1 ? -1 : 0; } } if (!maybeKeys) { @@ -36480,19 +38806,31 @@ var ts; expandingFlags |= 1; if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 : 8; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 || depth === 0) { for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1); + relation.set(maybeKeys[i], 1 | propagatingVarianceFlags); } maybeCount = maybeStart; } } else { - relation.set(id, reportErrors ? 3 : 2); + relation.set(id, (reportErrors ? 4 : 0) | 2 | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -36532,12 +38870,12 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); if (source.flags & (524288 | 16777216) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -36606,7 +38944,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -36616,7 +38954,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -36624,35 +38962,44 @@ var ts; var constraint = getConstraintOfType(source); if (!constraint || (source.flags & 262144 && constraint.flags & 1)) { if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } else if (result = isRelatedTo(constraint, target, false, undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } else if (source.flags & 16777216) { if (target.flags & 16777216) { - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + var ctx = createInferenceContext(sourceParams, undefined, 0, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 | 128); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -36661,14 +39008,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -36681,7 +39028,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -36697,7 +39044,7 @@ var ts; 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); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -36714,8 +39061,8 @@ var ts; return 0; } if (source.flags & (524288 | 2097152) && target.flags & 524288) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; - result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined); + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; + result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors); if (result) { @@ -36729,7 +39076,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; } else if (result) { return result; @@ -36746,13 +39093,13 @@ var ts; } } return 0; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24); })) { originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -36762,7 +39109,7 @@ var ts; return 0; } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -36817,25 +39164,25 @@ var ts; } var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) return "continue-outer"; if (sourceProperty === targetProperty) return "continue"; - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false, false); if (!related) { return "continue-outer"; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -36848,14 +39195,14 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } var result = -1; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, false, excludedProperties); + result &= propertiesRelatedTo(source, type, false, excludedProperties, false); if (result) { result &= signaturesRelatedTo(source, type, 0, false); if (result) { @@ -36890,7 +39237,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 && !getSymbolLinks(targetProp).type) { @@ -36924,10 +39271,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { @@ -36964,10 +39311,10 @@ var ts; } return 0; } - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0; } @@ -36979,7 +39326,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -36995,12 +39342,12 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, false)) { @@ -37010,8 +39357,8 @@ var ts; 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(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } } @@ -37022,7 +39369,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -37047,8 +39394,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -37060,12 +39408,14 @@ var ts; } } var properties = target.flags & 1048576 ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0; } @@ -37124,10 +39474,11 @@ var ts; } } var result = -1; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 && ts.getObjectFlags(target) & 64 && source.symbol === target.symbol) { for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0; } @@ -37136,7 +39487,7 @@ var ts; } else if (sourceSignatures.length === 1 && targetSignatures.length === 1) { var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -37144,10 +39495,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -37160,8 +39511,20 @@ var ts; } return result; } - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0, false, reportErrors, reportError, isRelatedTo); + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0, false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -37223,7 +39586,7 @@ var ts; return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } if (isGenericMappedType(source)) { - return (kind === 0 && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); + return kind === 0 ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0; } if (isObjectTypeWithInferableIndex(source)) { var related = -1; @@ -37276,23 +39639,24 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; + } + else { + discriminable[i] = false; } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(true); + return match === -1 || discriminable.indexOf(true, match + 1) !== -1 ? defaultValue : target.types[match]; } function isWeakType(type) { if (type.flags & 524288) { @@ -37335,7 +39699,7 @@ var ts; if (!variances) { cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -37360,7 +39724,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -37383,13 +39747,16 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -37466,8 +39833,27 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0; } @@ -37561,19 +39947,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 : + source.type === target.type ? -1 : + source.type && target.type ? compareTypes(source.type, target.type) : + 0; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -37608,13 +39997,13 @@ var ts; return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { return isArrayType(type) || !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -37694,7 +40083,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 && type.target.objectFlags & 8); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -37709,8 +40098,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -37766,13 +40155,44 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, function (t) { return t !== optionalType; }) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function createPooledOptionalTypeResult(isOptional, type) { + pooledOptionalTypeResult.isOptional = isOptional; + pooledOptionalTypeResult.type = type; + return pooledOptionalTypeResult; + } + function checkOptionalExpression(parent, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + var isOptional = false; + var type = checkExpression(expression); + if (ts.isOptionalChain(parent)) { + if (parent.questionDotToken) { + isOptional = isNullableType(type); + return createPooledOptionalTypeResult(isOptional, isOptional ? getNonNullableType(type) : type); + } + var nonOptionalType = removeOptionalTypeMarker(type); + if (nonOptionalType !== type) { + isOptional = true; + type = nonOptionalType; + } + } + type = checkNonNullType(type, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + return createPooledOptionalTypeResult(isOptional, type); + } function isCoercibleUnderDoubleEquals(source, target) { return ((source.flags & (8 | 4 | 512)) !== 0) && ((target.flags & (8 | 4 | 16)) !== 0); } function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8); @@ -37914,7 +40334,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -37940,7 +40360,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -37969,17 +40389,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205: - case 155: - case 154: + case 208: + case 158: + case 157: 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 152: + case 155: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832, undefined, param.name.escapedText, true) || + (resolveName(param, param.name.escapedText, 788968, undefined, param.name.escapedText, true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -37989,22 +40409,22 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187: + case 190: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { return; } break; - case 295: + case 298: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240: - case 157: - case 156: - case 159: + case 243: case 160: - case 197: - case 198: + case 159: + case 162: + case 163: + case 200: + case 201: if (noImplicitAny && !declaration.name) { if (wideningKind === 1) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -38018,7 +40438,7 @@ var ts; wideningKind === 1 ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182: + case 185: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -38059,8 +40479,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -38129,16 +40548,22 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 || - objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations || objectFlags & 32 || - type.flags & 3145728 && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 && !(type.flags & 1024) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -38189,10 +40614,10 @@ var ts; return undefined; } if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), 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.readonly, source.target.associatedNames); @@ -38274,8 +40699,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -38293,38 +40717,37 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - 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]; - inferFromTypes(t, t); - } - return; + if (source === target && source.flags & 3145728) { + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } + return; + } + if (target.flags & 1048576) { + var _b = inferFromMatchingTypes(source.flags & 1048576 ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { + return; } - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + target = getUnionType(targets); + if (sources.length === 0) { + var savePriority = priority; + priority |= 1; + inferFromTypes(source, target); + priority = savePriority; + return; } + source = getUnionType(sources); } - else if (target.flags & 1048576 && !(target.flags & 1024) || target.flags & 2097152) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); - return; + else if (target.flags & 2097152 && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + if (!(source.flags & 1048576)) { + var _d = inferFromMatchingTypes(source.flags & 2097152 ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); } } else if (target.flags & (8388608 | 33554432)) { @@ -38361,7 +40784,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -38380,8 +40803,9 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target))) { - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 && target.flags & 4194304) { contravariant = !contravariant; @@ -38416,8 +40840,8 @@ var ts; } else if (source.flags & 1048576) { var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -38437,15 +40861,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1); + var saveInferencePriority = inferencePriority; + inferencePriority = 256; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -38485,26 +40930,26 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + var inferenceCircularity = false; + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - if (typeVariableCount === 1 && inferenceComplete) { + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -38513,8 +40958,8 @@ var ts; } } else { - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -38526,8 +40971,8 @@ var ts; if (targetFlags & 2097152 ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -38582,7 +41027,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -38594,6 +41039,10 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } if (isGenericMappedType(source) && isGenericMappedType(target)) { inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target)); inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); @@ -38620,10 +41069,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -38662,7 +41111,7 @@ var ts; if (!skipParameters) { var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0; - bivariant = bivariant || kind === 157 || kind === 156 || kind === 158; + bivariant = bivariant || kind === 160 || kind === 159 || kind === 161; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -38688,39 +41137,12 @@ var ts; } } } - function isMatchableType(type) { - return !(type.flags & 524288) || !!(ts.getObjectFlags(type) & 16); - } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 | 128) && target.flags & 1048576) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 | 256)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 && t.flags & 524288 && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -38841,7 +41263,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277) { + if (node.parent.kind === 280) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -38853,25 +41275,25 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 | 1048576, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; + resolveName(node, node.escapedText, 111551 | 1048576, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; } function isInTypeQuery(node) { - return !!ts.findAncestor(node, function (n) { return n.kind === 168 ? true : n.kind === 73 || n.kind === 149 ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 ? true : n.kind === 75 || n.kind === 152 ? false : "quit"; }); } function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73: + case 75: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101: + case 103: return "0"; - case 214: - case 196: + case 217: + case 199: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190: - case 191: + case 193: + case 194: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -38882,24 +41304,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196: - case 214: + case 199: + case 217: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73: - return target.kind === 73 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 || target.kind === 187) && + case 75: + return target.kind === 75 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 || target.kind === 190) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); + case 103: + return target.kind === 103; case 101: return target.kind === 101; - case 99: - return target.kind === 99; - case 214: - case 196: + case 217: + case 199: return isMatchingReference(source.expression, target); - case 190: - case 191: + case 193: + case 194: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -38907,8 +41329,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -38928,7 +41350,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73) { + if (expr.kind === 75) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -38959,7 +41381,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 && !!(expr.expression.flags & 8); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 && !!(expr.expression.flags & 8); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -38987,14 +41409,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 && + if (callExpression.expression.kind === 193 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -39029,8 +41451,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -39133,15 +41555,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65, type, undefinedType, undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 && parent.parent.left === parent || - parent.parent.kind === 228 && parent.parent.initializer === parent; + return parent.parent.kind === 208 && parent.parent.left === parent || + parent.parent.kind === 231 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -39158,21 +41580,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227: + case 230: return stringType; - case 228: + case 231: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205: + case 208: return getAssignedTypeOfBinaryExpression(parent); - case 199: + case 202: return undefinedType; - case 188: + case 191: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209: + case 212: return getAssignedTypeOfSpreadExpression(parent); - case 276: + case 279: return getAssignedTypeOfPropertyAssignment(parent); - case 277: + case 280: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -39180,7 +41602,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 ? + var type = pattern.kind === 188 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -39195,37 +41617,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227) { + if (node.parent.parent.kind === 230) { return stringType; } - if (node.parent.parent.kind === 228) { + if (node.parent.parent.kind === 231) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 ? + return node.kind === 241 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 || node.kind === 187 ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 && node.initializer && + return node.kind === 241 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 && node.parent.kind === 205 && + node.kind !== 190 && node.parent.kind === 208 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196: + case 199: return getReferenceCandidate(node.expression); - case 205: + case 208: switch (node.operatorToken.kind) { - case 60: + case 62: return getReferenceCandidate(node.left); case 27: return getReferenceCandidate(node.right); @@ -39235,13 +41652,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 || - parent.kind === 205 && parent.operatorToken.kind === 60 && parent.left === node || - parent.kind === 205 && parent.operatorToken.kind === 27 && parent.right === node ? + return parent.kind === 199 || + parent.kind === 208 && parent.operatorToken.kind === 62 && parent.left === node || + parent.kind === 208 && parent.operatorToken.kind === 27 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272) { + if (clause.kind === 275) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -39261,8 +41678,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272) { - if (clause.expression.kind === 10) { + if (clause.kind === 275) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -39342,8 +41759,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 128) : t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 256) : - t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : - t; + t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : t; }); } return typeWithPrimitives; @@ -39387,8 +41803,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 131072)) { if (!(ts.getObjectFlags(t) & 256)) { return false; @@ -39406,33 +41822,70 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 && (parent.name.escapedText === "length" || - parent.parent.kind === 192 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 && + var isLengthPushOrUnshift = parent.kind === 193 && (parent.name.escapedText === "length" || + parent.parent.kind === 195 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 && parent.expression === root && - parent.parent.kind === 205 && - parent.parent.operatorToken.kind === 60 && + parent.parent.kind === 208 && + parent.parent.operatorToken.kind === 62 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 || declaration.kind === 155 || + declaration.kind === 158 || declaration.kind === 157) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 | 8192 | 32 | 512)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 | 4)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0), signatureHasTypePredicate); + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216)) { + switch (node.kind) { + case 75: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 ? resolveAlias(symbol) : symbol, diagnostic); + case 103: + return getExplicitThisType(node); + case 193: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + var funcType = node.parent.kind === 225 ? getTypeOfDottedName(node.expression, undefined) : + node.expression.kind !== 101 ? checkOptionalExpression(node, node.expression).type : + undefined; + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072); } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -39440,6 +41893,63 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 && flow.lock.locked) && isReachableFlowNodeWorker(flow, false); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, true)); + } + noCacheCheck = false; + } + if (flags & (16 | 96 | 256 | 4096)) { + flow = flow.antecedent; + } + else if (flags & 512) { + var signature = getEffectsSignature(flow.node); + if (signature && getReturnTypeOfSignature(signature).flags & 131072) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 4) { + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8) { + flow = flow.antecedents[0]; + } + else if (flags & 128) { + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192) { + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, false); + flow.locked = false; + return result; + } + else { + return !(flags & 1); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -39451,11 +41961,12 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 && getTypeWithFacts(resultType, 2097152).flags & 131072) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 && getTypeWithFacts(resultType, 2097152).flags & 131072) { return declaredType; } return resultType; @@ -39475,16 +41986,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024) { + if (flags & 2048) { for (var i = sharedFlowStart; i < sharedFlowCount; i++) { if (sharedFlowNodes[i] === flow) { flowDepth--; @@ -39493,12 +41995,12 @@ var ts; } } var type = void 0; - if (flags & 4096) { + if (flags & 8192) { flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048) { + else if (flags & 4096) { flow = flow.antecedent; continue; } @@ -39508,14 +42010,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96) { @@ -39541,11 +42041,11 @@ var ts; } } else if (flags & 2) { - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 && - reference.kind !== 191 && - reference.kind !== 101) { + reference.kind !== 193 && + reference.kind !== 194 && + reference.kind !== 103) { flow = container.flowNode; continue; } @@ -39554,7 +42054,7 @@ var ts; else { type = convertAutoToAny(declaredType); } - if (flags & 1024) { + if (flags & 2048) { sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; sharedFlowCount++; @@ -39563,9 +42063,30 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 || node.kind === 190 ? + getInitialType(node) : + getAssignedType(node), reference); + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -39574,32 +42095,65 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 197 || init.kind === 198)) { + if (init && (init.kind === 200 || init.kind === 201)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 227 && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 208) { + if (node.operatorToken.kind === 55) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 || predicate.kind === 3)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, true) : + predicate.kind === 3 ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 ? + var expr = node.kind === 195 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -39607,7 +42161,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 192) { + if (node.kind === 195) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -39634,7 +42188,7 @@ var ts; } var assumeTrue = (flow.flags & 32) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -39652,12 +42206,15 @@ 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 === 200 && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { type = declaredType; } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } return createFlowType(type, isIncomplete(flowType)); } function getTypeAtFlowBranchLabel(flow) { @@ -39666,7 +42223,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 && antecedent.lock.locked) { + if (antecedent.flags & 4096 && antecedent.lock.locked) { continue; } var flowType = getTypeAtFlowNode(antecedent); @@ -39703,22 +42260,25 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); if (!isTypeSubsetOf(type, declaredType)) { subtypeReduction = true; @@ -39784,19 +42344,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60: + case 62: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33: case 34: case 35: case 36: + case 37: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -39815,9 +42375,9 @@ var ts; return declaredType; } break; - case 95: + case 97: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94: + case 96: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -39832,11 +42392,11 @@ var ts; if (type.flags & 1) { return type; } - if (operator === 34 || operator === 36) { + if (operator === 35 || operator === 37) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2) && (operator === 35) && assumeTrue) { + if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) { if (valueType.flags & (131068 | 67108864)) { return valueType; } @@ -39849,7 +42409,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 || operator === 34; + var doubleEquals = operator === 34 || operator === 35; var facts = doubleEquals ? assumeTrue ? 262144 : 2097152 : valueType.flags & 65536 ? @@ -39861,7 +42421,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 ? + var filterFn = operator === 34 ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -39881,7 +42441,7 @@ var ts; } return type; } - if (operator === 34 || operator === 36) { + if (operator === 35 || operator === 37) { assumeTrue = !assumeTrue; } if (type.flags & 1 && literal.text === "function") { @@ -40049,21 +42609,23 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 || predicate.kind === 1)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { return type; } - if (ts.isIdentifierTypePredicate(predicate)) { + if (predicate.kind === 1 || predicate.kind === 3) { var predicateArgument = callExpression.arguments[predicate.parameterIndex]; - if (predicateArgument) { + if (predicateArgument && predicate.type) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } @@ -40074,7 +42636,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { + if (ts.isAccessExpression(invokedExpression) && predicate.type) { var possibleReference = ts.skipParentheses(invokedExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -40087,31 +42649,47 @@ var ts; return type; } function narrowType(type, expr, assumeTrue) { + if (ts.isOptionalChainRoot(expr.parent) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73: + case 75: + case 103: case 101: - case 99: - case 190: - case 191: + case 193: + case 194: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196: + case 195: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199: return narrowType(type, expr.expression, assumeTrue); - case 205: + case 208: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203: - if (expr.operator === 52) { + case 206: + if (expr.operator === 53) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 : 262144); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 : 262144); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; - if (location.kind === 73) { + if (location.kind === 75) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -40127,9 +42705,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 || - node.kind === 285 || - node.kind === 155; + node.kind === 249 || + node.kind === 288 || + node.kind === 158; }); } function isParameterAssigned(symbol) { @@ -40147,10 +42725,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608); }); } function markParameterAssignments(node) { - if (node.kind === 73) { + if (node.kind === 75) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155) { symbol.isAssigned = true; } } @@ -40164,7 +42742,7 @@ var ts; } function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 && + declaration.kind === 155 && declaration.initializer && getFalsyFlags(declaredType) & 32768 && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768); @@ -40172,10 +42750,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 || - parent.kind === 192 && parent.expression === node || - parent.kind === 191 && parent.expression === node || - parent.kind === 187 && parent.name === node && !!parent.initializer; + return parent.kind === 193 || + parent.kind === 195 && parent.expression === node || + parent.kind === 194 && parent.expression === node || + parent.kind === 190 && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304); @@ -40186,8 +42764,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, 67220415) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, 111551) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -40199,7 +42780,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 198) { + if (container.kind === 201) { 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)) { @@ -40215,7 +42796,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var declaration = localOrExportSymbol.valueDeclaration; if (localOrExportSymbol.flags & 32) { - if (declaration.kind === 241 + if (declaration.kind === 244 && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -40227,11 +42808,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210) { + else if (declaration.kind === 213) { var container = ts.getThisContainer(node, false); - while (container.kind !== 285) { + while (container.kind !== 288) { if (container.parent === declaration) { - if (container.kind === 155 && ts.hasModifier(container, 32)) { + if (container.kind === 158 && ts.hasModifier(container, 32)) { getNodeLinks(declaration).flags |= 16777216; getNodeLinks(node).flags |= 33554432; } @@ -40275,23 +42856,23 @@ var ts; if (!declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 152; + var isParameter = ts.getRootDeclaration(declaration).kind === 155; 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 === 197 || - flowContainer.kind === 198 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 || + flowContainer.kind === 201 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258) || - node.parent.kind === 214 || - declaration.kind === 238 && declaration.exclamationToken || - declaration.flags & 4194304; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 | 16384)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261) || + node.parent.kind === 217 || + declaration.kind === 241 && declaration.exclamationToken || + declaration.flags & 8388608; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -40321,7 +42902,7 @@ var ts; if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275) { + symbol.valueDeclaration.parent.kind === 278) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -40339,7 +42920,7 @@ var ts; if (usedInFunction) { var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -40355,8 +42936,8 @@ var ts; getNodeLinks(current).flags |= 65536; } } - if (container.kind === 226 && - ts.getAncestor(symbol.valueDeclaration, 239).parent === container && + if (container.kind === 229 && + ts.getAncestor(symbol.valueDeclaration, 242).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304; } @@ -40372,16 +42953,16 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 196) { + while (current.parent.kind === 199) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 || current.parent.kind === 204)) { + else if ((current.parent.kind === 206 || current.parent.kind === 207)) { var expr = current.parent; - isAssigned = expr.operator === 44 || expr.operator === 45; + isAssigned = expr.operator === 45 || expr.operator === 46; } if (!isAssigned) { return false; @@ -40390,7 +42971,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 155 || container.kind === 158) { + if (container.kind === 158 || container.kind === 161) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -40434,32 +43015,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var capturedByArrowFunction = false; - if (container.kind === 158) { + if (container.kind === 161) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 198) { + if (container.kind === 201) { container = ts.getThisContainer(container, false); capturedByArrowFunction = true; } switch (container.kind) { - case 245: + case 248: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 244: + case 247: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 158: + case 161: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 155: - case 154: + case 158: + case 157: if (ts.hasModifier(container, 32)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 150: + case 153: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -40494,19 +43075,15 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } else if (isInJS && - (container.kind === 197 || container.kind === 240) && + (container.kind === 200 || container.kind === 243) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -40534,8 +43111,21 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { - if (container.kind === 197 && + if (container.kind === 200 && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3) { return container.parent @@ -40543,20 +43133,20 @@ var ts; .expression .expression; } - else if (container.kind === 157 && - container.parent.kind === 189 && + else if (container.kind === 160 && + container.parent.kind === 192 && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6) { return container.parent.parent.left.expression; } - else if (container.kind === 197 && - container.parent.kind === 276 && - container.parent.parent.kind === 189 && + else if (container.kind === 200 && + container.parent.kind === 279 && + container.parent.parent.kind === 192 && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) { return container.parent.parent.parent.left.expression; } - else if (container.kind === 197 && + else if (container.kind === 200 && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && @@ -40578,7 +43168,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295) { + if (jsdocType && jsdocType.kind === 298) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -40592,14 +43182,14 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 198) { + while (container && container.kind === 201) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -40607,14 +43197,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 === 150; }); - if (current && current.kind === 150) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153; }); + if (current && current.kind === 153) { 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 === 189)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -40622,7 +43212,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158) { + if (!isCallExpression && container.kind === 161) { 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) { @@ -40632,7 +43222,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 157 && ts.hasModifier(container, 256)) { + if (container.kind === 160 && ts.hasModifier(container, 256)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -40643,7 +43233,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189) { + if (container.parent.kind === 192) { 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; @@ -40662,7 +43252,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } @@ -40674,24 +43264,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 158; + return container.kind === 161; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 189) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192) { if (ts.hasModifier(container, 32)) { - return container.kind === 157 || - container.kind === 156 || + return container.kind === 160 || container.kind === 159 || - container.kind === 160; + container.kind === 162 || + container.kind === 163; } else { - return container.kind === 157 || - container.kind === 156 || + return container.kind === 160 || container.kind === 159 || - container.kind === 160 || - container.kind === 155 || - container.kind === 154 || - container.kind === 158; + container.kind === 162 || + container.kind === 163 || + container.kind === 158 || + container.kind === 157 || + container.kind === 161; } } } @@ -40699,14 +43289,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 || - func.kind === 159 || - func.kind === 160) && func.parent.kind === 189 ? func.parent : - func.kind === 197 && func.parent.kind === 276 ? func.parent.parent : + return (func.kind === 160 || + func.kind === 162 || + func.kind === 163) && func.parent.kind === 192 ? func.parent : + func.kind === 200 && func.parent.kind === 279 ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -40714,7 +43304,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198) { + if (func.kind === 201) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -40738,7 +43328,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276) { + if (literal.parent.kind !== 279) { break; } literal = literal.parent.parent; @@ -40747,9 +43337,9 @@ var ts; return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral)); } var parent = func.parent; - if (parent.kind === 205 && parent.operatorToken.kind === 60) { + if (parent.kind === 208 && parent.operatorToken.kind === 62) { var target = parent.left; - if (target.kind === 190 || target.kind === 191) { + if (target.kind === 193 || target.kind === 194) { var expression = target.expression; if (inJs && ts.isIdentifier(expression)) { var sourceFile = ts.getSourceFileOfNode(parent); @@ -40806,9 +43396,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152: + case 155: return getContextuallyTypedParameterType(declaration, false); - case 187: + case 190: return getContextualTypeForBindingElement(declaration); } } @@ -40889,6 +43479,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { var returnType = getReturnTypeFromAnnotation(functionDecl); if (returnType) { @@ -40913,7 +43512,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194) { + if (template.parent.kind === 197) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -40922,7 +43521,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60: + case 62: if (node !== right) { return undefined; } @@ -40931,11 +43530,12 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55: + case 56: + case 60: var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54: + case 55: case 27: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -40959,19 +43559,22 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415, undefined, id.escapedText, true); + var parentSymbol = resolveName(id, id.escapedText, 111551, undefined, id.escapedText, true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -40993,12 +43596,13 @@ var ts; } if (kind === 2) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7: case 8: case 9: @@ -41039,7 +43643,7 @@ var ts; } function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608) { + if (node.flags & 16777216) { return undefined; } return getContextualTypeForObjectLiteralElement(node, contextFlags); @@ -41112,30 +43716,33 @@ var ts; case 8: case 9: case 14: - case 103: - case 88: - case 97: - case 73: - case 142: + case 105: + case 90: + case 99: + case 75: + case 145: return true; - case 190: - case 196: + case 193: + case 199: return isPossiblyDiscriminantValue(node.expression); - case 271: + case 274: 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 === 276 && 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 === 279 && 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 === 268 && 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 === 271 && 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, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType && !(contextFlags && contextFlags & 2 && instantiatedType.flags & 8650752)) { + var apparentType = mapType(instantiatedType, getApparentType, true); if (apparentType.flags & 1048576) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -41174,7 +43781,7 @@ var ts; return type; } function getContextualType(node, contextFlags) { - if (node.flags & 8388608) { + if (node.flags & 16777216) { return undefined; } if (node.contextualType) { @@ -41182,56 +43789,56 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238: - case 152: + case 241: case 155: - case 154: - case 187: + case 158: + case 157: + case 190: return getContextualTypeForInitializerExpression(node); - case 198: - case 231: + case 201: + case 234: return getContextualTypeForReturnExpression(node); - case 208: + case 211: return getContextualTypeForYieldOperand(parent); - case 202: + case 205: return getContextualTypeForAwaitOperand(parent); - case 192: - if (parent.expression.kind === 93) { + case 195: + if (parent.expression.kind === 95) { return stringType; } - case 193: + case 196: return getContextualTypeForArgument(parent, node); - case 195: - case 213: + case 198: + case 216: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205: + case 208: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276: - case 277: + case 279: + case 280: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278: + case 281: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188: { + case 191: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206: + case 209: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217: - ts.Debug.assert(parent.parent.kind === 207); + case 220: + ts.Debug.assert(parent.parent.kind === 210); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196: { + case 199: { var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 271: + case 274: return getContextualTypeForJsxExpression(parent); - case 268: - case 270: + case 271: + case 273: return getContextualTypeForJsxAttribute(parent); - case 263: - case 262: + case 266: + case 265: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -41369,7 +43976,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 || node.kind === 198; + return node.kind === 200 || node.kind === 201; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -41377,14 +43984,12 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1) : - getApparentTypeOfContextualType(node, 1); + var type = getApparentTypeOfContextualType(node, 1); if (!type) { return undefined; } @@ -41393,8 +43998,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -41420,8 +44025,8 @@ var ts; return checkIteratedTypeOrElementType(33, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 && !!node.initializer) || - (node.kind === 205 && node.operatorToken.kind === 60); + return (node.kind === 190 && !!node.initializer) || + (node.kind === 208 && node.operatorToken.kind === 62); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -41433,7 +44038,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209) { + if (inDestructuringPattern && e.kind === 212) { var restArrayType = checkExpression(e.expression, checkMode, forceTuple); var restElementType = getIndexTypeOfType(restArrayType, 1) || getIteratedTypeOrElementType(65, restArrayType, undefinedType, undefined, false); @@ -41446,12 +44051,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209) { + if (index < elementCount - 1 && e.kind === 212) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212; var minLength = elementCount - (hasRestElement ? 1 : 0); var tupleResult = void 0; if (inDestructuringPattern && minLength > 0) { @@ -41490,9 +44095,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150: + case 153: return isNumericComputedName(name); - case 73: + case 75: return isNumericLiteralName(name.escapedText); case 8: case 10: @@ -41554,7 +44159,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 || contextualType.pattern.kind === 189); + (contextualType.pattern.kind === 188 || contextualType.pattern.kind === 192); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -41569,13 +44174,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 === 150 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 || - memberDecl.kind === 277 || + if (memberDecl.kind === 279 || + memberDecl.kind === 280 || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -41596,8 +44201,8 @@ var ts; prop.nameType = nameType; } if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 276 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } @@ -41620,7 +44225,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278) { + else if (memberDecl.kind === 281) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } @@ -41641,7 +44246,7 @@ var ts; continue; } else { - ts.Debug.assert(memberDecl.kind === 159 || memberDecl.kind === 160); + ts.Debug.assert(memberDecl.kind === 162 || memberDecl.kind === 163); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576)) { @@ -41699,7 +44304,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 | 67108864 | 524288 | 58982400) || + if (type.flags & 63176704) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 | 67108864 | 524288 | 58982400) || getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 && ts.every(type.types, isValidSpreadType)); } @@ -41738,7 +44349,7 @@ var ts; return !ts.stringContains(name, "-"); } function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 73 && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -41774,7 +44385,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270); + ts.Debug.assert(attributeDecl.kind === 273); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false); attributesTable = ts.createSymbolTable(); @@ -41796,7 +44407,7 @@ var ts; spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false); } } - var parent = openingLikeElement.parent.kind === 261 ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 ? openingLikeElement.parent : undefined; if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { @@ -41852,7 +44463,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832); + var typeSymbol = exports && getSymbol(exports, name, 788968); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } function getIntrinsicTagSymbol(node) { @@ -41908,7 +44519,7 @@ var ts; return getGlobalSymbol(JsxNames.JSX, 1920, undefined); } function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968); var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType); if (propertiesOfJsxElementAttribPropInterface) { @@ -41925,7 +44536,7 @@ var ts; return undefined; } function getJsxLibraryManagedAttributes(jsxNamespace) { - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968); } function getJsxElementPropertiesName(jsxNamespace) { return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace); @@ -42052,10 +44663,10 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415, reactRefErr, reactNamespace, true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551, reactRefErr, reactNamespace, true); if (reactSym) { reactSym.isReferenced = 67108863; - if (reactSym.flags & 2097152 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + if (reactSym.flags & 2097152) { markAliasSymbolAsReferenced(reactSym); } } @@ -42118,7 +44729,7 @@ var ts; } function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 ? node.right : node.kind === 184 ? node : node.name; + var errorNode = node.kind === 152 ? node.right : node.kind === 187 ? node : node.name; if (ts.getCheckFlags(prop) & 1024) { error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); return false; @@ -42191,12 +44802,11 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304); + } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (strictNullChecks && type.flags & 2) { @@ -42228,14 +44838,13 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196) { + while (node.parent.kind === 199) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + var _a = checkOptionalExpression(node, left), isOptional = _a.isOptional, leftType = _a.type; var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -42249,6 +44858,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -42276,9 +44886,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101); + markPropertyAsReferenced(prop, node, left.kind === 103); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -42287,21 +44897,21 @@ var ts; } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return propagateOptionalTypeMarker(getFlowTypeOfAccessExpression(node, prop, propType, right), isOptional); } function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 && node.kind !== 190 || + if (node.kind !== 194 && node.kind !== 193 || assignmentKind === 1 || prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) { return propType; } var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 101) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -42321,7 +44931,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -42331,9 +44941,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 && - node.parent.kind !== 165 && - !(valueDeclaration.flags & 4194304) && + else if (valueDeclaration.kind === 244 && + node.parent.kind !== 168 && + !(valueDeclaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -42344,22 +44954,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155: + case 158: return true; - case 276: - case 157: - case 159: + case 279: case 160: - case 278: - case 150: - case 217: - case 271: - case 268: - case 269: - case 270: - case 263: - case 212: + case 162: + case 163: + case 281: + case 153: + case 220: case 274: + case 271: + case 272: + case 273: + case 266: + case 215: + case 277: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -42395,7 +45005,7 @@ var ts; 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)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -42433,7 +45043,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -42508,16 +45118,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190: - return isValidPropertyAccessWithType(node, node.expression.kind === 99, propertyName, getWidenedType(checkExpression(node.expression))); - case 149: + case 193: + return isValidPropertyAccessWithType(node, node.expression.kind === 101, propertyName, getWidenedType(checkExpression(node.expression))); + case 152: return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left))); - case 184: + case 187: return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 && node.expression.kind === 99, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 && node.expression.kind === 101, property.escapedName, type); } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { if (type === errorType || isTypeAny(type)) { @@ -42529,13 +45139,13 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239) { + if (initializer.kind === 242) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73) { + else if (initializer.kind === 75) { return getResolvedSymbol(initializer); } return undefined; @@ -42545,13 +45155,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73) { + if (e.kind === 75) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 && + if (node.kind === 230 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -42565,28 +45175,14 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + var _a = checkOptionalExpression(node, node.expression), isOptional = _a.isOptional, exprType = _a.type; var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 && 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); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -42595,7 +45191,7 @@ var ts; 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) : 0; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); + return propagateOptionalTypeMarker(checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node), isOptional); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === errorType) { @@ -42634,13 +45230,13 @@ var ts; if (callLikeExpressionMayHaveTypeArguments(node)) { ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194) { + if (node.kind === 197) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153) { + else if (node.kind !== 156) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -42651,7 +45247,7 @@ var ts; resolveUntypedCall(node); return unknownSignature; } - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -42659,8 +45255,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -42685,11 +45281,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? createOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 || arg.kind === 216 && arg.isSpread); + return !!arg && (arg.kind === 212 || arg.kind === 219 && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -42703,9 +45299,9 @@ var ts; var callIsIncomplete = false; var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194) { + if (node.kind === 197) { argCount = args.length; - if (node.template.kind === 207) { + if (node.template.kind === 210) { var lastSpan = ts.last(node.template.templateSpans); callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } @@ -42715,7 +45311,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153) { + else if (node.kind === 156) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -42729,7 +45325,7 @@ var ts; } else { if (!node.arguments) { - ts.Debug.assert(node.kind === 193); + ts.Debug.assert(node.kind === 196); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -42805,7 +45401,7 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { return inferJsxTypeArguments(node, signature, checkMode, context); } - if (node.kind !== 153) { + if (node.kind !== 156) { var contextualType = getContextualType(node); if (contextualType) { var outerContext = getInferenceContext(node); @@ -42820,7 +45416,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -42833,7 +45429,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 !== 211) { + if (arg.kind !== 214) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -42855,7 +45451,7 @@ var ts; if (index >= argCount - 1) { var arg = args[argCount - 1]; if (isSpreadArgument(arg)) { - return arg.kind === 216 ? + return arg.kind === 219 ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0)); } @@ -42920,19 +45516,19 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193) { + if (thisType && thisType !== voidType && node.kind !== 196) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -42940,14 +45536,14 @@ 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 !== 211) { + if (arg.kind !== 214) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, undefined, checkMode); var checkArgType = checkMode & 4 ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -42957,7 +45553,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -42974,32 +45570,32 @@ var ts; } } function getThisArgumentOfCall(node) { - if (node.kind === 192) { + if (node.kind === 195) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 || callee.kind === 191) { + if (callee.kind === 193 || callee.kind === 194) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216, parent.pos, parent.end); + var result = ts.createNode(219, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; return result; } function getEffectiveCallArguments(node) { - if (node.kind === 194) { + if (node.kind === 197) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207) { + if (template.kind === 210) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153) { + if (node.kind === 156) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -43011,7 +45607,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -43023,23 +45619,23 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241: - case 210: + case 244: + case 213: return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 152: + case 155: var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 158 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155: - case 157: - case 159: + case 158: case 160: - var hasPropDesc = parent.kind !== 155 && languageVersion !== 0; + case 162: + case 163: + var hasPropDesc = parent.kind !== 158 && languageVersion !== 0; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -43050,16 +45646,16 @@ var ts; } function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241: - case 210: + case 244: + case 213: return 1; - case 155: + case 158: return 2; - case 157: - case 159: case 160: + case 162: + case 163: return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3; - case 152: + case 155: return 3; default: return ts.Debug.fail(); @@ -43097,8 +45693,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -43165,8 +45761,8 @@ var ts; } var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -43181,20 +45777,20 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194; - var isDecorator = node.kind === 153; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197; + var isDecorator = node.kind === 156; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 99) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -43208,7 +45804,7 @@ var ts; var candidateForArgumentArityError; var candidateForTypeArgumentError; var result; - var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 192 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 195 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -43247,7 +45843,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2); if (diags_2) { @@ -43265,7 +45861,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -43385,7 +45981,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { + var _loop_15 = function (i) { var symbols = ts.mapDefined(candidates, function (_a) { var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; return hasRestParameter ? @@ -43396,7 +45992,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); var hasRestParameter = restParameterSymbols.length !== 0; @@ -43462,7 +46058,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -43475,12 +46071,12 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var _b = checkOptionalExpression(node, node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined), isOptional = _b.isOptional, funcType = _b.type; if (funcType === silentNeverType) { return silentNeverSignature; } @@ -43520,7 +46116,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -43560,11 +46156,11 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, false); } var callSignatures = getSignaturesOfType(expressionType, 0); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -43646,8 +46242,8 @@ var ts; if (apparentType.flags & 1048576) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var constituent = types_16[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -43731,20 +46327,20 @@ var ts; invocationError(node.tag, apparentType, 0); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, false); } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241: - case 210: + case 244: + case 213: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152: - return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; case 155: + return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; + case 158: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157: - case 159: case 160: + case 162: + case 163: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -43778,14 +46374,14 @@ var ts; invocationErrorRecovery(apparentType, 0, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, false, 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(121)); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node); + var declaration = ts.createFunctionTypeNode(undefined, [ts.createParameter(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, undefined) : ts.createKeywordTypeNode(124)); var parameterSymbol = createSymbol(1, "props"); parameterSymbol.type = result; return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, false, false); @@ -43810,7 +46406,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, false); } function isPotentiallyUncalledDecorator(decorator, signatures) { return signatures.length && ts.every(signatures, function (signature) { @@ -43821,16 +46417,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192: + case 195: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193: + case 196: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194: + case 197: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153: + case 156: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263: - case 262: + case 266: + case 265: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -43859,57 +46455,52 @@ var ts; if (ts.getJSDocClassTag(node)) return true; var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function isJSConstructorType(type) { - if (type.flags & 524288) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); - } - return false; - } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190) { + while (parent && parent.kind === 193) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - } - return links.inferredClassType; - } function checkCallExpression(node, checkMode) { if (!checkGrammarTypeArguments(node, node.typeArguments)) checkGrammarArguments(node.arguments); @@ -43917,15 +46508,15 @@ var ts; if (signature === resolvingSignature) { return nonInferrableType; } - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { return voidType; } - if (node.kind === 193) { + if (node.kind === 196) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 && - declaration.kind !== 162 && - declaration.kind !== 167 && + declaration.kind !== 161 && + declaration.kind !== 165 && + declaration.kind !== 170 && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { if (noImplicitAny) { @@ -43941,18 +46532,28 @@ var ts; if (returnType.flags & 12288 && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 && node.parent.kind === 225 && + returnType.flags & 16384 && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -43968,7 +46569,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415, undefined, undefined, false); + return globalESSymbol === resolveName(left, "Symbol", 111551, undefined, undefined, false); } function checkImportCallExpression(node) { if (!checkGrammarArguments(node.arguments)) @@ -43986,7 +46587,7 @@ var ts; } var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true, false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -44024,7 +46625,7 @@ var ts; } if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415, undefined, undefined, true); + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, true); if (resolvedRequire === requireSymbol) { return true; } @@ -44032,18 +46633,19 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 240 + ? 243 : resolvedRequire.flags & 3 - ? 238 + ? 241 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); - return !!decl && !!(decl.flags & 4194304); + return !!decl && !!(decl.flags & 8388608); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2) { checkExternalEmitHelpers(node, 131072); } @@ -44058,20 +46660,20 @@ var ts; case 14: case 8: case 9: - case 103: - case 88: - case 188: - case 189: + case 105: + case 90: + case 191: + case 192: return true; - case 196: + case 199: return isValidConstAssertionArgument(node.expression); - case 203: + case 206: var op = node.operator; var arg = node.operand; - return op === 39 && (arg.kind === 8 || arg.kind === 9) || - op === 38 && arg.kind === 8; - case 190: - case 191: + return op === 40 && (arg.kind === 8 || arg.kind === 9) || + op === 39 && arg.kind === 8; + case 193: + case 194: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -44107,10 +46709,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96) { + if (node.keywordToken === 98) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93) { + if (node.keywordToken === 95) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -44121,7 +46723,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 === 158) { + else if (container.kind === 161) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -44131,11 +46733,11 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -44174,7 +46776,7 @@ var ts; if (signature.hasRestParameter) { var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -44206,7 +46808,7 @@ var ts; if (signature.hasRestParameter) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; @@ -44297,7 +46899,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 === 73) { + if (element.name.kind === 75) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -44311,7 +46913,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73) { + if (decl.name.kind !== 75) { if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -44361,7 +46963,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219) { + if (func.body.kind !== 222) { returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8); if (isAsync) { returnType = checkAwaitedType(returnType, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -44426,7 +47028,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2, func) || unknownType, isAsync); } else { return isAsync @@ -44509,15 +47111,16 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203) { 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 & 131072); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -44530,13 +47133,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } function checkAndAggregateReturnExpressionTypes(func, checkMode) { var functionFlags = ts.getFunctionFlags(func); @@ -44570,11 +47167,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197: - case 198: + case 200: + case 201: return true; - case 157: - return func.parent.kind === 189; + case 160: + return func.parent.kind === 192; default: return false; } @@ -44588,10 +47185,10 @@ var ts; if (type && maybeTypeOfKind(type, 1 | 16384)) { return; } - if (func.kind === 156 || ts.nodeIsMissing(func.body) || func.body.kind !== 219 || !functionHasImplicitReturn(func)) { + if (func.kind === 159 || ts.nodeIsMissing(func.body) || func.body.kind !== 222 || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256; + var hasExplicitReturn = func.flags & 512; if (type && type.flags & 131072) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -44615,7 +47212,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (checkMode && checkMode & 4 && isContextSensitive(node)) { if (!ts.getEffectiveReturnTypeNode(node) && hasContextSensitiveReturnExpression(node)) { @@ -44632,7 +47229,7 @@ var ts; return anyFunctionType; } var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197) { + if (!hasGrammarError && node.kind === 200) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -44682,7 +47279,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -44690,7 +47287,7 @@ var ts; if (!ts.getEffectiveReturnTypeNode(node)) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219) { + if (node.body.kind === 222) { checkSourceElement(node.body); } else { @@ -44755,10 +47352,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 190 || expr.kind === 191) && - expr.expression.kind === 101) { + (expr.kind === 193 || expr.kind === 194) && + expr.expression.kind === 103) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158)) { + if (!(func && func.kind === 161)) { return true; } return !symbol.valueDeclaration || !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); @@ -44768,30 +47365,34 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 || expr.kind === 191) { + if (expr.kind === 193 || expr.kind === 194) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73) { + if (node.kind === 75) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252; + return !!declaration && declaration.kind === 255; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { var node = ts.skipOuterExpressions(expr, 2 | 1); - if (node.kind !== 73 && node.kind !== 190 && node.kind !== 191) { + if (node.kind !== 75 && node.kind !== 193 && node.kind !== 194) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 && expr.kind !== 191) { + if (expr.kind !== 193 && expr.kind !== 194) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -44812,13 +47413,13 @@ var ts; } function checkAwaitExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 16384)) { + if (!(node.flags & 32768)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158) { + if (func && func.kind !== 161) { ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -44831,7 +47432,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3)) { + addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -44841,14 +47446,14 @@ var ts; switch (node.operand.kind) { case 8: switch (node.operator) { - case 39: + case 40: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38: + case 39: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9: - if (node.operator === 39) { + if (node.operator === 40) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -44856,31 +47461,31 @@ var ts; } } switch (node.operator) { - case 38: case 39: - case 53: + case 40: + case 54: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38) { + if (node.operator === 39) { if (maybeTypeOfKind(operandType, 2112)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52: + case 53: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 | 8388608); return facts === 4194304 ? falseType : facts === 8388608 ? trueType : booleanType; - case 44: case 45: + case 46: 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -44893,7 +47498,7 @@ var ts; } 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -44911,8 +47516,8 @@ var ts; } if (type.flags & 3145728) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -44990,7 +47595,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 || property.kind === 277) { + if (property.kind === 279 || property.kind === 280) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -45003,9 +47608,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 ? property : property.initializer, type); } - else if (property.kind === 278) { + else if (property.kind === 281) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -45045,8 +47650,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211) { - if (element.kind !== 209) { + if (element.kind !== 214) { + if (element.kind !== 212) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { var accessFlags = hasDefaultValue(element) ? 8 : 0; @@ -45062,7 +47667,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 && restExpression.operatorToken.kind === 60) { + if (restExpression.kind === 208 && restExpression.operatorToken.kind === 62) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -45078,7 +47683,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277) { + if (exprOrAssignment.kind === 280) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -45092,24 +47697,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 && target.operatorToken.kind === 60) { + if (target.kind === 208 && target.operatorToken.kind === 62) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189) { + if (target.kind === 192) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188) { + if (target.kind === 191) { 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 === 278 ? + var error = target.parent.kind === 281 ? 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)) { + var optionalError = target.parent.kind === 281 ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -45117,50 +47725,50 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73: + case 75: case 10: case 13: - case 194: - case 207: + case 197: + case 210: case 14: case 8: case 9: - case 103: - case 88: - case 97: - case 142: - case 197: - case 210: - case 198: - case 188: - case 189: + case 105: + case 90: + case 99: + case 145: case 200: - case 214: - case 262: - case 261: + case 213: + case 201: + case 191: + case 192: + case 203: + case 217: + case 265: + case 264: return true; - case 206: + case 209: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205: + case 208: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203: - case 204: + case 206: + case 207: switch (node.operator) { - case 52: - case 38: - case 39: case 53: + case 39: + case 40: + case 54: return true; } return false; - case 201: - case 195: - case 213: + case 204: + case 198: + case 216: default: return false; } @@ -45172,15 +47780,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 || left.operatorToken.kind === 55)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 || right.operatorToken.kind === 55)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 && (left.kind === 189 || left.kind === 188)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101); + if (operator === 62 && (left.kind === 192 || left.kind === 191)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103); } var leftType; - if (operator === 54 || operator === 55) { + if (operator === 55 || operator === 56 || operator === 60) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -45188,28 +47808,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40: case 41: - case 63: - case 64: case 42: case 65: - case 43: case 66: - case 39: - case 62: - case 46: + case 43: case 67: - case 47: + case 44: case 68: - case 48: + case 40: + case 64: + case 47: case 69: - case 50: + case 48: + case 70: + case 49: case 71: case 51: + case 73: + case 52: + case 74: + case 50: case 72: - case 49: - case 70: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -45230,16 +47850,16 @@ var ts; !(maybeTypeOfKind(leftType, 2112) || maybeTypeOfKind(rightType, 2112))) { resultType_1 = numberType; } - else if (isTypeAssignableToKind(leftType, 2112) && isTypeAssignableToKind(rightType, 2112)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48: - case 69: + case 49: + case 71: reportOperatorError(); } resultType_1 = bigintType; } else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112) && isTypeAssignableToKind(awaitedRight, 2112); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -45247,8 +47867,8 @@ var ts; } return resultType_1; } - case 38: - case 61: + case 39: + case 63: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -45274,20 +47894,20 @@ var ts; } if (!resultType) { var closeEnoughKind_1 = 296 | 2112 | 132 | 3; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61) { + if (operator === 63) { checkAssignmentOperator(resultType); } return resultType; - case 28: - case 30: + case 29: case 31: case 32: + case 33: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -45296,25 +47916,29 @@ var ts; }); } return booleanType; - case 33: case 34: case 35: case 36: + case 37: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95: + case 97: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94: + case 96: return checkInExpression(left, right, leftType, rightType); - case 54: + case 55: return getTypeFacts(leftType) & 4194304 ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55: + case 56: return getTypeFacts(leftType) & 8388608 ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) : leftType; case 60: + return getTypeFacts(leftType) & 262144 ? + getUnionType([getNonNullableType(leftType), rightType], 2) : + leftType; + case 62: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -45340,6 +47964,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112) && isTypeAssignableToKind(right, 2112); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -45347,7 +47974,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832, undefined, name, false); + var symbol = resolveName(prop.valueDeclaration, name, 788968, undefined, name, false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -45357,7 +47984,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 && node.escapedText === "eval"; + return node.kind === 75 && node.escapedText === "eval"; } function checkForDisallowedESSymbolOperand(operator) { var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288) ? left : @@ -45371,22 +47998,22 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50: - case 71: - return 55; case 51: + case 73: + return 56; + case 52: + case 74: + return 37; + case 50: case 72: - return 36; - case 49: - case 70: - return 54; + return 55; default: return undefined; } } function checkAssignmentOperator(valueType) { if (produceDiagnostics && ts.isAssignmentOperator(operator)) { - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } @@ -45416,17 +48043,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); + } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -45434,12 +48067,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35: - case 33: - typeName = "false"; - break; case 36: case 34: + typeName = "false"; + break; + case 37: + case 35: typeName = "true"; } if (typeName) { @@ -45448,6 +48081,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -45465,7 +48109,7 @@ var ts; } function checkYieldExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 4096) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -45507,12 +48151,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -45529,7 +48168,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; } return node; @@ -45562,12 +48201,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 || node.kind === 213; + return node.kind === 198 || node.kind === 216; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 || @@ -45589,10 +48228,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, false, false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -45636,14 +48275,14 @@ var ts; getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node)); } function checkPropertyAssignment(node, checkMode) { - if (node.name.kind === 150) { + if (node.name.kind === 153) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); } function checkObjectLiteralMethod(node, checkMode) { checkGrammarMethod(node); - if (node.name.kind === 150) { + if (node.name.kind === 153) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -45655,8 +48294,8 @@ var ts; var constructSignature = getSingleSignature(type, 1, true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 : 1, false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8) { @@ -45761,11 +48400,11 @@ var ts; } function getTypeOfExpression(node, cache) { var expr = ts.skipParentheses(node); - if (expr.kind === 192 && expr.expression.kind !== 99 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) { + var _a = checkOptionalExpression(expr, expr.expression), isOptional = _a.isOptional, funcType = _a.type; var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -45797,17 +48436,18 @@ var ts; return type; } function checkConstEnumAccess(node, type) { - var ok = (node.parent.kind === 190 && node.parent.expression === node) || - (node.parent.kind === 191 && node.parent.expression === node) || - ((node.kind === 73 || node.kind === 149) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 && node.parent.exprName === node)); + var ok = (node.parent.kind === 193 && node.parent.expression === node) || + (node.parent.kind === 194 && node.parent.expression === node) || + ((node.kind === 75 || node.kind === 152) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 && node.parent.exprName === node)) || + (node.parent.kind === 261 && (compilerOptions.preserveConstEnums || node.flags & 8388608)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304) { + if (constEnumDeclaration.flags & 8388608) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -45820,14 +48460,23 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { - case 73: + var kind = node.kind; + if (cancellationToken) { + switch (kind) { + case 213: + case 200: + case 201: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 75: return checkIdentifier(node); - case 101: + case 103: return checkThisExpression(node); - case 99: + case 101: return checkSuperExpression(node); - case 97: + case 99: return nullWideningType; case 14: case 10: @@ -45838,81 +48487,81 @@ var ts; case 9: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103: + case 105: return trueType; - case 88: + case 90: return falseType; - case 207: + case 210: return checkTemplateExpression(node); case 13: return globalRegExpType; - case 188: + case 191: return checkArrayLiteral(node, checkMode, forceTuple); - case 189: + case 192: return checkObjectLiteral(node, checkMode); - case 190: + case 193: return checkPropertyAccessExpression(node); - case 149: + case 152: return checkQualifiedName(node); - case 191: + case 194: return checkIndexedAccess(node); - case 192: - if (node.expression.kind === 93) { + case 195: + if (node.expression.kind === 95) { return checkImportCallExpression(node); } - case 193: + case 196: return checkCallExpression(node, checkMode); - case 194: + case 197: return checkTaggedTemplateExpression(node); - case 196: + case 199: return checkParenthesizedExpression(node, checkMode); - case 210: + case 213: return checkClassExpression(node); - case 197: - case 198: - return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); case 200: + case 201: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 203: return checkTypeOfExpression(node); - case 195: - case 213: + case 198: + case 216: return checkAssertion(node); - case 214: + case 217: return checkNonNullAssertion(node); - case 215: + case 218: return checkMetaProperty(node); - case 199: + case 202: return checkDeleteExpression(node); - case 201: + case 204: return checkVoidExpression(node); - case 202: + case 205: return checkAwaitExpression(node); - case 203: + case 206: return checkPrefixUnaryExpression(node); - case 204: + case 207: return checkPostfixUnaryExpression(node); - case 205: + case 208: return checkBinaryExpression(node, checkMode); - case 206: - return checkConditionalExpression(node, checkMode); case 209: + return checkConditionalExpression(node, checkMode); + case 212: return checkSpreadExpression(node, checkMode); - case 211: + case 214: return undefinedWideningType; - case 208: + case 211: return checkYieldExpression(node); - case 216: + case 219: return node.type; - case 271: + case 274: return checkJsxExpression(node, checkMode); - case 261: + case 264: return checkJsxElement(node, checkMode); - case 262: - return checkJsxSelfClosingElement(node, checkMode); case 265: + return checkJsxSelfClosingElement(node, checkMode); + case 268: return checkJsxFragment(node); - case 269: + case 272: return checkJsxAttributes(node, checkMode); - case 263: + case 266: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -45942,7 +48591,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92)) { - if (!(func.kind === 158 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -45953,10 +48602,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 === 158 || func.kind === 162 || func.kind === 167) { + if (func.kind === 161 || func.kind === 165 || func.kind === 170) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198) { + if (func.kind === 201) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -45977,7 +48626,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 || typePredicate.kind === 2) { getTypeFromThisTypeNode(parameterName); } else { @@ -45986,8 +48635,10 @@ var ts; error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, undefined, leadingError); + } } } else if (parameterName) { @@ -46008,13 +48659,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198: - case 161: - case 240: - case 197: - case 166: - case 157: - case 156: + case 201: + case 164: + case 243: + case 200: + case 169: + case 160: + case 159: var parent = node.parent; if (node === parent.type) { return parent; @@ -46028,11 +48679,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 && name.escapedText === predicateVariableName) { + if (name.kind === 75 && 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 === 186 || name.kind === 185) { + else if (name.kind === 189 || name.kind === 188) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -46040,12 +48691,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 163) { + if (node.kind === 166) { checkGrammarIndexSignature(node); } - else if (node.kind === 166 || node.kind === 240 || node.kind === 167 || - node.kind === 161 || node.kind === 158 || - node.kind === 162) { + else if (node.kind === 169 || node.kind === 243 || node.kind === 170 || + node.kind === 164 || node.kind === 161 || + node.kind === 165) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -46070,10 +48721,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162: + case 165: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161: + case 164: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -46097,7 +48748,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 && node.kind !== 295) { + if (node.kind !== 166 && node.kind !== 298) { registerForUnusedIdentifiersCheck(node); } } @@ -46107,10 +48758,10 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158) { + if (member.kind === 161) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { addName(instanceNames, param.name, param.name.escapedText, 3); } } @@ -46122,17 +48773,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159: + case 162: addName(names, name, memberName, 1); break; - case 160: + case 163: addName(names, name, memberName, 2); break; - case 155: + case 158: addName(names, name, memberName, 3); break; - case 157: - addName(names, name, memberName, 4); + case 160: + addName(names, name, memberName, 8); break; } } @@ -46141,8 +48792,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4) { - if (meaning !== 4) { + if (prev & 8) { + if (meaning !== 8) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -46183,7 +48834,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154) { + if (member.kind === 157) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -46191,7 +48842,7 @@ var ts; case 8: memberName = name.text; break; - case 73: + case 75: memberName = ts.idText(name); break; default: @@ -46208,7 +48859,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242) { + if (node.kind === 245) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -46223,7 +48874,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139: + case 142: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -46231,7 +48882,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136: + case 139: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -46253,7 +48904,7 @@ var ts; if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); checkFunctionOrMethodDeclaration(node); - if (ts.hasModifier(node, 128) && node.kind === 157 && node.body) { + if (ts.hasModifier(node, 128) && node.kind === 160 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -46274,7 +48925,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 && + return n.kind === 158 && !ts.hasModifier(n, 32) && !!n.initializer; } @@ -46292,9 +48943,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -46318,18 +48969,18 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159) { - if (!(node.flags & 4194304) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { - if (!(node.flags & 256)) { + if (node.kind === 162) { + if (!(node.flags & 8388608) && ts.nodeIsPresent(node.body) && (node.flags & 256)) { + if (!(node.flags & 512)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 150) { + if (node.name.kind === 153) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { - var otherKind = node.kind === 159 ? 160 : 159; + var otherKind = node.kind === 162 ? 163 : 162; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -46345,7 +48996,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159) { + if (node.kind === 162) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -46393,18 +49044,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 && getNodeLinks(node).resolvedSymbol.flags & 8) { @@ -46440,16 +49089,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173) { + if (e.kind === 176) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172) { + else if (e.kind === 175) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -46469,7 +49118,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) { - if (accessNode.kind === 191 && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -46518,7 +49167,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -46529,14 +49178,14 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8) && !!(node.flags & 4194304); + return ts.hasModifier(node, 8) && !!(node.flags & 8388608); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 242 && - n.parent.kind !== 241 && - n.parent.kind !== 210 && - n.flags & 4194304) { + if (n.parent.kind !== 245 && + n.parent.kind !== 244 && + n.parent.kind !== 213 && + n.flags & 8388608) { if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { flags |= 1; } @@ -46615,7 +49264,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 === 157 || node.kind === 156) && + var reportError = (node.kind === 160 || node.kind === 159) && 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; @@ -46644,15 +49293,19 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304; - var inAmbientContextOrInterface = node.parent.kind === 242 || node.parent.kind === 169 || inAmbientContext; + var inAmbientContext = node.flags & 8388608; + var inAmbientContextOrInterface = node.parent.kind === 245 || node.parent.kind === 172 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 240 || node.kind === 157 || node.kind === 156 || node.kind === 158) { + if ((node.kind === 244 || node.kind === 213) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 243 || node.kind === 160 || node.kind === 159 || node.kind === 161) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -46693,6 +49346,11 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16) { + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); @@ -46703,8 +49361,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -46765,36 +49423,37 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242: - case 243: - case 311: - case 304: - return 2; case 245: + case 246: + case 315: + case 308: + case 309: + return 2; + case 248: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4 | 1 : 4; - case 241: case 244: + case 247: return 2 | 1; - case 285: + case 288: return 2 | 1 | 4; - case 255: + case 258: if (!ts.isEntityNameExpression(d.expression)) { return 1; } d = d.expression; - case 249: case 252: - case 251: + case 255: + case 254: var result_8 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238: - case 187: - case 240: - case 254: + case 241: + case 190: + case 243: + case 257: return 1; default: return ts.Debug.failBadSyntaxKind(d); @@ -46814,7 +49473,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); if (isTypeAny(thenFunction)) { @@ -46842,9 +49501,6 @@ var ts; } function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3)) { - addErrorOrSuggestion(false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -46915,10 +49571,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415, true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) { + if (promiseConstructorName.kind === 75 && 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 { @@ -46935,7 +49591,7 @@ var ts; return; } var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -46953,22 +49609,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241: + case 244: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152: + case 155: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 155: + case 158: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 157: - case 159: case 160: + case 162: + case 163: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -46985,7 +49641,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 ? 67897832 : 1920) | 2097152; + var meaning = (typeName.kind === 75 ? 788968 : 1920) | 2097152; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true); if (rootSymbol && rootSymbol.flags & 2097152 @@ -47003,29 +49659,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175: - case 174: + case 178: + case 177: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176: + case 179: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178: + case 181: return getEntityNameForDecoratorMetadata(node.type); - case 165: + case 168: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178) { + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var typeNode = types_18[_i]; + while (typeNode.kind === 181) { typeNode = typeNode.type; } - if (typeNode.kind === 133) { + if (typeNode.kind === 136) { continue; } - if (!strictNullChecks && (typeNode.kind === 97 || typeNode.kind === 142)) { + if (!strictNullChecks && (typeNode.kind === 99 || typeNode.kind === 145)) { continue; } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -47061,13 +49717,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 152) { + if (node.kind === 155) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 241: + case 244: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -47076,23 +49732,23 @@ var ts; } } break; - case 159: - case 160: - var otherKind = node.kind === 159 ? 160 : 159; + case 162: + case 163: + var otherKind = node.kind === 162 ? 163 : 162; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157: + case 160: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 155: + case 158: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152: + case 155: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -47151,7 +49807,7 @@ var ts; 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 === 149 ? 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 === 152 ? node.name.right : node.name)); } } } @@ -47184,9 +49840,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73: + case 75: return node; - case 190: + case 193: return node.name; default: return undefined; @@ -47196,13 +49852,13 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); - if (node.name && node.name.kind === 150) { + if (node.name && node.name.kind === 153) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { var symbol = getSymbolOfNode(node); var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536); }); + var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072); }); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); } @@ -47212,7 +49868,7 @@ var ts; } } } - var body = node.kind === 156 ? undefined : node.body; + var body = node.kind === 159 ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -47231,7 +49887,7 @@ var ts; } } function registerForUnusedIdentifiersCheck(node) { - if (produceDiagnostics && !(node.flags & 4194304)) { + if (produceDiagnostics && !(node.flags & 8388608)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -47245,42 +49901,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241: - case 210: + case 244: + case 213: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285: - case 245: - case 219: - case 247: - case 226: - case 227: - case 228: + case 288: + case 248: + case 222: + case 250: + case 229: + case 230: + case 231: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158: - case 197: - case 240: - case 198: - case 157: - case 159: + case 161: + case 200: + case 243: + case 201: case 160: + case 162: + case 163: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156: - case 161: - case 162: - case 166: - case 167: - case 243: - case 242: + case 159: + case 164: + case 165: + case 169: + case 170: + case 246: + case 245: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177: + case 180: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -47300,11 +49956,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157: - case 155: - case 159: case 160: - if (member.kind === 160 && member.symbol.flags & 32768) { + case 158: + case 162: + case 163: + if (member.kind === 163 && member.symbol.flags & 32768) { break; } var symbol = getSymbolOfNode(member); @@ -47312,7 +49968,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 158: + case 161: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { @@ -47320,8 +49976,8 @@ var ts; } } break; - case 163: - case 218: + case 166: + case 221: break; default: ts.Debug.fail(); @@ -47345,7 +50001,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) ? ts.rangeOfNode(parent) @@ -47378,7 +50034,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304) + if (nodeWithLocals.flags & 8388608) return; var unusedImports = ts.createMap(); var unusedDestructures = ts.createMap(); @@ -47409,7 +50065,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -47424,7 +50080,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0, unuseds.length === 1 @@ -47442,7 +50098,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 === 238 && bindingPattern.parent.parent.kind === 239) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 && bindingPattern.parent.parent.kind === 242) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -47463,7 +50119,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 === 220 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -47475,23 +50131,23 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73: + case 75: return ts.idText(name); - case 186: - case 185: + case 189: + case 188: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 || node.kind === 254 || node.kind === 252; + return node.kind === 254 || node.kind === 257 || node.kind === 255; } function importClauseFromImported(decl) { - return decl.kind === 251 ? decl : decl.kind === 252 ? decl.parent : decl.parent.parent; + return decl.kind === 254 ? decl : decl.kind === 255 ? decl.parent : decl.parent.parent; } function checkBlock(node) { - if (node.kind === 219) { + if (node.kind === 222) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -47507,7 +50163,7 @@ var ts; } } function checkCollisionWithArgumentsInGeneratedCode(node) { - if (languageVersion >= 2 || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -47520,19 +50176,19 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 || - node.kind === 154 || + if (node.kind === 158 || node.kind === 157 || - node.kind === 156 || + node.kind === 160 || node.kind === 159 || - node.kind === 160) { + node.kind === 162 || + node.kind === 163) { return false; } - if (node.flags & 4194304) { + if (node.flags & 8388608) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -47540,7 +50196,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 73; + var isDeclaration_1 = node.kind !== 75; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -47555,7 +50211,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8) { - var isDeclaration_2 = node.kind !== 73; + var isDeclaration_2 = node.kind !== 75; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -47578,7 +50234,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 285 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 && 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)); } } @@ -47590,7 +50246,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 285 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 288 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048) { 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)); } } @@ -47598,7 +50254,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 238 && !node.initializer) { + if (node.kind === 241 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -47610,15 +50266,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239); - var container = varDeclList.parent.kind === 220 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242); + var container = varDeclList.parent.kind === 224 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 219 && ts.isFunctionLike(container.parent) || - container.kind === 246 || - container.kind === 245 || - container.kind === 285); + (container.kind === 222 && ts.isFunctionLike(container.parent) || + container.kind === 249 || + container.kind === 248 || + container.kind === 288); 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); @@ -47638,17 +50294,17 @@ var ts; if (!node.name) { return; } - if (node.name.kind === 150) { + if (node.name.kind === 153) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187) { - if (node.parent.kind === 185 && languageVersion < 99) { + if (node.kind === 190) { + if (node.parent.kind === 188 && languageVersion < 99) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 150) { + if (node.propertyName && node.propertyName.kind === 153) { checkComputedPropertyName(node.propertyName); } var parent = node.parent.parent; @@ -47661,23 +50317,23 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, undefined, false); - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101, parentType, property); } } } } if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 && languageVersion < 2 && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 && languageVersion < 2 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512); } ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 152 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { var widenedType = getWidenedTypeForVariableLikeDeclaration(node); @@ -47710,7 +50366,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined); } } @@ -47734,9 +50390,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 && node.kind !== 154) { + if (node.kind !== 158 && node.kind !== 157) { checkExportsOnMergedDeclarations(node); - if (node.kind === 238 || node.kind === 187) { + if (node.kind === 241 || node.kind === 190) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -47745,7 +50401,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 || nextDeclaration.kind === 154 + var message = nextDeclaration.kind === 158 || nextDeclaration.kind === 157 ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -47755,8 +50411,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 && right.kind === 238) || - (left.kind === 238 && right.kind === 152)) { + if ((left.kind === 155 && right.kind === 241) || + (left.kind === 241 && right.kind === 155)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -47789,13 +50445,51 @@ var ts; } function checkIfStatement(node) { checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221) { + if (node.thenStatement.kind === 223) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + var callSignatures = getSignaturesOfType(type, 0); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { checkGrammarStatementInAmbientContext(node); checkSourceElement(node.statement); @@ -47815,12 +50509,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239) { + if (node.initializer && node.initializer.kind === 242) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239) { + if (node.initializer.kind === 242) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -47847,18 +50541,18 @@ var ts; else if (compilerOptions.downlevelIteration && languageVersion < 2) { checkExternalEmitHelpers(node, 256); } - if (node.initializer.kind === 239) { + if (node.initializer.kind === 242) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); - if (varExpr.kind === 188 || varExpr.kind === 189) { + if (varExpr.kind === 191 || varExpr.kind === 192) { checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); if (iteratedType) { checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } @@ -47872,7 +50566,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression)); - if (node.initializer.kind === 239) { + if (node.initializer.kind === 242) { 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); @@ -47882,14 +50576,14 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 188 || varExpr.kind === 189) { + if (varExpr.kind === 191 || varExpr.kind === 192) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); } else { - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 | 58982400)) { @@ -48145,12 +50839,12 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; var _a = getIterationTypesOfGlobalIterableType(globalType, resolver), returnType = _a.returnType, nextType = _a.nextType; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } if (isReferenceToType(type, resolver.getGlobalGeneratorType(false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -48189,7 +50883,7 @@ var ts; function getIterationTypesOfIteratorFast(type, resolver) { var globalType = resolver.getGlobalIterableIteratorType(false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || getIterationTypesOfIteratorSlow(globalType, resolver, undefined); var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType; @@ -48197,7 +50891,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -48220,11 +50914,11 @@ var ts; return cachedTypes; } if (isReferenceToType(type, getGlobalIteratorYieldResultType(false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, undefined, undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(undefined, returnType_1, undefined); } var yieldIteratorResult = filterType(type, isYieldIteratorResult); @@ -48270,11 +50964,11 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + nextType = methodParameterType; } else if (methodName === "return") { + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -48348,12 +51042,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160) { + if (func.kind === 163) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158) { + else if (func.kind === 161) { 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); } @@ -48368,13 +51062,13 @@ var ts; } } } - else if (func.kind !== 158 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } function checkWithStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384) { + if (node.flags & 32768) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -48393,7 +51087,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 273 && !hasDuplicateDefaultClause) { + if (clause.kind === 276 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -48405,7 +51099,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272) { + if (produceDiagnostics && clause.kind === 275) { var caseType = checkExpression(clause.expression); var caseIsLiteral = isLiteralType(caseType); var comparedExpressionType = expressionType; @@ -48429,7 +51123,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -48524,8 +51218,8 @@ var ts; } var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 205 || - name.kind === 150 || + (propDeclaration.kind === 208 || + name.kind === 153 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -48590,7 +51284,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165) { + if (node.kind === 168) { var type = getTypeFromTypeReference(node); if (type.flags & 262144) { for (var i = index; i < typeParameters.length; i++) { @@ -48643,10 +51337,8 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } var sourceDefault = source.default && getTypeFromTypeNode(source.default); var targetDefault = getDefaultFromTypeParameter(target); @@ -48681,7 +51373,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304)) { + if (!(node.flags & 8388608)) { checkClassNameCollisionWithObject(node.name); } } @@ -48693,11 +51385,12 @@ var ts; var staticType = getTypeOfSymbol(symbol); checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); - if (!(node.flags & 4194304)) { + if (!(node.flags & 8388608)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2) { checkExternalEmitHelpers(baseTypeNode.parent, 1); } @@ -48733,7 +51426,7 @@ var ts; } 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; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -48775,7 +51468,7 @@ var ts; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -48793,7 +51486,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag); @@ -48816,12 +51509,12 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 || d.kind === 242; + return d.kind === 244 || d.kind === 245; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304) { @@ -48830,43 +51523,87 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - if (derived === base) { - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { - if (derivedClassDecl.kind === 210) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + if (derived === base) { + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { + for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { + var otherBaseType = _b[_a]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } + if (derivedClassDecl.kind === 213) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } - else { - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) { + } + else { + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) { + continue; + } + var errorMessage = void 0; + var basePropertyFlags = base.flags & 98308; + var derivedPropertyFlags = derived.flags & 98308; + if (basePropertyFlags && derivedPropertyFlags) { + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { continue; } - if (isPrototypeProperty(base) || base.flags & 98308 && derived.flags & 98308) { - continue; + if (basePropertyFlags !== 4 && derivedPropertyFlags === 4) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + else if (basePropertyFlags === 4 && derivedPropertyFlags !== 4) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432) + && !(baseDeclarationFlags & 128) + && !(derivedDeclarationFlags & 128) + && !derived.declarations.some(function (d) { return d.flags & 8388608; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } } + continue; } - else if (base.flags & 98304) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived)) { + continue; + } + else if (derived.flags & 98304) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -48903,12 +51640,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -48923,7 +51663,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 && + return node.kind === 158 && !ts.hasModifier(node, 32 | 128) && !node.exclamationToken && !node.initializer; @@ -48945,7 +51685,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -49004,7 +51744,7 @@ var ts; if (member.initializer) { return computeConstantValue(member); } - if (member.parent.flags & 4194304 && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0) { + if (member.parent.flags & 8388608 && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0) { return undefined; } if (autoValue !== undefined) { @@ -49032,7 +51772,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304) { + else if (member.parent.flags & 8388608) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -49041,66 +51781,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203: + case 206: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38: return value_2; - case 39: return -value_2; - case 53: return ~value_2; + case 39: return value_2; + case 40: return -value_2; + case 54: return ~value_2; } } break; - case 205: + case 208: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - 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); + case 51: return left | right; + case 50: return left & right; + case 48: return left >> right; + case 49: return left >>> right; + case 47: return left << right; + case 52: return left ^ right; + case 41: return left * right; + case 43: return left / right; + case 39: return left + right; + case 40: return left - right; + case 44: return left % right; + case 42: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39) { return left + right; } break; case 10: + case 14: return expr.text; case 8: checkGrammarNumericLiteral(expr); return +expr.text; - case 196: + case 199: return evaluate(expr.expression); - case 73: + case 75: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191: - case 190: + case 194: + case 193: 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 === 190) { + if (ex.kind === 193) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -49125,10 +51864,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 || - node.kind === 190 && isConstantMemberAccess(node.expression) || - node.kind === 191 && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10; + return node.kind === 75 || + node.kind === 193 && isConstantMemberAccess(node.expression) || + node.kind === 194 && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -49153,7 +51892,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 244) { + if (declaration.kind !== 247) { return false; } var enumDeclaration = declaration; @@ -49176,9 +51915,9 @@ 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 === 241 || - (declaration.kind === 240 && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304)) { + if ((declaration.kind === 244 || + (declaration.kind === 243 && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608)) { return declaration; } } @@ -49200,7 +51939,7 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304; + var inAmbientContext = node.flags & 8388608; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -49235,7 +51974,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, 241); + var mergedClass = ts.getDeclarationOfKind(symbol, 244); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -49278,22 +52017,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220: + case 224: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255: - case 256: + case 258: + case 259: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249: - case 250: + case 252: + case 253: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187: - case 238: + case 190: + case 241: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -49302,12 +52041,12 @@ var ts; } break; } - case 241: case 244: - case 240: - case 242: - case 245: + case 247: case 243: + case 245: + case 248: + case 246: if (isGlobalAugmentation) { return; } @@ -49323,17 +52062,36 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 73: + case 75: return node; - case 149: + case 152: do { node = node.left; - } while (node.kind !== 73); + } while (node.kind !== 75); return node; - case 190: + case 193: do { node = node.expression; - } while (node.kind !== 73); + } while (node.kind !== 75); + return node; + } + } + function getFirstNonModuleExportsIdentifier(node) { + switch (node.kind) { + case 75: + return node; + case 152: + do { + node = node.left; + } while (node.kind !== 75); + return node; + case 193: + do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } + node = node.expression; + } while (node.kind !== 75); return node; } } @@ -49346,9 +52104,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 ? + var inAmbientExternalModule = node.parent.kind === 249 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -49364,20 +52122,22 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - var excludedMeanings = (symbol.flags & (67220415 | 1048576) ? 67220415 : 0) | - (symbol.flags & 67897832 ? 67897832 : 0) | + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + symbol = getMergedSymbol(symbol.exportSymbol || symbol); + var excludedMeanings = (symbol.flags & (111551 | 1048576) ? 111551 : 0) | + (symbol.flags & 788968 ? 788968 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 ? + var message = node.kind === 261 ? 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 === 258 - && !(target.flags & 67220415) - && !(node.flags & 4194304)) { + && node.kind === 261 + && !(target.flags & 111551) + && !(node.flags & 8388608)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -49401,7 +52161,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252) { + if (importClause.namedBindings.kind === 255) { checkImportBinding(importClause.namedBindings); } else { @@ -49424,22 +52184,22 @@ var ts; if (ts.hasModifier(node, 1)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260) { + if (node.moduleReference.kind !== 263) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415) { + if (target.flags & 111551) { var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 | 1920).flags & 1920)) { + if (!(resolveEntityName(moduleName, 111551 | 1920).flags & 1920)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832) { + if (target.flags & 788968) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608)) { grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } @@ -49455,10 +52215,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 && - !node.moduleSpecifier && node.flags & 4194304; - if (node.parent.kind !== 285 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 && + !node.moduleSpecifier && node.flags & 8388608; + if (node.parent.kind !== 288 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -49474,7 +52234,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 || node.parent.kind === 246 || node.parent.kind === 245; + var isInAppropriateContext = node.parent.kind === 288 || node.parent.kind === 249 || node.parent.kind === 248; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -49487,12 +52247,16 @@ var ts; } if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 | 67897832 | 1920 | 2097152, undefined, undefined, true); + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, undefined, true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -49500,8 +52264,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 285 ? node.parent : node.parent.parent; - if (container.kind === 245 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 ? node.parent : node.parent.parent; + if (container.kind === 248 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -49513,8 +52277,16 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73) { - markExportAsReferenced(node); + if (node.expression.kind === 75) { + var id = node.expression; + var sym = resolveEntityName(id, 67108863, true, true, node); + if (sym) { + markAliasReferenced(sym, id); + var target = sym.flags & 2097152 ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551) { + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, true); } @@ -49523,10 +52295,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304)) { + if (node.isExportEquals && !(node.flags & 8388608)) { if (moduleKind >= ts.ModuleKind.ES2015) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); } @@ -49549,9 +52321,9 @@ var ts; error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } } - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -49576,13 +52348,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 && declaration.kind !== 157) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -49602,157 +52367,161 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { + case 248: + case 244: case 245: - case 241: - case 242: - case 240: + case 243: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 && kind <= 240 && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151: + case 154: return checkTypeParameter(node); - case 152: - return checkParameter(node); case 155: - case 154: + return checkParameter(node); + case 158: + case 157: return checkPropertyDeclaration(node); + case 169: + case 170: + case 164: + case 165: case 166: - case 167: - case 161: - case 162: - case 163: return checkSignatureDeclaration(node); - case 157: - case 156: + case 160: + case 159: return checkMethodDeclaration(node); - case 158: + case 161: return checkConstructorDeclaration(node); - case 159: - case 160: + case 162: + case 163: return checkAccessorDeclaration(node); - case 165: + case 168: return checkTypeReferenceNode(node); - case 164: + case 167: return checkTypePredicate(node); - case 168: + case 171: return checkTypeQuery(node); - case 169: + case 172: return checkTypeLiteral(node); - case 170: + case 173: return checkArrayType(node); - case 171: - return checkTupleType(node); case 174: - case 175: - return checkUnionOrIntersectionType(node); + return checkTupleType(node); + case 177: case 178: - case 172: - case 173: + return checkUnionOrIntersectionType(node); + case 181: + case 175: + case 176: return checkSourceElement(node.type); - case 179: + case 182: return checkThisType(node); - case 180: + case 183: return checkTypeOperator(node); - case 176: + case 179: return checkConditionalType(node); - case 177: + case 180: return checkInferType(node); - case 184: + case 187: return checkImportType(node); - case 301: + case 305: return checkJSDocAugmentsTag(node); - case 311: - case 304: + case 315: + case 308: + case 309: return checkJSDocTypeAliasTag(node); - case 310: + case 314: return checkJSDocTemplateTag(node); - case 309: + case 313: return checkJSDocTypeTag(node); - case 306: + case 310: return checkJSDocParameterTag(node); - case 295: + case 298: checkJSDocFunctionType(node); + case 296: + case 295: case 293: - case 292: - case 290: - case 291: - case 298: + case 294: + case 302: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296: + case 299: checkJSDocVariadicType(node); return; - case 289: + case 292: return checkSourceElement(node.type); - case 181: + case 184: return checkIndexedAccessType(node); - case 182: + case 185: return checkMappedType(node); - case 240: + case 243: return checkFunctionDeclaration(node); - case 219: - case 246: + case 222: + case 249: return checkBlock(node); - case 220: + case 224: return checkVariableStatement(node); - case 222: + case 225: return checkExpressionStatement(node); - case 223: + case 226: return checkIfStatement(node); - case 224: + case 227: return checkDoStatement(node); - case 225: + case 228: return checkWhileStatement(node); - case 226: + case 229: return checkForStatement(node); - case 227: + case 230: return checkForInStatement(node); - case 228: + case 231: return checkForOfStatement(node); - case 229: - case 230: + case 232: + case 233: return checkBreakOrContinueStatement(node); - case 231: + case 234: return checkReturnStatement(node); - case 232: + case 235: return checkWithStatement(node); - case 233: + case 236: return checkSwitchStatement(node); - case 234: + case 237: return checkLabeledStatement(node); - case 235: + case 238: return checkThrowStatement(node); - case 236: + case 239: return checkTryStatement(node); - case 238: + case 241: return checkVariableDeclaration(node); - case 187: + case 190: return checkBindingElement(node); - case 241: + case 244: return checkClassDeclaration(node); - case 242: + case 245: return checkInterfaceDeclaration(node); - case 243: + case 246: return checkTypeAliasDeclaration(node); - case 244: + case 247: return checkEnumDeclaration(node); - case 245: + case 248: return checkModuleDeclaration(node); - case 250: + case 253: return checkImportDeclaration(node); - case 249: + case 252: return checkImportEqualsDeclaration(node); - case 256: + case 259: return checkExportDeclaration(node); - case 255: + case 258: return checkExportAssignment(node); - case 221: - case 237: + case 223: + case 240: checkGrammarStatementInAmbientContext(node); return; - case 259: + case 262: return checkMissingDeclaration(node); } } @@ -49828,23 +52597,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197: - case 198: - case 157: - case 156: + case 200: + case 201: + case 160: + case 159: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159: - case 160: + case 162: + case 163: checkAccessorDeclaration(node); break; - case 210: + case 213: checkClassExpressionDeferred(node); break; - case 262: + case 265: checkJsxSelfClosingElementDeferred(node); break; - case 261: + case 264: checkJsxElementDeferred(node); break; } @@ -49872,7 +52641,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } checkGrammarSourceFile(node); @@ -49944,7 +52713,7 @@ var ts; } } function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608) { + if (location.flags & 16777216) { return []; } var symbols = ts.createSymbolTable(); @@ -49958,27 +52727,27 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285: + case 288: if (!ts.isExternalOrCommonJsModule(location)) break; - case 245: + case 248: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475); break; - case 244: + case 247: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 210: + case 213: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 241: - case 242: + case 244: + case 245: if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968); } break; - case 197: + case 200: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -50010,33 +52779,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 && + return name.kind === 75 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151: - case 241: - case 242: - case 243: + case 154: case 244: + case 245: + case 246: + case 247: return true; default: return false; } } function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149) { + while (node.parent.kind === 152) { node = node.parent; } - return node.parent.kind === 165; + return node.parent.kind === 168; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190) { + while (node.parent.kind === 193) { node = node.parent; } - return node.parent.kind === 212; + return node.parent.kind === 215; } function forEachEnclosingClass(node, callback) { var result; @@ -50064,13 +52833,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149) { + while (nodeOnRightSide.parent.kind === 152) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249) { + if (nodeOnRightSide.parent.kind === 252) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255) { + if (nodeOnRightSide.parent.kind === 258) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -50096,7 +52865,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 && parent.qualifier === node) { + if (parent && parent.kind === 187 && parent.qualifier === node) { return parent; } return undefined; @@ -50106,21 +52875,21 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 && + entityName.parent.kind === 193 && entityName.parent === entityName.parent.parent.left) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 && ts.isEntityNameExpression(entityName)) { - var success = resolveEntityName(entityName, 67220415 | 67897832 | 1920 | 2097152, true); + if (entityName.parent.kind === 258 && ts.isEntityNameExpression(entityName)) { + var success = resolveEntityName(entityName, 111551 | 788968 | 1920 | 2097152, true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 249); + var importEqualsDeclaration = ts.getAncestor(entityName, 252); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -50137,10 +52906,10 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 212) { - meaning = 67897832; + if (entityName.parent.kind === 215) { + meaning = 788968; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415; + meaning |= 111551; } } else { @@ -50152,10 +52921,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306) { + if (entityName.parent.kind === 310) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 && entityName.parent.parent.kind === 310) { + if (entityName.parent.kind === 154 && entityName.parent.parent.kind === 314) { ts.Debug.assert(!ts.isInJSFile(entityName)); var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -50164,19 +52933,19 @@ var ts; if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 73) { + if (entityName.kind === 75) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(entityName, 67220415, false, true); + return resolveEntityName(entityName, 111551, false, true); } - else if (entityName.kind === 190 || entityName.kind === 149) { + else if (entityName.kind === 193 || entityName.kind === 152) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190) { + if (entityName.kind === 193) { checkPropertyAccessExpression(entityName); } else { @@ -50186,21 +52955,21 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 ? 67897832 : 1920; + var meaning = entityName.parent.kind === 168 ? 788968 : 1920; return resolveEntityName(entityName, meaning, false, true); } - if (entityName.parent.kind === 164) { + if (entityName.parent.kind === 167) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285) { + if (node.kind === 288) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608) { + if (node.flags & 16777216) { return undefined; } if (isDeclarationNameOrImportPropertyName(node)) { @@ -50212,12 +52981,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73) { + if (node.kind === 75) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 && - grandParent.kind === 185 && + else if (parent.kind === 190 && + grandParent.kind === 188 && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -50227,11 +52996,11 @@ var ts; } } switch (node.kind) { - case 73: - case 190: - case 149: + case 75: + case 193: + case 152: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101: + case 103: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -50242,20 +53011,20 @@ var ts; if (ts.isInExpressionContext(node)) { return checkExpression(node).symbol; } - case 179: + case 182: return getTypeFromThisTypeNode(node).symbol; - case 99: + case 101: return checkExpression(node).symbol; - case 125: + case 128: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158) { + if (constructorDeclaration && constructorDeclaration.kind === 161) { return constructorDeclaration.parent.symbol; } return undefined; case 10: case 14: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 250 || node.parent.kind === 256) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 || node.parent.kind === 259) && 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); @@ -50270,32 +53039,32 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81: - case 91: - case 37: - case 77: + case 83: + case 93: + case 38: + case 79: return getSymbolOfNode(node.parent); - case 184: + case 187: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86: + case 88: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277) { - return resolveEntityName(location.name, 67220415 | 2097152); + if (location && location.kind === 280) { + return resolveEntityName(location.name, 111551 | 2097152); } return undefined; } function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 | 67897832 | 1920 | 2097152); + resolveEntityName(node.propertyName || node.name, 111551 | 788968 | 1920 | 2097152); } function getTypeOfNode(node) { - if (node.flags & 8388608) { + if (node.flags & 16777216) { return errorType; } var classDecl = ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node); @@ -50340,20 +53109,20 @@ var ts; return errorType; } function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 || expr.kind === 188); - if (expr.parent.kind === 228) { + ts.Debug.assert(expr.kind === 192 || expr.kind === 191); + if (expr.parent.kind === 231) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 205) { + if (expr.parent.kind === 208) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 276) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; @@ -50379,17 +53148,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73: + case 75: return getLiteralType(ts.idText(name)); case 8: case 10: return getLiteralType(name.text); - case 150: + case 153: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } function getAugmentedPropertiesOfType(type) { @@ -50438,7 +53206,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -50454,13 +53222,13 @@ var ts; var symbolLinks = getSymbolLinks(moduleSymbol); if (symbolLinks.exportsSomeValue === undefined) { symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415) + ? !!(moduleSymbol.flags & 111551) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415); + return s && !!(s.flags & 111551); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -50480,7 +53248,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 285) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 288) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -50495,7 +53263,7 @@ var ts; var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); - if (isNonLocalAlias(symbol, 67220415)) { + if (isNonLocalAlias(symbol, 111551)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -50503,7 +53271,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -50512,13 +53280,13 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415, undefined, undefined, false)) { + if (resolveName(container.parent, symbol.escapedName, 111551, undefined, undefined, false)) { links.isDeclarationWithCollidingName = true; } else if (nodeLinks_1.flags & 262144) { var isDeclaredInLoop = nodeLinks_1.flags & 524288; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 219 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 222 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -50554,26 +53322,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249: - case 251: case 252: case 254: - case 258: + case 255: + case 257: + case 261: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256: + case 259: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255: - return node.expression - && node.expression.kind === 73 - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258: + return node.expression && node.expression.kind === 75 ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -50584,7 +53351,7 @@ var ts; if (target === unknownSymbol) { return true; } - return !!(target.flags & 67220415) && + return !!(target.flags & 111551) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -50598,7 +53365,7 @@ var ts; } var target = getSymbolLinks(symbol).target; if (target && ts.getModifierFlags(node) & 1 && - target.flags & 67220415 && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { return true; } } @@ -50640,7 +53407,7 @@ var ts; if (!symbol || !(symbol.flags & 16)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -50659,15 +53426,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279: - case 190: - case 191: + case 282: + case 193: + case 194: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279) { + if (node.kind === 282) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -50691,8 +53458,8 @@ var ts; if (!location) return ts.TypeReferenceSerializationKind.Unknown; } - var valueSymbol = resolveEntityName(typeName, 67220415, true, false, location); - var typeSymbol = resolveEntityName(typeName, 67897832, true, false, location); + var valueSymbol = resolveEntityName(typeName, 111551, true, false, location); + var typeSymbol = resolveEntityName(typeName, 788968, true, false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -50747,7 +53514,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121); + return ts.createToken(124); } var symbol = getSymbolOfNode(declaration); var type = symbol && !(symbol.flags & (2048 | 131072)) @@ -50765,7 +53532,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121); + return ts.createToken(124); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker); @@ -50773,7 +53540,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121); + return ts.createToken(124); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker); @@ -50793,7 +53560,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 | 1048576 | 2097152, undefined, undefined, true); + return resolveName(location, reference.escapedText, 111551 | 1048576 | 2097152, undefined, undefined, true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -50814,7 +53581,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 67220415, enclosing, undefined, tracker) + var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 111551, enclosing, undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -50888,12 +53655,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 === 160 ? 159 : 160; + var otherKind = accessor.kind === 163 ? 162 : 163; 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 === 160 ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -50906,18 +53673,27 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 && node.parent.parent && node.parent.parent.kind === 274; + return node.parent && node.parent.kind === 215 && node.parent.parent && node.parent.parent.kind === 277; } function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } - var meaning = 67897832 | 1920; - if ((node.kind === 73 && isInTypeQuery(node)) || (node.kind === 190 && !isInHeritageClause(node))) { - meaning = 67220415 | 1048576; + var meaning = 788968 | 1920; + if ((node.kind === 75 && isInTypeQuery(node)) || (node.kind === 193 && !isInHeritageClause(node))) { + meaning = 111551 | 1048576; } var symbol = resolveEntityName(node, meaning, true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -50959,7 +53735,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -50986,12 +53762,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 285); + return ts.getDeclarationOfKind(moduleSymbol, 288); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -51104,16 +53880,16 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1; helper <= 131072; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -51159,14 +53935,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 && !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 === 159 || node.kind === 160) { + else if (node.kind === 162 || node.kind === 163) { 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); @@ -51183,23 +53959,23 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 134) { - if (node.kind === 154 || node.kind === 156) { + if (modifier.kind !== 137) { + if (node.kind === 157 || node.kind === 159) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163) { + if (node.kind === 166) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78: - if (node.kind !== 244) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78)); + case 80: + if (node.kind !== 247) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80)); } break; + case 118: + case 117: case 116: - case 115: - case 114: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -51213,11 +53989,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 === 246 || node.parent.kind === 285) { + else if (node.parent.kind === 249 || node.parent.kind === 288) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 114) { + if (modifier.kind === 116) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -51226,7 +54002,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117: + case 119: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -51236,10 +54012,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 === 246 || node.parent.kind === 285) { + else if (node.parent.kind === 249 || node.parent.kind === 288) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152) { + else if (node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -51248,17 +54024,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 134: + case 137: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 && node.kind !== 154 && node.kind !== 163 && node.kind !== 152) { + else if (node.kind !== 158 && node.kind !== 157 && node.kind !== 166 && node.kind !== 155) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 86: + case 88: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -51271,52 +54047,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 === 241) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152) { + else if (node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 81: - var container = node.parent.kind === 285 ? node.parent : node.parent.parent; - if (container.kind === 245 && !ts.isAmbientModule(container)) { + case 83: + var container = node.parent.kind === 288 ? node.parent : node.parent.parent; + if (container.kind === 248 && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512; break; - case 126: + case 129: 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 === 241) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152) { + else if (node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304) && node.parent.kind === 246) { + else if ((node.parent.flags & 8388608) && node.parent.kind === 249) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 119: + case 121: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241) { - if (node.kind !== 157 && - node.kind !== 155 && - node.kind !== 159 && - node.kind !== 160) { + if (node.kind !== 244) { + if (node.kind !== 160 && + node.kind !== 158 && + node.kind !== 162 && + node.kind !== 163) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 && ts.hasModifier(node.parent, 128))) { + if (!(node.parent.kind === 244 && ts.hasModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -51328,14 +54104,14 @@ var ts; } flags |= 128; break; - case 122: + case 125: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 || node.parent.flags & 4194304) { + else if (flags & 2 || node.parent.flags & 8388608) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152) { + else if (node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -51343,7 +54119,7 @@ var ts; break; } } - if (node.kind === 158) { + if (node.kind === 161) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -51358,13 +54134,13 @@ var ts; } return false; } - else if ((node.kind === 250 || node.kind === 249) && flags & 2) { + else if ((node.kind === 253 || node.kind === 252) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 && (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 === 152 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 155 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -51381,38 +54157,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159: - case 160: + case 162: + case 163: + case 161: case 158: - case 155: - case 154: case 157: - case 156: - case 163: - case 245: - case 250: - case 249: - case 256: - case 255: - case 197: - case 198: - case 152: + case 160: + case 159: + case 166: + case 248: + case 253: + case 252: + case 259: + case 258: + case 200: + case 201: + case 155: return false; default: - if (node.parent.kind === 246 || node.parent.kind === 285) { + if (node.parent.kind === 249 || node.parent.kind === 288) { return false; } switch (node.kind) { - case 240: - return nodeHasAnyModifiersExcept(node, 122); - case 241: - return nodeHasAnyModifiersExcept(node, 119); - case 242: - case 220: case 243: - return true; + return nodeHasAnyModifiersExcept(node, 125); case 244: - return nodeHasAnyModifiersExcept(node, 78); + return nodeHasAnyModifiersExcept(node, 121); + case 245: + case 224: + case 246: + return true; + case 247: + return nodeHasAnyModifiersExcept(node, 80); default: ts.Debug.fail(); return false; @@ -51424,10 +54200,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157: - case 240: - case 197: - case 198: + case 160: + case 243: + case 200: + case 201: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -51456,7 +54232,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304)) { + if (!(parameter.flags & 8388608)) { checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -51490,7 +54266,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -51541,7 +54317,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 && parameter.type.kind !== 136) { + if (parameter.type.kind !== 142 && parameter.type.kind !== 139) { 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(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -51572,11 +54348,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211) { + if (arg.kind === 214) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -51606,7 +54388,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 === 87) { + if (heritageClause.token === 89) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -51619,7 +54401,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110); + ts.Debug.assert(heritageClause.token === 112); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -51634,14 +54416,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87) { + if (heritageClause.token === 89) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110); + ts.Debug.assert(heritageClause.token === 112); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -51650,21 +54432,21 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 150) { + if (node.kind !== 153) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 && computedPropertyName.expression.operatorToken.kind === 27) { + if (computedPropertyName.expression.kind === 208 && 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 === 240 || - node.kind === 197 || - node.kind === 157); - if (node.flags & 4194304) { + ts.Debug.assert(node.kind === 243 || + node.kind === 200 || + node.kind === 160); + if (node.flags & 8388608) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -51682,7 +54464,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 === 278) { + if (prop.kind === 281) { if (inDestructuring) { var expression = ts.skipParentheses(prop.expression); if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) { @@ -51692,38 +54474,40 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150) { + if (name.kind === 153) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 && !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 !== 122 || prop.kind !== 157) { + if (mod.kind !== 125 || prop.kind !== 160) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; switch (prop.kind) { - case 277: + case 280: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - case 276: + case 279: checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); } - case 157: + currentKind = 4; + break; + case 160: + currentKind = 8; + break; + case 162: currentKind = 1; break; - case 159: + case 163: currentKind = 2; break; - case 160: - currentKind = 4; - break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); } @@ -51736,11 +54520,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 && existingKind === 1) { + if ((currentKind & 12) && (existingKind & 12)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6) && (existingKind & 6)) { - if (existingKind !== 6 && currentKind !== existingKind) { + else if ((currentKind & 3) && (existingKind & 3)) { + if (existingKind !== 3 && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -51758,7 +54542,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 === 270) { + if (attr.kind === 273) { continue; } var name = attr.name, initializer = attr.initializer; @@ -51768,7 +54552,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 && !initializer.expression) { + if (initializer && initializer.kind === 274 && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -51782,13 +54566,13 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384) === 0) { + if (forInOrOfStatement.kind === 231 && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768) === 0) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158) { + if (func && func.kind !== 161) { ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -51799,7 +54583,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239) { + if (forInOrOfStatement.initializer.kind === 242) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -51807,20 +54591,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 + var diagnostic = forInOrOfStatement.kind === 230 ? 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 === 227 + var diagnostic = forInOrOfStatement.kind === 230 ? 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 === 227 + var diagnostic = forInOrOfStatement.kind === 230 ? 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); @@ -51830,64 +54614,60 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 8388608)) { + if (languageVersion < 1) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128)) { + if (accessor.body && ts.hasModifier(accessor, 128)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 162 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160) { + if (accessor.kind === 163) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 159 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143) { - if (node.type.kind !== 140) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140)); + if (node.operator === 146) { + if (node.type.kind !== 143) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238: + case 241: var decl = parent; - if (decl.name.kind !== 73) { + if (decl.name.kind !== 75) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { @@ -51897,13 +54677,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155: + case 158: 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 154: + case 157: 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); } @@ -51912,9 +54692,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134) { - if (node.type.kind !== 170 && node.type.kind !== 171) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140)); + else if (node.operator === 137) { + if (node.type.kind !== 173 && node.type.kind !== 174) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143)); } } } @@ -51927,9 +54707,9 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157) { - if (node.parent.kind === 189) { - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 122)) { + if (node.kind === 160) { + if (node.parent.kind === 192) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -51947,17 +54727,17 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (node.flags & 4194304) { + if (node.flags & 8388608) { 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 === 157 && !node.body) { + else if (node.kind === 160 && !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 === 242) { + else if (node.parent.kind === 245) { 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 === 169) { + else if (node.parent.kind === 172) { 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); } } @@ -51968,9 +54748,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234: + case 237: if (node.label && current.label.escapedText === node.label.escapedText) { - var isMisplacedContinueLabel = node.kind === 229 + var isMisplacedContinueLabel = node.kind === 232 && !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); @@ -51978,8 +54758,8 @@ var ts; return false; } break; - case 233: - if (node.kind === 230 && !node.label) { + case 236: + if (node.kind === 233 && !node.label) { return false; } break; @@ -51992,13 +54772,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 + var message = node.kind === 233 ? 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 === 230 + var message = node.kind === 233 ? 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); @@ -52020,13 +54800,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 || expr.kind === 8 || - expr.kind === 203 && expr.operator === 39 && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 && expr.operator === 40 && expr.operand.kind === 8; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 || - expr.kind === 203 && expr.operator === 39 && + expr.kind === 206 && expr.operator === 40 && expr.operand.kind === 9; } function isSimpleLiteralEnumReference(expr) { @@ -52039,7 +54819,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 || initializer.kind === 88 || + initializer.kind === 105 || initializer.kind === 90 || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -52056,8 +54836,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 && node.parent.parent.kind !== 228) { - if (node.flags & 4194304) { + if (node.parent.parent.kind !== 230 && node.parent.parent.kind !== 231) { + if (node.flags & 8388608) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -52069,18 +54849,18 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 || !node.type || node.initializer || node.flags & 4194304)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 || !node.type || node.initializer || node.flags & 8388608)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304) && ts.hasModifier(node.parent.parent, 1)) { + !(node.parent.parent.flags & 8388608) && ts.hasModifier(node.parent.parent, 1)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73) { + if (name.kind === 75) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -52097,8 +54877,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73) { - if (name.originalKeywordKind === 112) { + if (name.kind === 75) { + if (name.originalKeywordKind === 114) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -52125,15 +54905,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223: - case 224: - case 225: - case 232: case 226: case 227: case 228: + case 235: + case 229: + case 230: + case 231: return false; - case 234: + case 237: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -52151,12 +54931,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96: + case 98: 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 93: + case 95: 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"); } @@ -52214,7 +54994,7 @@ var ts; return true; } } - else if (node.parent.kind === 242) { + else if (node.parent.kind === 245) { 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; } @@ -52222,7 +55002,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169) { + else if (node.parent.kind === 172) { 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; } @@ -52230,22 +55010,22 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304) { + if (node.flags & 8388608) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 || ts.hasModifier(node, 32 | 128))) { + node.flags & 8388608 || ts.hasModifier(node, 32 | 128))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 242 || - node.kind === 243 || - node.kind === 250 || - node.kind === 249 || - node.kind === 256 || - node.kind === 255 || - node.kind === 248 || + if (node.kind === 245 || + node.kind === 246 || + node.kind === 253 || + node.kind === 252 || + node.kind === 259 || + node.kind === 258 || + node.kind === 251 || ts.hasModifier(node, 2 | 1 | 512)) { return false; } @@ -52254,7 +55034,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 === 220) { + if (ts.isDeclaration(decl) || decl.kind === 224) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -52263,18 +55043,15 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304) { - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } + if (node.flags & 8388608) { var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 219 || node.parent.kind === 246 || node.parent.kind === 285) { + if (node.parent.kind === 222 || node.parent.kind === 249 || node.parent.kind === 288) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -52291,20 +55068,31 @@ 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, 183)) { + else if (ts.isChildOfNodeWithKind(node, 186)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279)) { + else if (ts.isChildOfNodeWithKind(node, 282)) { 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 === 39; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + if (node.numericLiteralFlags & 16 || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -52356,10 +55144,17 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 243 && declaration.kind !== 160) || + !!declaration.body; + } function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254: - case 258: + case 257: + case 261: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -52367,13 +55162,13 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251: - case 249: - case 252: case 254: + case 252: + case 255: + case 257: return true; - case 73: - return decl.parent.kind === 254; + case 75: + return decl.parent.kind === 257; default: return false; } @@ -52495,7 +55290,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73); + var node = createSynthesizedNode(75); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateFlags = 0; @@ -52571,23 +55366,23 @@ var ts; } ts.createToken = createToken; function createSuper() { - return createSynthesizedNode(99); + return createSynthesizedNode(101); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101); + return createSynthesizedNode(103); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97); + return createSynthesizedNode(99); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103); + return createSynthesizedNode(105); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88); + return createSynthesizedNode(90); } ts.createFalse = createFalse; function createModifier(kind) { @@ -52597,43 +55392,43 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1) { - result.push(createModifier(86)); + result.push(createModifier(88)); } if (flags & 2) { - result.push(createModifier(126)); + result.push(createModifier(129)); } if (flags & 512) { - result.push(createModifier(81)); + result.push(createModifier(83)); } if (flags & 2048) { - result.push(createModifier(78)); + result.push(createModifier(80)); } if (flags & 4) { - result.push(createModifier(116)); + result.push(createModifier(118)); } if (flags & 8) { - result.push(createModifier(114)); + result.push(createModifier(116)); } if (flags & 16) { - result.push(createModifier(115)); + result.push(createModifier(117)); } if (flags & 128) { - result.push(createModifier(119)); + result.push(createModifier(121)); } if (flags & 32) { - result.push(createModifier(117)); + result.push(createModifier(119)); } if (flags & 64) { - result.push(createModifier(134)); + result.push(createModifier(137)); } if (flags & 256) { - result.push(createModifier(122)); + result.push(createModifier(125)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; function createQualifiedName(left, right) { - var node = createSynthesizedNode(149); + var node = createSynthesizedNode(152); node.left = left; node.right = asName(right); return node; @@ -52652,7 +55447,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150); + var node = createSynthesizedNode(153); node.expression = parenthesizeForComputedName(expression); return node; } @@ -52664,7 +55459,7 @@ var ts; } ts.updateComputedPropertyName = updateComputedPropertyName; function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151); + var node = createSynthesizedNode(154); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -52680,7 +55475,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152); + var node = createSynthesizedNode(155); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -52704,7 +55499,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153); + var node = createSynthesizedNode(156); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -52716,7 +55511,7 @@ var ts; } ts.updateDecorator = updateDecorator; function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154); + var node = createSynthesizedNode(157); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -52736,12 +55531,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155); + var node = createSynthesizedNode(158); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -52751,8 +55546,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -52760,7 +55555,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156, typeParameters, parameters, type); + var node = createSignatureDeclaration(159, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -52777,7 +55572,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157); + var node = createSynthesizedNode(160); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -52790,6 +55585,35 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -52805,7 +55629,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158); + var node = createSynthesizedNode(161); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -52825,7 +55649,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159); + var node = createSynthesizedNode(162); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52848,7 +55672,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160); + var node = createSynthesizedNode(163); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52869,7 +55693,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161, typeParameters, parameters, type); + return createSignatureDeclaration(164, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -52877,7 +55701,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162, typeParameters, parameters, type); + return createSignatureDeclaration(165, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -52885,7 +55709,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163); + var node = createSynthesizedNode(166); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -52923,21 +55747,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164); + return createTypePredicateNodeWithModifier(undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165); + var node = createSynthesizedNode(168); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -52951,7 +55785,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166, typeParameters, parameters, type); + return createSignatureDeclaration(169, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -52959,7 +55793,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167, typeParameters, parameters, type); + return createSignatureDeclaration(170, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -52967,7 +55801,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168); + var node = createSynthesizedNode(171); node.exprName = exprName; return node; } @@ -52979,7 +55813,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169); + var node = createSynthesizedNode(172); node.members = createNodeArray(members); return node; } @@ -52991,7 +55825,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170); + var node = createSynthesizedNode(173); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -53003,7 +55837,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171); + var node = createSynthesizedNode(174); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -53015,7 +55849,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172); + var node = createSynthesizedNode(175); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -53027,7 +55861,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173); + var node = createSynthesizedNode(176); node.type = type; return node; } @@ -53039,7 +55873,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174, types); + return createUnionOrIntersectionTypeNode(177, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -53047,7 +55881,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175, types); + return createUnionOrIntersectionTypeNode(178, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -53066,7 +55900,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176); + var node = createSynthesizedNode(179); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -53084,7 +55918,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177); + var node = createSynthesizedNode(180); node.typeParameter = typeParameter; return node; } @@ -53096,7 +55930,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184); + var node = createSynthesizedNode(187); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -53114,7 +55948,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178); + var node = createSynthesizedNode(181); node.type = type; return node; } @@ -53126,12 +55960,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179); + return createSynthesizedNode(182); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130; + var node = createSynthesizedNode(183); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -53141,7 +55975,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181); + var node = createSynthesizedNode(184); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -53155,7 +55989,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182); + var node = createSynthesizedNode(185); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -53173,7 +56007,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183); + var node = createSynthesizedNode(186); node.literal = literal; return node; } @@ -53185,7 +56019,7 @@ var ts; } ts.updateLiteralTypeNode = updateLiteralTypeNode; function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185); + var node = createSynthesizedNode(188); node.elements = createNodeArray(elements); return node; } @@ -53197,7 +56031,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186); + var node = createSynthesizedNode(189); node.elements = createNodeArray(elements); return node; } @@ -53209,7 +56043,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187); + var node = createSynthesizedNode(190); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -53227,7 +56061,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188); + var node = createSynthesizedNode(191); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -53241,7 +56075,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189); + var node = createSynthesizedNode(192); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -53255,7 +56089,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190); + var node = createSynthesizedNode(193); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072); @@ -53263,28 +56097,67 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + ts.Debug.assert(!(node.flags & 32), "Cannot update a PropertyAccessChain using updatePropertyAccess. Use updatePropertyAccessChain instead."); return node.expression !== expression || node.name !== name ? updateNode(setEmitFlags(createPropertyAccess(expression, name), ts.getEmitFlags(node)), node) : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193); + node.flags |= 32; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191); + var node = createSynthesizedNode(194); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + ts.Debug.assert(!(node.flags & 32), "Cannot update an ElementAccessChain using updateElementAccess. Use updateElementAccessChain instead."); return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194); + node.flags |= 32; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192); + var node = createSynthesizedNode(195); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -53292,6 +56165,7 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + ts.Debug.assert(!(node.flags & 32), "Cannot update a CallChain using updateCall. Use updateCallChain instead."); return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -53299,8 +56173,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195); + node.flags |= 32; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193); + var node = createSynthesizedNode(196); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -53316,7 +56210,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194); + var node = createSynthesizedNode(197); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -53339,7 +56233,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195); + var node = createSynthesizedNode(198); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -53353,7 +56247,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196); + var node = createSynthesizedNode(199); node.expression = expression; return node; } @@ -53365,7 +56259,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197); + var node = createSynthesizedNode(200); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -53389,12 +56283,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198); + var node = createSynthesizedNode(201); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -53411,7 +56305,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199); + var node = createSynthesizedNode(202); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53423,7 +56317,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200); + var node = createSynthesizedNode(203); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53435,7 +56329,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201); + var node = createSynthesizedNode(204); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53447,7 +56341,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202); + var node = createSynthesizedNode(205); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53459,7 +56353,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203); + var node = createSynthesizedNode(206); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -53472,7 +56366,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204); + var node = createSynthesizedNode(207); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -53485,7 +56379,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205); + var node = createSynthesizedNode(208); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -53502,11 +56396,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206); + var node = createSynthesizedNode(209); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57); + node.colonToken = whenFalse ? colonToken : createToken(58); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -53522,7 +56416,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207); + var node = createSynthesizedNode(210); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -53535,34 +56429,93 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99, false, 0); + } + switch (kind) { + case 14: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14: + case 15: + case 16: + case 17: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -53574,7 +56527,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209); + var node = createSynthesizedNode(212); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -53586,7 +56539,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210); + var node = createSynthesizedNode(213); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -53607,11 +56560,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211); + return createSynthesizedNode(214); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212); + var node = createSynthesizedNode(215); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -53625,7 +56578,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213); + var node = createSynthesizedNode(216); node.expression = expression; node.type = type; return node; @@ -53639,7 +56592,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214); + var node = createSynthesizedNode(217); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -53651,7 +56604,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215); + var node = createSynthesizedNode(218); node.keywordToken = keywordToken; node.name = name; return node; @@ -53664,7 +56617,7 @@ var ts; } ts.updateMetaProperty = updateMetaProperty; function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217); + var node = createSynthesizedNode(220); node.expression = expression; node.literal = literal; return node; @@ -53678,11 +56631,11 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218); + return createSynthesizedNode(221); } ts.createSemicolonClassElement = createSemicolonClassElement; function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219); + var block = createSynthesizedNode(222); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -53696,7 +56649,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220); + var node = createSynthesizedNode(224); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -53711,11 +56664,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221); + return createSynthesizedNode(223); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222); + var node = createSynthesizedNode(225); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -53729,7 +56682,7 @@ var ts; ts.createStatement = createExpressionStatement; ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223); + var node = createSynthesizedNode(226); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -53745,7 +56698,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224); + var node = createSynthesizedNode(227); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -53759,7 +56712,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225); + var node = createSynthesizedNode(228); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -53773,7 +56726,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226); + var node = createSynthesizedNode(229); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -53791,7 +56744,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227); + var node = createSynthesizedNode(230); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -53807,7 +56760,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228); + var node = createSynthesizedNode(231); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -53825,7 +56778,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229); + var node = createSynthesizedNode(232); node.label = asName(label); return node; } @@ -53837,7 +56790,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230); + var node = createSynthesizedNode(233); node.label = asName(label); return node; } @@ -53849,7 +56802,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231); + var node = createSynthesizedNode(234); node.expression = expression; return node; } @@ -53861,7 +56814,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232); + var node = createSynthesizedNode(235); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -53875,7 +56828,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233); + var node = createSynthesizedNode(236); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -53889,7 +56842,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234); + var node = createSynthesizedNode(237); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -53903,7 +56856,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235); + var node = createSynthesizedNode(238); node.expression = expression; return node; } @@ -53915,7 +56868,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236); + var node = createSynthesizedNode(239); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -53931,11 +56884,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237); + return createSynthesizedNode(240); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238); + var node = createSynthesizedNode(241); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -53952,7 +56905,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(239); + var node = createSynthesizedNode(242); node.flags |= flags & 3; node.declarations = createNodeArray(declarations); return node; @@ -53965,7 +56918,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240); + var node = createSynthesizedNode(243); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -53991,7 +56944,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241); + var node = createSynthesizedNode(244); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54013,7 +56966,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242); + var node = createSynthesizedNode(245); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54035,7 +56988,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243); + var node = createSynthesizedNode(246); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54055,7 +57008,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244); + var node = createSynthesizedNode(247); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54074,8 +57027,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(245); - node.flags |= flags & (16 | 4 | 512); + var node = createSynthesizedNode(248); + node.flags |= flags & (16 | 4 | 1024); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -54093,7 +57046,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246); + var node = createSynthesizedNode(249); node.statements = createNodeArray(statements); return node; } @@ -54105,7 +57058,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247); + var node = createSynthesizedNode(250); node.clauses = createNodeArray(clauses); return node; } @@ -54117,7 +57070,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248); + var node = createSynthesizedNode(251); node.name = asName(name); return node; } @@ -54129,7 +57082,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249); + var node = createSynthesizedNode(252); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54147,7 +57100,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250); + var node = createSynthesizedNode(253); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -54165,7 +57118,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251); + var node = createSynthesizedNode(254); node.name = name; node.namedBindings = namedBindings; return node; @@ -54179,7 +57132,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252); + var node = createSynthesizedNode(255); node.name = name; return node; } @@ -54191,7 +57144,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253); + var node = createSynthesizedNode(256); node.elements = createNodeArray(elements); return node; } @@ -54203,7 +57156,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254); + var node = createSynthesizedNode(257); node.propertyName = propertyName; node.name = name; return node; @@ -54217,11 +57170,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255); + var node = createSynthesizedNode(258); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60, expression, false, undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62, expression, false, undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -54234,7 +57187,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256); + var node = createSynthesizedNode(259); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -54251,8 +57204,12 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + function createEmptyExports() { + return createExportDeclaration(undefined, undefined, createNamedExports([]), undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257); + var node = createSynthesizedNode(260); node.elements = createNodeArray(elements); return node; } @@ -54264,7 +57221,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258); + var node = createSynthesizedNode(261); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -54278,7 +57235,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260); + var node = createSynthesizedNode(263); node.expression = expression; return node; } @@ -54290,33 +57247,33 @@ var ts; } ts.updateExternalModuleReference = updateExternalModuleReference; function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289); + var node = createSynthesizedNode(292); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309, "type"); + var tag = createJSDocTag(313, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; } ts.createJSDocTypeTag = createJSDocTypeTag; function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307, "returns"); + var tag = createJSDocTag(311, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; } ts.createJSDocReturnTag = createJSDocReturnTag; function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308, "this"); + var tag = createJSDocTag(312, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306, "param"); + var tag = createJSDocTag(310, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -54325,7 +57282,7 @@ var ts; } ts.createJSDocParamTag = createJSDocParamTag; function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297); + var node = createSynthesizedNode(301); node.comment = comment; node.tags = tags; return node; @@ -54337,7 +57294,7 @@ var ts; return node; } function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261); + var node = createSynthesizedNode(264); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -54353,7 +57310,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262); + var node = createSynthesizedNode(265); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -54369,7 +57326,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263); + var node = createSynthesizedNode(266); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -54385,7 +57342,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264); + var node = createSynthesizedNode(267); node.tagName = tagName; return node; } @@ -54397,7 +57354,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265); + var node = createSynthesizedNode(268); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -54419,11 +57376,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266); + return createSynthesizedNode(269); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267); + return createSynthesizedNode(270); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -54435,7 +57392,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268); + var node = createSynthesizedNode(271); node.name = name; node.initializer = initializer; return node; @@ -54449,7 +57406,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269); + var node = createSynthesizedNode(272); node.properties = createNodeArray(properties); return node; } @@ -54461,7 +57418,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270); + var node = createSynthesizedNode(273); node.expression = expression; return node; } @@ -54473,7 +57430,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271); + var node = createSynthesizedNode(274); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -54486,7 +57443,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272); + var node = createSynthesizedNode(275); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -54500,7 +57457,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273); + var node = createSynthesizedNode(276); node.statements = createNodeArray(statements); return node; } @@ -54512,7 +57469,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274); + var node = createSynthesizedNode(277); node.token = token; node.types = createNodeArray(types); return node; @@ -54525,7 +57482,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275); + var node = createSynthesizedNode(278); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -54539,7 +57496,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276); + var node = createSynthesizedNode(279); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -54554,7 +57511,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277); + var node = createSynthesizedNode(280); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -54568,7 +57525,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278); + var node = createSynthesizedNode(281); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -54580,7 +57537,7 @@ var ts; } ts.updateSpreadAssignment = updateSpreadAssignment; function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279); + var node = createSynthesizedNode(282); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -54600,7 +57557,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285); + var updated = createSynthesizedNode(288); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -54674,28 +57631,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314); + var node = createSynthesizedNode(318); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318); + var node = createSynthesizedNode(322); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317); + var node = createSynthesizedNode(321); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(315); + var node = createSynthesizedNode(319); node.expression = expression; node.original = original; setTextRange(node, original); @@ -54711,7 +57668,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316) { + if (node.kind === 320) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) { @@ -54721,7 +57678,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316); + var node = createSynthesizedNode(320); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -54732,9 +57689,23 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286); + var node = ts.createNode(289); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -54765,7 +57736,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287); + var node = ts.createNode(290); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -54847,8 +57818,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal": - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } case "text": (texts || (texts = [])).push(createUnparsedNode(section, node)); break; @@ -54895,10 +57869,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue": return 280; - case "prepend": return 281; - case "internal": return 283; - case "text": return 282; + case "prologue": return 283; + case "prepend": return 284; + case "internal": return 286; + case "text": return 285; case "emitHelpers": case "no-default-lib": case "reference": @@ -54916,14 +57890,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284, section.pos, section.end); + var node = ts.createNode(287, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288); + var node = ts.createNode(291); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -54969,8 +57943,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -54998,43 +57972,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28, right); + return createBinary(left, 29, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60, right); + return createBinary(left, 62, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35, right); + return createBinary(left, 36, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36, right); + return createBinary(left, 37, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38, right); + return createBinary(left, 39, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39, right); + return createBinary(left, 40, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44); + return createPostfix(operand, 45); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54, right); + return createBinary(left, 55, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55, right); + return createBinary(left, 56, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52, operand); + return createPrefix(53, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -55053,7 +58031,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -55079,7 +58060,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 285) { + if (node.kind === 288) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -55364,9 +58345,9 @@ var ts; } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { - return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, [ + return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -55456,51 +58437,55 @@ var ts; return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location); } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; - function getHelperName(name) { + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), undefined, [expression]), location); + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), undefined, count !== undefined + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); } ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), undefined, argumentList), location); + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), undefined, argumentList), location); + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; function createForOfBindingStatement(node, boundValue) { @@ -55517,7 +58502,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), true); @@ -55528,7 +58513,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -55540,20 +58525,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73: + case 75: return cacheIdentifiers; - case 101: + case 103: case 8: case 9: case 10: return false; - case 188: + case 191: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189: + case 192: return target.properties.length > 0; default: return true; @@ -55568,7 +58553,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99) { + else if (callee.kind === 101) { thisArg = ts.createThis(); target = languageVersion < 2 ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -55580,7 +58565,7 @@ var ts; } else { switch (callee.kind) { - case 190: { + case 193: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); @@ -55592,7 +58577,7 @@ var ts; } break; } - case 191: { + case 194: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); @@ -55645,14 +58630,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159: - case 160: + case 162: + case 163: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276: + case 279: return createExpressionForPropertyAssignment(property, receiver); - case 277: + case 280: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157: + case 160: return createExpressionForMethodDeclaration(property, receiver); } } @@ -55824,8 +58809,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -55848,16 +58833,16 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 196) { + if (skipped.kind === 199) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -55866,10 +58851,10 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(205, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 && binaryOperatorPrecedence > 3) { return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); @@ -55877,7 +58862,7 @@ var ts; case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 208) { + && operand.kind === 211) { return false; } return true; @@ -55893,7 +58878,7 @@ var ts; if (operatorHasAssociativeProperty(binaryOperator)) { return false; } - if (binaryOperator === 38) { + if (binaryOperator === 39) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -55906,32 +58891,30 @@ var ts; } } function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 40 + return binaryOperator === 41 + || binaryOperator === 51 || binaryOperator === 50 - || binaryOperator === 49 - || binaryOperator === 51; + || binaryOperator === 52; } function getLiteralKindOfBinaryPlusOperand(node) { node = ts.skipPartiallyEmittedExpressions(node); if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 && node.operatorToken.kind === 38) { + if (node.kind === 208 && node.operatorToken.kind === 39) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0; node.cachedLiteralKind = literalKind; return literalKind; } return 0; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206, 56); + var conditionalPrecedence = ts.getOperatorPrecedence(209, 57); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { @@ -55952,8 +58935,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, false).kind) { - case 210: - case 197: + case 213: + case 200: needsParens = true; } } @@ -55963,9 +58946,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, true); switch (leftmostExpr.kind) { - case 192: + case 195: return ts.createParen(expression); - case 193: + case 196: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -55976,7 +58959,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -56014,7 +58997,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205, 27); + var commaPrecedence = ts.getOperatorPrecedence(208, 27); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -56025,29 +59008,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 || kind === 198) { + if (kind === 200 || kind === 201) { 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 === 189 || leftmostExpressionKind === 197) { + if (leftmostExpressionKind === 192 || leftmostExpressionKind === 200) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 ? ts.createParenthesizedType(member) : member; + return member.kind === 179 ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174: - case 175: - case 166: - case 167: + case 177: + case 178: + case 169: + case 170: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -56055,9 +59038,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168: + case 171: + case 183: case 180: - case 177: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -56083,27 +59066,27 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204: + case 207: node = node.operand; continue; - case 205: + case 208: node = node.left; continue; - case 206: + case 209: node = node.condition; continue; - case 194: + case 197: node = node.tag; continue; - case 192: + case 195: if (stopAtCallExpressions) { return node; } - case 213: - case 191: - case 190: - case 214: - case 315: + case 216: + case 194: + case 193: + case 217: + case 319: node = node.expression; continue; } @@ -56112,27 +59095,27 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 189)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 192)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 && node.operatorToken.kind === 27 || - node.kind === 316; + return node.kind === 208 && node.operatorToken.kind === 27 || + node.kind === 320; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7; } switch (node.kind) { - case 196: + case 199: return (kinds & 1) !== 0; - case 195: - case 213: - case 214: + case 198: + case 216: + case 217: return (kinds & 2) !== 0; - case 315: + case 319: return (kinds & 4) !== 0; } return false; @@ -56157,7 +59140,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214) { + while (ts.isAssertionExpression(node) || node.kind === 217) { node = node.expression; } return node; @@ -56165,15 +59148,15 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196: return ts.updateParen(outerExpression, expression); - case 195: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214: return ts.updateNonNullExpression(outerExpression, expression); - case 315: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199: return ts.updateParen(outerExpression, expression); + case 198: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217: return ts.updateNonNullExpression(outerExpression, expression); + case 319: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } function isIgnorableParen(node) { - return node.kind === 196 + return node.kind === 199 && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -56198,6 +59181,54 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -56212,8 +59243,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -56235,10 +59266,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 && node.importClause) { + if (node.kind === 253 && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 && node.moduleSpecifier) { + if (node.kind === 259 && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -56301,11 +59332,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276: + case 279: return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277: + case 280: return bindingElement.name; - case 278: + case 281: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -56321,11 +59352,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152: - case 187: + case 155: + case 190: return bindingElement.dotDotDotToken; - case 209: - case 278: + case 212: + case 281: return bindingElement; } return undefined; @@ -56333,7 +59364,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187: + case 190: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) @@ -56341,7 +59372,7 @@ var ts; : propertyName; } break; - case 276: + case 279: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) @@ -56349,7 +59380,7 @@ var ts; : propertyName; } break; - case 278: + case 281: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -56368,11 +59399,11 @@ var ts; } function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185: - case 186: case 188: - return name.elements; case 189: + case 191: + return name.elements; + case 192: return name.properties; } } @@ -56411,11 +59442,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186: - case 188: - return convertToArrayAssignmentPattern(node); - case 185: case 189: + case 191: + return convertToArrayAssignmentPattern(node); + case 188: + case 192: return convertToObjectAssignmentPattern(node); } } @@ -56519,11 +59550,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; function visitParameterList(nodes, visitor, context, nodesVisitor) { @@ -56552,261 +59581,270 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 148) || kind === 179) { + if ((kind > 0 && kind <= 151) || kind === 182) { return node; } switch (kind) { - case 73: + case 75: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149: + case 152: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150: + case 153: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 151: + case 154: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152: + case 155: 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 153: + case 156: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); - case 154: + case 157: 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 155: + case 158: 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 || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156: + case 159: 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 157: + case 160: 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 158: + case 161: 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 159: + case 162: 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 160: + case 163: 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 161: + case 164: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162: + case 165: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163: + case 166: 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 164: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165: + case 167: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166: + case 169: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167: + case 170: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168: + case 171: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169: + case 172: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170: + case 173: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171: + case 174: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172: + case 175: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173: + case 176: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174: + case 177: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175: + case 178: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176: + case 179: 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 177: + case 180: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184: + case 187: 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 178: + case 181: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180: + case 183: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181: + case 184: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182: + case 185: 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 183: + case 186: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); - case 185: + case 188: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186: + case 189: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187: + case 190: 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 188: + case 191: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189: + case 192: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190: + case 193: + if (node.flags & 32) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191: + case 194: + if (node.flags & 32) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192: + case 195: + if (node.flags & 32) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193: + case 196: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194: + case 197: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195: + case 198: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196: + case 199: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197: + case 200: 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 198: + case 201: 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 199: + case 202: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200: + case 203: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201: + case 204: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202: + case 205: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203: + case 206: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204: + case 207: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205: + case 208: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206: + case 209: 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 207: + case 210: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208: + case 211: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209: + case 212: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210: + case 213: 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 212: + case 215: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213: + case 216: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214: + case 217: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215: + case 218: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 217: + case 220: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 219: + case 222: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220: + case 224: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222: + case 225: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223: + case 226: 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 224: + case 227: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225: + case 228: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226: + case 229: 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 227: + case 230: 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 228: + case 231: 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 229: + case 232: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230: + case 233: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231: + case 234: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232: + case 235: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233: + case 236: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234: + case 237: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235: + case 238: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236: + case 239: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238: + case 241: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239: + case 242: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240: + case 243: 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 241: + case 244: 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 242: + case 245: 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 243: + case 246: 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 244: + case 247: 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 245: + case 248: 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 246: + case 249: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247: + case 250: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248: + case 251: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249: + case 252: 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 250: + case 253: 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 251: + case 254: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252: + case 255: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253: + case 256: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254: + case 257: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255: + case 258: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256: + case 259: 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 257: + case 260: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258: + case 261: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 260: + case 263: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); - case 261: + case 264: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262: + case 265: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263: + case 266: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264: + case 267: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265: - return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); case 268: + return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); + case 271: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269: + case 272: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270: + case 273: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271: + case 274: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 272: + case 275: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273: + case 276: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274: + case 277: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275: + case 278: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); - case 276: + case 279: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277: + case 280: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278: + case 281: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 279: + case 282: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 285: + case 288: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 315: + case 319: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316: + case 320: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: return node; @@ -56832,52 +59870,52 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 148)) { + if ((kind > 0 && kind <= 151)) { return initial; } - if ((kind >= 164 && kind <= 183)) { + if ((kind >= 167 && kind <= 186)) { return initial; } var result = initial; switch (node.kind) { - case 218: case 221: - case 211: - case 237: - case 314: + case 223: + case 214: + case 240: + case 318: break; - case 149: + case 152: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150: + case 153: result = reduceNode(node.expression, cbNode, result); break; - case 152: + case 155: 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 153: + case 156: result = reduceNode(node.expression, cbNode, result); break; - case 154: + case 157: 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 155: + case 158: 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 157: + case 160: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -56886,12 +59924,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158: + case 161: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159: + case 162: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -56899,56 +59937,56 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160: + case 163: 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 185: - case 186: + case 188: + case 189: result = reduceNodes(node.elements, cbNodes, result); break; - case 187: + case 190: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 188: + case 191: result = reduceNodes(node.elements, cbNodes, result); break; - case 189: + case 192: result = reduceNodes(node.properties, cbNodes, result); break; - case 190: + case 193: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191: + case 194: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192: + case 195: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193: + case 196: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194: + case 197: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195: + case 198: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197: + case 200: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -56956,121 +59994,121 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198: + case 201: 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 196: case 199: - case 200: - case 201: case 202: - case 208: - case 209: - case 214: - result = reduceNode(node.expression, cbNode, result); - break; case 203: case 204: + case 205: + case 211: + case 212: + case 217: + result = reduceNode(node.expression, cbNode, result); + break; + case 206: + case 207: result = reduceNode(node.operand, cbNode, result); break; - case 205: + case 208: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206: + case 209: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207: + case 210: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210: + case 213: 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 212: + case 215: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213: + case 216: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; - case 217: + case 220: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 219: + case 222: result = reduceNodes(node.statements, cbNodes, result); break; - case 220: + case 224: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222: + case 225: result = reduceNode(node.expression, cbNode, result); break; - case 223: + case 226: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224: + case 227: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225: - case 232: + case 228: + case 235: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226: + case 229: 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 227: - case 228: + case 230: + case 231: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231: - case 235: + case 234: + case 238: result = reduceNode(node.expression, cbNode, result); break; - case 233: + case 236: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234: + case 237: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236: + case 239: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238: + case 241: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239: + case 242: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240: + case 243: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57079,7 +60117,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241: + case 244: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57087,132 +60125,132 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244: + case 247: 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 245: + case 248: 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 246: + case 249: result = reduceNodes(node.statements, cbNodes, result); break; - case 247: + case 250: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249: + case 252: 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 250: + case 253: 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 251: + case 254: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252: + case 255: result = reduceNode(node.name, cbNode, result); break; - case 253: - case 257: + case 256: + case 260: result = reduceNodes(node.elements, cbNodes, result); break; - case 254: - case 258: + case 257: + case 261: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255: + case 258: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256: + case 259: 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 260: + case 263: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 264: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265: + case 268: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262: - case 263: + case 265: + case 266: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269: + case 272: result = reduceNodes(node.properties, cbNodes, result); break; - case 264: + case 267: result = reduceNode(node.tagName, cbNode, result); break; - case 268: + case 271: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270: + case 273: result = reduceNode(node.expression, cbNode, result); break; - case 271: + case 274: result = reduceNode(node.expression, cbNode, result); break; - case 272: + case 275: result = reduceNode(node.expression, cbNode, result); - case 273: + case 276: result = reduceNodes(node.statements, cbNodes, result); break; - case 274: + case 277: result = reduceNodes(node.types, cbNodes, result); break; - case 275: + case 278: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 276: + case 279: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277: + case 280: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278: + case 281: result = reduceNode(node.expression, cbNode, result); break; - case 279: + case 282: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 285: + case 288: result = reduceNodes(node.statements, cbNodes, result); break; - case 315: + case 319: result = reduceNode(node.expression, cbNode, result); break; - case 316: + case 320: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -57265,7 +60303,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 212)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 215)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -57888,7 +60926,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -57928,20 +60966,26 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250: + case 253: externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249: - if (node.moduleReference.kind === 260) { + case 252: + if (node.moduleReference.kind === 263) { externalImports.push(node); } break; - case 256: + case 259: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -57968,12 +61012,12 @@ var ts; } } break; - case 255: + case 258: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 220: + case 224: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -57981,7 +61025,7 @@ var ts; } } break; - case 240: + case 243: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -57999,7 +61043,7 @@ var ts; } } break; - case 241: + case 244: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -58019,10 +61063,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -58076,7 +61118,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -58101,21 +61143,17 @@ var ts; }; } ts.helperString = helperString; - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.getInitializedProperties = getInitializedProperties; - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); + ts.getProperties = getProperties; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; } - ts.isStaticInitializedProperty = isStaticInitializedProperty; - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); - } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; - function isInitializedProperty(member) { - return member.kind === 155 - && member.initializer !== undefined; + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -58443,6 +61481,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -58463,7 +61502,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [ + return ts.createCall(ts.getUnscopedHelperName("__rest"), undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) ]); @@ -58483,8 +61522,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190); - context.enableSubstitution(191); + context.enableSubstitution(193); + context.enableSubstitution(194); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -58497,14 +61536,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286) { + if (node.kind === 289) { 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 === 288) { + if (prepend.kind === 291) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -58537,16 +61576,16 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 285: - case 247: - case 246: - case 219: + case 288: + case 250: + case 249: + case 222: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241: - case 240: + case 244: + case 243: if (ts.hasModifier(node, 2)) { break; } @@ -58554,7 +61593,7 @@ var ts; recordEmittedDeclarationInScope(node); } else { - ts.Debug.assert(node.kind === 241 || ts.hasModifier(node, 512)); + ts.Debug.assert(node.kind === 244 || ts.hasModifier(node, 512)); } if (ts.isClassDeclaration(node)) { currentNameScope = node; @@ -58576,10 +61615,10 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250: - case 249: - case 255: - case 256: + case 253: + case 252: + case 258: + case 259: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -58594,13 +61633,13 @@ var ts; return node; } switch (node.kind) { - case 250: + case 253: return visitImportDeclaration(node); - case 249: + case 252: return visitImportEqualsDeclaration(node); - case 255: + case 258: return visitExportAssignment(node); - case 256: + case 259: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -58610,11 +61649,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 256 || - node.kind === 250 || - node.kind === 251 || - (node.kind === 249 && - node.moduleReference.kind === 260)) { + if (node.kind === 259 || + node.kind === 253 || + node.kind === 254 || + (node.kind === 252 && + node.moduleReference.kind === 263)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -58627,16 +61666,16 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 158: + case 161: return visitConstructor(node); - case 155: + case 158: return visitPropertyDeclaration(node); + case 166: + case 162: case 163: - case 159: case 160: - case 157: return visitorWorker(node); - case 218: + case 221: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -58646,7 +61685,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270) { return undefined; } - else if (currentNamespace && node.kind === 86) { + else if (currentNamespace && node.kind === 88) { return undefined; } return node; @@ -58656,100 +61695,100 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86: - case 81: + case 88: + case 83: return currentNamespace ? undefined : node; + case 118: case 116: - case 114: - case 115: - case 119: - case 78: - case 126: - case 134: - case 170: - case 171: - case 172: - case 173: - case 169: - case 164: - case 151: + case 117: case 121: - case 144: + case 80: + case 129: + case 137: + case 173: + case 174: + case 175: + case 176: + case 172: + case 167: + case 154: case 124: + case 147: + case 127: + case 142: case 139: case 136: - case 133: - case 107: - case 140: - case 167: - case 166: + case 109: + case 143: + case 170: + case 169: + case 171: case 168: - case 165: - case 174: - case 175: - case 176: + case 177: case 178: case 179: - case 180: case 181: case 182: case 183: - case 163: - case 153: - case 243: + case 184: + case 185: + case 186: + case 166: + case 156: + case 246: return undefined; - case 155: + case 158: return visitPropertyDeclaration(node); - case 248: + case 251: return undefined; - case 158: + case 161: return visitConstructor(node); - case 242: + case 245: return ts.createNotEmittedStatement(node); - case 241: + case 244: return visitClassDeclaration(node); - case 210: + case 213: return visitClassExpression(node); - case 274: + case 277: return visitHeritageClause(node); - case 212: + case 215: return visitExpressionWithTypeArguments(node); - case 157: + case 160: return visitMethodDeclaration(node); - case 159: + case 162: return visitGetAccessor(node); - case 160: + case 163: return visitSetAccessor(node); - case 240: + case 243: return visitFunctionDeclaration(node); - case 197: + case 200: return visitFunctionExpression(node); - case 198: + case 201: return visitArrowFunction(node); - case 152: + case 155: return visitParameter(node); - case 196: + case 199: return visitParenthesizedExpression(node); - case 195: - case 213: + case 198: + case 216: return visitAssertionExpression(node); - case 192: + case 195: return visitCallExpression(node); - case 193: + case 196: return visitNewExpression(node); - case 194: + case 197: return visitTaggedTemplateExpression(node); - case 214: + case 217: return visitNonNullExpression(node); - case 244: + case 247: return visitEnumDeclaration(node); - case 220: + case 224: return visitVariableStatement(node); - case 238: + case 241: return visitVariableDeclaration(node); - case 245: + case 248: return visitModuleDeclaration(node); - case 249: + case 252: return visitImportEqualsDeclaration(node); default: return ts.visitEachChild(node, visitor, context); @@ -58779,7 +61818,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99) facts |= 64; if (shouldEmitDecorateCallForClass(node)) facts |= 2; @@ -58808,7 +61847,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, true); + var staticProperties = ts.getProperties(node, true, true); var facts = getClassFacts(node, staticProperties); if (facts & 128) { context.startLexicalEnvironment(); @@ -58907,7 +61946,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -58964,12 +62003,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159: - case 160: + case 162: + case 163: return getAllDecoratorsOfAccessors(node, member); - case 157: + case 160: return getAllDecoratorsOfMethod(member); - case 155: + case 158: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -59048,7 +62087,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 155 + ? member.kind === 158 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -59117,13 +62156,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(37), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(37), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(37), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); @@ -59132,22 +62171,22 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 - || kind === 159 - || kind === 160 - || kind === 155; + return kind === 160 + || kind === 162 + || kind === 163 + || kind === 158; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 157; + return node.kind === 160; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241: - case 210: + case 244: + case 213: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157: - case 159: case 160: + case 162: + case 163: return true; } return false; @@ -59159,15 +62198,15 @@ var ts; } function serializeTypeOfNode(node) { switch (node.kind) { + case 158: case 155: - case 152: return serializeTypeNode(node.type); - case 160: - case 159: + case 163: + case 162: return serializeTypeNode(getAccessorTypeNode(node)); - case 241: - case 210: - case 157: + case 244: + case 213: + case 160: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -59199,7 +62238,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159) { + if (container && node.kind === 162) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -59221,69 +62260,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107: - case 142: - case 97: - case 133: + case 109: + case 145: + case 99: + case 136: return ts.createVoidZero(); - case 178: + case 181: return serializeTypeNode(node.type); - case 166: - case 167: - return ts.createIdentifier("Function"); + case 169: case 170: - case 171: + return ts.createIdentifier("Function"); + case 173: + case 174: return ts.createIdentifier("Array"); - case 164: - case 124: + case 167: + case 127: return ts.createIdentifier("Boolean"); - case 139: + case 142: return ts.createIdentifier("String"); - case 137: + case 140: return ts.createIdentifier("Object"); - case 183: + case 186: switch (node.literal.kind) { case 10: return ts.createIdentifier("String"); - case 203: + case 206: case 8: return ts.createIdentifier("Number"); case 9: return getGlobalBigIntNameWithFallback(); - case 103: - case 88: + case 105: + case 90: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136: + case 139: return ts.createIdentifier("Number"); - case 147: + case 150: return getGlobalBigIntNameWithFallback(); - case 140: + case 143: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165: + case 168: return serializeTypeReferenceNode(node); - case 175: - case 174: + case 178: + case 177: return serializeTypeList(node.types); - case 176: + case 179: return serializeTypeList([node.trueType, node.falseType]); - case 180: - if (node.operator === 134) { + case 183: + if (node.operator === 137) { return serializeTypeNode(node.type); } break; - case 168: - case 181: - case 182: - case 169: - case 121: - case 144: - case 179: + case 171: case 184: + case 185: + case 172: + case 124: + case 147: + case 182: + case 187: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -59292,15 +62331,15 @@ var ts; } function serializeTypeList(types) { var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181) { typeNode = typeNode.type; } - if (typeNode.kind === 133) { + if (typeNode.kind === 136) { continue; } - if (!strictNullChecks && (typeNode.kind === 97 || typeNode.kind === 142)) { + if (!strictNullChecks && (typeNode.kind === 99 || typeNode.kind === 145)) { continue; } var serializedIndividual = serializeTypeNode(typeNode); @@ -59362,11 +62401,11 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(left), ts.createLiteral("undefined")), right); } function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73) { + if (node.kind === 75) { var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73) { + if (node.left.kind === 75) { return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } var left = serializeEntityNameAsExpressionFallback(node.left); @@ -59375,13 +62414,13 @@ var ts; } function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73: + case 75: var name = ts.getMutableClone(node); name.flags &= ~8; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); return name; - case 149: + case 152: return serializeQualifiedNameAsExpression(node); } } @@ -59424,7 +62463,7 @@ var ts; return ts.visitNode(name, visitor, ts.isPropertyName); } function visitHeritageClause(node) { - if (node.token === 110) { + if (node.token === 112) { return undefined; } return ts.visitEachChild(node, visitor, context); @@ -59451,7 +62490,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -59709,11 +62748,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 === 285 ? 0 : 1)); + ], currentLexicalScope.kind === 288 ? 0 : 1)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 244) { + if (node.kind === 247) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -59779,7 +62818,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246) { + if (body.kind === 249) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -59803,13 +62842,13 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (body.kind !== 246) { + if (body.kind !== 249) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245) { + if (moduleDeclaration.body.kind === 248) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -59829,7 +62868,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 252) { + if (node.kind === 255) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -59950,29 +62989,29 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(73); + context.enableSubstitution(75); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(73); + context.enableSubstitution(75); classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(73); - context.enableSubstitution(277); - context.enableEmitNotification(245); + context.enableSubstitution(75); + context.enableSubstitution(280); + context.enableEmitNotification(248); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245; + return ts.getOriginalNode(node).kind === 248; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244; + return ts.getOriginalNode(node).kind === 247; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -60016,11 +63055,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73: + case 75: return substituteExpressionIdentifier(node); - case 190: + case 193: return substitutePropertyAccessExpression(node); - case 191: + case 194: return substituteElementAccessExpression(node); } return node; @@ -60050,9 +63089,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 !== 285) { - var substitute = (applicableSubstitutions & 2 && container.kind === 245) || - (applicableSubstitutions & 8 && container.kind === 244); + if (container && container.kind !== 288) { + var substitute = (applicableSubstitutions & 2 && container.kind === 248) || + (applicableSubstitutions & 8 && container.kind === 247); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } @@ -60072,9 +63111,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " "); } return substitute; @@ -60100,36 +63140,39 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), undefined, [ + return ts.createCall(ts.getUnscopedHelperName("__metadata"), undefined, [ ts.createLiteral(metadataKey), metadataValue ]); } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), undefined, [ ts.createLiteral(parameterOffset), expression ]), location); } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -60148,7 +63191,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -60159,28 +63204,28 @@ var ts; if (!(node.transformFlags & 1048576)) return node; switch (node.kind) { - case 210: + case 213: return visitClassExpression(node); - case 241: + case 244: return visitClassDeclaration(node); - case 220: + case 224: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); } function classElementVisitor(node) { switch (node.kind) { - case 158: + case 161: return undefined; - case 159: + case 162: + case 163: case 160: - case 157: return ts.visitEachChild(node, classElementVisitor, context); - case 155: + case 158: return visitPropertyDeclaration(node); - case 150: + case 153: return visitComputedPropertyName(node); - case 218: + case 221: return node; default: return visitor(node); @@ -60190,7 +63235,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -60220,7 +63265,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99); var statements = [ ts.updateClassDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) ]; @@ -60228,9 +63273,9 @@ var ts; statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; - var staticProperties = ts.getInitializedProperties(node, true); + var staticProperties = ts.getProperties(node, true, true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -60241,9 +63286,9 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, true); + var staticProperties = ts.getProperties(node, true, true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { @@ -60253,7 +63298,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -60290,8 +63335,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -60302,7 +63347,7 @@ var ts; return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, false); + var properties = ts.getProperties(node, !context.getCompilerOptions().useDefineForClassFields, false); if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(undefined, visitor, context); } @@ -60318,7 +63363,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -60330,14 +63375,14 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); } - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -60361,17 +63406,27 @@ var ts; return expressions; } function transformInitializedProperty(property, receiver) { + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(73); + context.enableSubstitution(75); classAliases = []; } } @@ -60384,7 +63439,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73: + case 75: return substituteExpressionIdentifier(node); } return node; @@ -60439,6 +63494,7 @@ var ts; var capturedSuperProperties; var hasSuperElementAccess; var substitutedSuperAccessors = []; + var topLevel; var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; @@ -60448,37 +63504,56 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32) === 0) { return node; } switch (node.kind) { - case 122: + case 125: return undefined; - case 202: + case 205: return visitAwaitExpression(node); - case 157: - return visitMethodDeclaration(node); - case 240: - return visitFunctionDeclaration(node); - case 197: - return visitFunctionExpression(node); - case 198: + case 160: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 243: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201: return visitArrowFunction(node); - case 190: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99) { + case 193: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191: - if (capturedSuperProperties && node.expression.kind === 99) { + case 194: + if (capturedSuperProperties && node.expression.kind === 101) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 162: + case 163: + case 161: + case 244: + case 213: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -60486,27 +63561,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220: + case 224: return visitVariableStatementInAsyncBody(node); - case 226: + case 229: return visitForStatementInAsyncBody(node); - case 227: + case 230: return visitForInStatementInAsyncBody(node); - case 228: + case 231: return visitForOfStatementInAsyncBody(node); - case 275: + case 278: return visitCatchClauseInAsyncBody(node); - case 219: - case 233: - case 247: - case 272: - case 273: + case 222: case 236: - case 224: - case 225: - case 223: - case 232: - case 234: + case 250: + case 275: + case 276: + case 239: + case 227: + case 228: + case 226: + case 235: + case 237: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -60655,7 +63730,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 === 198; + var isArrowFunction = node.kind === 201; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames; enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap(); @@ -60673,7 +63748,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048); if (emitSuperHelpers) { @@ -60697,7 +63772,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -60736,15 +63811,15 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(192); - context.enableSubstitution(190); - context.enableSubstitution(191); - context.enableEmitNotification(241); - context.enableEmitNotification(157); - context.enableEmitNotification(159); + context.enableSubstitution(195); + context.enableSubstitution(193); + context.enableSubstitution(194); + context.enableEmitNotification(244); context.enableEmitNotification(160); - context.enableEmitNotification(158); - context.enableEmitNotification(220); + context.enableEmitNotification(162); + context.enableEmitNotification(163); + context.enableEmitNotification(161); + context.enableEmitNotification(224); } } function onEmitNode(hint, node, emitCallback) { @@ -60776,23 +63851,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190: + case 193: return substitutePropertyAccessExpression(node); - case 191: + case 194: return substituteElementAccessExpression(node); - case 192: + case 195: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -60803,19 +63878,19 @@ var ts; var argumentExpression = ts.isPropertyAccessExpression(expression) ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 - || kind === 158 - || kind === 157 - || kind === 159 - || kind === 160; + return kind === 244 + || kind === 161 + || kind === 160 + || kind === 162 + || kind === 163; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -60851,16 +63926,17 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); - var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(40), undefined, undefined, [], undefined, body); + var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(41), undefined, undefined, [], undefined, body); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288; - return ts.createCall(ts.getHelperName("__awaiter"), undefined, [ - ts.createThis(), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), undefined, [ + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -60888,9 +63964,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; var capturedSuperProperties; var hasSuperElementAccess; var substitutedSuperAccessors = []; @@ -60899,6 +63977,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -60910,68 +63990,85 @@ var ts; return visitorWorker(node, true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122) { + if (node.kind === 125) { return undefined; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16) === 0) { return node; } switch (node.kind) { - case 202: + case 205: return visitAwaitExpression(node); - case 208: + case 211: return visitYieldExpression(node); - case 231: - return visitReturnStatement(node); case 234: + return visitReturnStatement(node); + case 237: return visitLabeledStatement(node); - case 189: + case 192: return visitObjectLiteralExpression(node); - case 205: + case 208: return visitBinaryExpression(node, noDestructuringValue); - case 275: + case 278: return visitCatchClause(node); - case 238: + case 224: + return visitVariableStatement(node); + case 241: return visitVariableDeclaration(node); - case 228: + case 231: return visitForOfStatement(node, undefined); - case 226: + case 229: return visitForStatement(node); - case 201: + case 204: return visitVoidExpression(node); - case 158: - return visitConstructorDeclaration(node); - case 157: - return visitMethodDeclaration(node); - case 159: - return visitGetAccessorDeclaration(node); + case 161: + return doOutsideOfTopLevel(visitConstructorDeclaration, node); case 160: - return visitSetAccessorDeclaration(node); - case 240: - return visitFunctionDeclaration(node); - case 197: - return visitFunctionExpression(node); - case 198: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 162: + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 163: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 243: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201: return visitArrowFunction(node); - case 152: + case 155: return visitParameter(node); - case 222: + case 225: return visitExpressionStatement(node); - case 196: + case 199: return visitParenthesizedExpression(node, noDestructuringValue); - case 190: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99) { + case 193: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191: - if (capturedSuperProperties && node.expression.kind === 99) { + case 194: + if (capturedSuperProperties && node.expression.kind === 101) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 244: + case 213: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -61003,7 +64100,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 && statement.awaitModifier) { + if (statement.kind === 231 && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -61015,7 +64112,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 === 278) { + if (e.kind === 281) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -61024,7 +64121,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 + chunkObject = ts.append(chunkObject, e.kind === 279 ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -61037,7 +64134,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 8192) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189) { + if (objects.length && objects[0].kind !== 192) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -61077,17 +64174,37 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, undefined, undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, false); + } + function visitVariableDeclarationWorker(node, exportedVariableStatement) { if (ts.isBindingPattern(node.name) && node.name.transformFlags & 8192) { - return ts.flattenDestructuringBinding(node, visitor, context, 1); + return ts.flattenDestructuringBinding(node, visitor, context, 1, undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -61266,7 +64383,7 @@ var ts; var savedHasSuperElementAccess = hasSuperElementAccess; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; - 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 returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(41), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); @@ -61325,15 +64442,15 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(192); - context.enableSubstitution(190); - context.enableSubstitution(191); - context.enableEmitNotification(241); - context.enableEmitNotification(157); - context.enableEmitNotification(159); + context.enableSubstitution(195); + context.enableSubstitution(193); + context.enableSubstitution(194); + context.enableEmitNotification(244); context.enableEmitNotification(160); - context.enableEmitNotification(158); - context.enableEmitNotification(220); + context.enableEmitNotification(162); + context.enableEmitNotification(163); + context.enableEmitNotification(161); + context.enableEmitNotification(224); } } function onEmitNode(hint, node, emitCallback) { @@ -61365,23 +64482,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190: + case 193: return substitutePropertyAccessExpression(node); - case 191: + case 194: return substituteElementAccessExpression(node); - case 192: + case 195: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -61392,19 +64509,19 @@ var ts; var argumentExpression = ts.isPropertyAccessExpression(expression) ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 - || kind === 158 - || kind === 157 - || kind === 159 - || kind === 160; + return kind === 244 + || kind === 161 + || kind === 160 + || kind === 162 + || kind === 163; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -61418,6 +64535,7 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" @@ -61427,51 +64545,55 @@ var ts; return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); + return ts.createCall(ts.getUnscopedHelperName("__assign"), undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144; - return ts.createCall(ts.getHelperName("__asyncGenerator"), undefined, [ - ts.createThis(), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), undefined, [ + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), undefined, [expression]), location); + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), undefined, [expression]), location); + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), undefined, [expression]), location); } })(ts || (ts = {})); var ts; @@ -61489,7 +64611,7 @@ var ts; return node; } switch (node.kind) { - case 275: + case 278: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -61507,6 +64629,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -61519,10 +64642,135 @@ var ts; return node; } switch (node.kind) { + case 193: + case 194: + case 195: + if (node.flags & 32) { + var updated = visitOptionalExpression(node, false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208: + if (node.operatorToken.kind === 60) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37), ts.createNull()), ts.createToken(55), ts.createBinary(node, ts.createToken(37), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -61551,13 +64799,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261: + case 264: return visitJsxElement(node, false); - case 262: - return visitJsxSelfClosingElement(node, false); case 265: + return visitJsxSelfClosingElement(node, false); + case 268: return visitJsxFragment(node, false); - case 271: + case 274: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -61567,13 +64815,13 @@ var ts; switch (node.kind) { case 11: return visitJsxText(node); - case 271: + case 274: return visitJsxExpression(node); - case 261: + case 264: return visitJsxElement(node, true); - case 262: - return visitJsxSelfClosingElement(node, true); case 265: + return visitJsxSelfClosingElement(node, true); + case 268: return visitJsxFragment(node, true); default: return ts.Debug.failBadSyntaxKind(node); @@ -61637,7 +64885,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271) { + else if (node.kind === 274) { if (node.expression === undefined) { return ts.createTrue(); } @@ -61697,7 +64945,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261) { + if (node.kind === 264) { return getTagName(node.openingElement); } else { @@ -61997,7 +65245,7 @@ var ts; return node; } switch (node.kind) { - case 205: + case 208: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -62005,9 +65253,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64: + case 66: return visitExponentiationAssignmentExpression(node); - case 41: + case 42: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -62087,13 +65335,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192) !== 0 - && node.kind === 231 + && node.kind === 234 && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 && (ts.isStatement(node) || (node.kind === 219))) + || (hierarchyFacts & 8192 && (ts.isStatement(node) || (node.kind === 222))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432) !== 0; } @@ -62106,72 +65354,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99) { + if (node.kind === 101) { return visitSuperKeyword(true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117: + case 119: return undefined; - case 241: + case 244: return visitClassDeclaration(node); - case 210: + case 213: return visitClassExpression(node); - case 152: + case 155: return visitParameter(node); - case 240: + case 243: return visitFunctionDeclaration(node); - case 198: + case 201: return visitArrowFunction(node); - case 197: + case 200: return visitFunctionExpression(node); - case 238: + case 241: return visitVariableDeclaration(node); - case 73: + case 75: return visitIdentifier(node); - case 239: + case 242: return visitVariableDeclarationList(node); - case 233: + case 236: return visitSwitchStatement(node); - case 247: + case 250: return visitCaseBlock(node); - case 219: + case 222: return visitBlock(node, false); - case 230: - case 229: + case 233: + case 232: return visitBreakOrContinueStatement(node); - case 234: + case 237: return visitLabeledStatement(node); - case 224: - case 225: + case 227: + case 228: return visitDoOrWhileStatement(node, undefined); - case 226: + case 229: return visitForStatement(node, undefined); - case 227: + case 230: return visitForInStatement(node, undefined); - case 228: + case 231: return visitForOfStatement(node, undefined); - case 222: + case 225: return visitExpressionStatement(node); - case 189: + case 192: return visitObjectLiteralExpression(node); - case 275: + case 278: return visitCatchClause(node); - case 277: + case 280: return visitShorthandPropertyAssignment(node); - case 150: + case 153: return visitComputedPropertyName(node); - case 188: + case 191: return visitArrayLiteralExpression(node); - case 192: + case 195: return visitCallExpression(node); - case 193: - return visitNewExpression(node); case 196: + return visitNewExpression(node); + case 199: return visitParenthesizedExpression(node, true); - case 205: + case 208: return visitBinaryExpression(node, true); case 14: case 15: @@ -62182,28 +65430,28 @@ var ts; return visitStringLiteral(node); case 8: return visitNumericLiteral(node); - case 194: + case 197: return visitTaggedTemplateExpression(node); - case 207: + case 210: return visitTemplateExpression(node); - case 208: + case 211: return visitYieldExpression(node); - case 209: + case 212: return visitSpreadElement(node); - case 99: - return visitSuperKeyword(false); case 101: + return visitSuperKeyword(false); + case 103: return visitThisKeyword(node); - case 215: + case 218: return visitMetaProperty(node); - case 157: - return visitMethodDeclaration(node); - case 159: case 160: + return visitMethodDeclaration(node); + case 162: + case 163: return visitAccessorDeclaration(node); - case 220: + case 224: return visitVariableStatement(node); - case 231: + case 234: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -62288,14 +65536,14 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 230 ? 2 : 4; + var jump = node.kind === 233 ? 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 === 230) { + if (node.kind === 233) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -62305,7 +65553,7 @@ var ts; } } else { - if (node.kind === 230) { + if (node.kind === 233) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker); } @@ -62438,7 +65686,7 @@ var ts; return block; } function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99; if (!constructor) return createDefaultConstructorBody(node, isDerivedClass); var prologue = []; @@ -62491,17 +65739,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 231) { + if (statement.kind === 234) { return true; } - else if (statement.kind === 223) { + else if (statement.kind === 226) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 219) { + else if (statement.kind === 222) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -62584,9 +65832,9 @@ var ts; if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { return false; } - var declarationName = parameter.name.kind === 73 ? ts.getMutableClone(parameter.name) : ts.createTempVariable(undefined); + var declarationName = parameter.name.kind === 75 ? ts.getMutableClone(parameter.name) : ts.createTempVariable(undefined); ts.setEmitFlags(declarationName, 48); - var expressionName = parameter.name.kind === 73 ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ @@ -62602,14 +65850,14 @@ var ts; ts.setEmitFlags(forStatement, 1048576); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73) { + if (parameter.name.kind !== 75) { prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, expressionName))), parameter), 1048576)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; } function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 && node.kind !== 198) { + if (hierarchyFacts & 32768 && node.kind !== 201) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -62628,19 +65876,19 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 198: + case 201: return statements; - case 157: - case 159: case 160: + case 162: + case 163: newTarget = ts.createVoidZero(); break; - case 158: + case 161: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 240: - case 197: - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 95, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + case 243: + case 200: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 97, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -62660,20 +65908,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218: + case 221: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157: + case 160: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159: - case 160: + case 162: + case 163: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158: + case 161: break; default: ts.Debug.failBadSyntaxKind(member, currentSourceFile && currentSourceFile.fileName); @@ -62687,11 +65935,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); @@ -62793,7 +66052,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 240 || node.kind === 197)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 243 || node.kind === 200)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -62824,7 +66083,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198); + ts.Debug.assert(node.kind === 201); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -62877,9 +66136,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 196: + case 199: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, false)); - case 205: + case 208: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -62887,9 +66146,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 196: + case 199: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 205: + case 208: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -62915,7 +66174,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0); } else { - assignment = ts.createBinary(decl.name, 60, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -63020,14 +66279,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224: - case 225: + case 227: + case 228: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226: + case 229: return visitForStatement(node, outermostLabeledStatement); - case 227: + case 230: return visitForInStatement(node, outermostLabeledStatement); - case 228: + case 231: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -63154,7 +66413,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150) { + if (property.name.kind === 153) { numInitialProperties = i; break; } @@ -63201,7 +66460,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73) { + if (node.kind === 75) { state.hoistedLocalVariables.push(node); } else { @@ -63265,11 +66524,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227: return convertForInStatement(node, convertedLoopBody); - case 228: return convertForOfStatement(node, convertedLoopBody); - case 224: return convertDoStatement(node, convertedLoopBody); - case 225: return convertWhileStatement(node, convertedLoopBody); + case 229: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230: return convertForInStatement(node, convertedLoopBody); + case 231: return convertForOfStatement(node, convertedLoopBody); + case 227: return convertDoStatement(node, convertedLoopBody); + case 228: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -63293,11 +66552,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226: - case 227: - case 228: + case 229: + case 230: + case 231: var initializer = node.initializer; - if (initializer && initializer.kind === 239) { + if (initializer && initializer.kind === 242) { loopInitializer = initializer; } break; @@ -63391,7 +66650,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(40) : 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(41) : 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 }; @@ -63406,7 +66665,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(52, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -63427,7 +66686,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(40) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(41) : 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 }; @@ -63435,7 +66694,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, 60, source); + return ts.createBinary(target, 62, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -63448,7 +66707,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40), ts.setEmitFlags(call, 8388608)) + ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608)) : call; return ts.createStatement(callResult); } @@ -63459,7 +66718,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(40), ts.setEmitFlags(call, 8388608)) + ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -63479,10 +66738,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -63556,20 +66815,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159: - case 160: + case 162: + case 163: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157: + case 160: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276: + case 279: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277: + case 280: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -63624,7 +66883,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); @@ -63640,7 +66899,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159) { + if (node.kind === 162) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -63670,7 +66929,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 || + if (expression.kind === 101 || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); @@ -63719,20 +66978,20 @@ var ts; } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { if (node.transformFlags & 4096 || - node.expression.kind === 99 || + node.expression.kind === 101 || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { ts.setEmitFlags(thisArg, 4); } var resultingCall = void 0; if (node.transformFlags & 4096) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -63745,7 +67004,7 @@ var ts; function visitNewExpression(node) { if (ts.some(node.arguments, ts.isSpreadElement)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), false, false, false)), undefined, []); } return ts.visitEachChild(node, visitor, context); } @@ -63851,9 +67110,12 @@ var ts; return ts.createCall(tag, undefined, templateArguments); } function getRawLiteral(node) { - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 14 || node.kind === 17; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + 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); } @@ -63888,13 +67150,11 @@ var ts; } } function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 && node.name.escapedText === "target") { + if (node.keywordToken === 98 && node.name.escapedText === "target") { hierarchyFacts |= 16384; return ts.createFileLevelUniqueName("_newTarget"); } @@ -63914,20 +67174,20 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(73); + context.enableSubstitution(75); } } function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(101); - context.enableEmitNotification(158); - context.enableEmitNotification(157); - context.enableEmitNotification(159); + context.enableSubstitution(103); + context.enableEmitNotification(161); context.enableEmitNotification(160); - context.enableEmitNotification(198); - context.enableEmitNotification(197); - context.enableEmitNotification(240); + context.enableEmitNotification(162); + context.enableEmitNotification(163); + context.enableEmitNotification(201); + context.enableEmitNotification(200); + context.enableEmitNotification(243); } } function onSubstituteNode(hint, node) { @@ -63951,10 +67211,10 @@ var ts; } function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187: - case 241: + case 190: case 244: - case 238: + case 247: + case 241: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -63962,9 +67222,9 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73: + case 75: return substituteExpressionIdentifier(node); - case 101: + case 103: return substituteThisKeyword(node); } return node; @@ -64015,19 +67275,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212) { return false; } var expression = callArgument.expression; @@ -64037,26 +67297,28 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), undefined, [ + return ts.createCall(ts.getUnscopedHelperName("__extends"), undefined, [ name, ts.createFileLevelUniqueName("_super") ]); } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), undefined, [ + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), undefined, [ cooked, raw ]); } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -64071,24 +67333,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263); - context.enableEmitNotification(264); - context.enableEmitNotification(262); + context.enableEmitNotification(266); + context.enableEmitNotification(267); + context.enableEmitNotification(265); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190); - context.enableSubstitution(276); + context.enableSubstitution(193); + context.enableSubstitution(279); return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263: - case 264: - case 262: + case 266: + case 267: + case 265: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -64124,7 +67386,7 @@ var ts; } function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 && token <= 109) { + if (token !== undefined && token >= 76 && token <= 111) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -64205,13 +67467,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224: + case 227: return visitDoStatement(node); - case 225: + case 228: return visitWhileStatement(node); - case 233: + case 236: return visitSwitchStatement(node); - case 234: + case 237: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -64219,24 +67481,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240: + case 243: return visitFunctionDeclaration(node); - case 197: + case 200: return visitFunctionExpression(node); - case 159: - case 160: + case 162: + case 163: return visitAccessorDeclaration(node); - case 220: + case 224: return visitVariableStatement(node); - case 226: + case 229: return visitForStatement(node); - case 227: - return visitForInStatement(node); case 230: + return visitForInStatement(node); + case 233: return visitBreakStatement(node); - case 229: + case 232: return visitContinueStatement(node); - case 231: + case 234: return visitReturnStatement(node); default: if (node.transformFlags & 131072) { @@ -64252,21 +67514,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205: + case 208: return visitBinaryExpression(node); - case 206: + case 209: return visitConditionalExpression(node); - case 208: + case 211: return visitYieldExpression(node); - case 188: + case 191: return visitArrayLiteralExpression(node); - case 189: + case 192: return visitObjectLiteralExpression(node); - case 191: + case 194: return visitElementAccessExpression(node); - case 192: + case 195: return visitCallExpression(node); - case 193: + case 196: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -64274,9 +67536,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 240: + case 243: return visitFunctionDeclaration(node); - case 197: + case 200: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -64409,23 +67671,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 - && kind <= 72; + return kind >= 63 + && kind <= 74; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61: return 38; - case 62: return 39; - case 63: return 40; - case 64: return 41; - case 65: return 42; - case 66: return 43; - case 67: return 46; - case 68: return 47; - case 69: return 48; - case 70: return 49; - case 71: return 50; - case 72: return 51; + case 63: return 39; + case 64: return 40; + case 65: return 41; + case 66: return 42; + case 67: return 43; + case 68: return 44; + case 69: return 47; + case 70: return 48; + case 71: return 49; + case 72: return 50; + case 73: return 51; + case 74: return 52; } } function visitRightAssociativeBinaryExpression(node) { @@ -64433,10 +67695,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190: + case 193: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191: + case 194: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -64472,7 +67734,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 54) { + if (node.operatorToken.kind === 55) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -64541,13 +67803,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -64556,7 +67818,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -64637,35 +67899,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219: - return transformAndEmitBlock(node); case 222: + return transformAndEmitBlock(node); + case 225: return transformAndEmitExpressionStatement(node); - case 223: + case 226: return transformAndEmitIfStatement(node); - case 224: + case 227: return transformAndEmitDoStatement(node); - case 225: + case 228: return transformAndEmitWhileStatement(node); - case 226: + case 229: return transformAndEmitForStatement(node); - case 227: + case 230: return transformAndEmitForInStatement(node); - case 229: + case 232: return transformAndEmitContinueStatement(node); - case 230: + case 233: return transformAndEmitBreakStatement(node); - case 231: + case 234: return transformAndEmitReturnStatement(node); - case 232: + case 235: return transformAndEmitWithStatement(node); - case 233: + case 236: return transformAndEmitSwitchStatement(node); - case 234: + case 237: return transformAndEmitLabeledStatement(node); - case 235: + case 238: return transformAndEmitThrowStatement(node); - case 236: + case 239: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -64959,7 +68221,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 && defaultClauseIndex === -1) { + if (clause.kind === 276 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -64969,7 +68231,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272) { + if (clause.kind === 275) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -65102,11 +68364,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, node); return temp; } @@ -65204,7 +68465,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73); + context.enableSubstitution(75); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -65755,10 +69016,11 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), undefined, [ts.createThis(), body]); + return ts.createCall(ts.getUnscopedHelperName("__generator"), undefined, [ts.createThis(), body]); } ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -65784,12 +69046,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73); - context.enableSubstitution(205); - context.enableSubstitution(203); - context.enableSubstitution(204); - context.enableSubstitution(277); - context.enableEmitNotification(285); + context.enableSubstitution(75); + context.enableSubstitution(208); + context.enableSubstitution(206); + context.enableSubstitution(207); + context.enableSubstitution(280); + context.enableEmitNotification(288); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -65845,17 +69107,17 @@ var ts; var jsonSourceFile = ts.isJsonSourceFile(node) && node; var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ - ts.createExpressionStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createExpressionStatement(ts.createCall(define, undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), jsonSourceFile ? jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : ts.createObjectLiteral() : - ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([ ts.createParameter(undefined, undefined, undefined, "require"), ts.createParameter(undefined, undefined, undefined, "exports") - ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ], importAliasNames), undefined, transformAsynchronousModuleBody(node)) ]))) ]), node.statements)); ts.addEmitHelpers(updated, context.readEmitHelpers()); @@ -65874,21 +69136,21 @@ var ts; ]), ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) ], true), undefined)); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(umdHeader, undefined, [ - ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([ ts.createParameter(undefined, undefined, undefined, "require"), ts.createParameter(undefined, undefined, undefined, "exports") - ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ], importAliasNames), undefined, transformAsynchronousModuleBody(node)) ])) ]), node.statements)); ts.addEmitHelpers(updated, context.readEmitHelpers()); @@ -65980,23 +69242,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 250: + case 253: return visitImportDeclaration(node); - case 249: + case 252: return visitImportEqualsDeclaration(node); - case 256: + case 259: return visitExportDeclaration(node); - case 255: + case 258: return visitExportAssignment(node); - case 220: + case 224: return visitVariableStatement(node); - case 240: + case 243: return visitFunctionDeclaration(node); - case 241: + case 244: return visitClassDeclaration(node); - case 317: + case 321: return visitMergeDeclarationMarker(node); - case 318: + case 322: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -66021,24 +69283,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276: + case 279: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277: + case 280: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278: + case 281: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157: - case 159: case 160: + case 162: + case 163: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -66115,7 +69377,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -66124,7 +69386,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [requireCall]); } var func; if (languageVersion >= 2) { @@ -66144,11 +69406,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), undefined, [innerExpr]); } return innerExpr; } @@ -66353,7 +69615,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -66385,10 +69647,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252: + case 255: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253: + case 256: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -66489,14 +69751,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 86: - case 81: + case 88: + case 83: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285) { + if (node.kind === 288) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -66536,12 +69798,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73: + case 75: return substituteExpressionIdentifier(node); - case 205: + case 208: return substituteBinaryExpression(node); - case 204: - case 203: + case 207: + case 206: return substituteUnaryExpression(node); } return node; @@ -66556,7 +69818,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285) { + if (exportContainer && exportContainer.kind === 288) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -66592,15 +69854,15 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 44 || node.operator === 45) + if ((node.operator === 45 || node.operator === 46) && 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 === 204 - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 ? 61 : 62), ts.createLiteral(1)), node) + var expression = node.kind === 207 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 ? 63 : 64), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; @@ -66632,7 +69894,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), undefined, [module]); } var dynamicImportUMDHelper = { @@ -66642,11 +69904,13 @@ var ts; }; ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -66662,16 +69926,18 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73); - context.enableSubstitution(277); - context.enableSubstitution(205); - context.enableSubstitution(203); - context.enableSubstitution(204); - context.enableEmitNotification(285); + context.enableSubstitution(75); + context.enableSubstitution(280); + context.enableSubstitution(208); + context.enableSubstitution(206); + context.enableSubstitution(207); + context.enableSubstitution(218); + context.enableEmitNotification(288); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; var noSubstitutionMap = []; + var contextObjectMap = []; var currentSourceFile; var moduleInfo; var exportFunction; @@ -66690,7 +69956,7 @@ var ts; moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); var moduleBodyFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ @@ -66771,7 +70037,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 && externalImport.exportClause) { + if (externalImport.kind === 259 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -66794,7 +70060,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256) { + if (externalImport.kind !== 259) { continue; } if (!externalImport.exportClause) { @@ -66837,23 +70103,23 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var group_2 = dependencyGroups_1[_i]; + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 250: + case 253: if (!entry.importClause) { break; } - case 249: + case 252: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256: + case 259: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -66875,13 +70141,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 250: + case 253: return visitImportDeclaration(node); - case 249: + case 252: return visitImportEqualsDeclaration(node); - case 256: + case 259: return undefined; - case 255: + case 258: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -67002,7 +70268,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 2097152) === 0 - && (enclosingBlockScopedContainer.kind === 285 + && (enclosingBlockScopedContainer.kind === 288 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -67024,7 +70290,7 @@ var ts; : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -67063,10 +70329,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252: + case 255: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253: + case 256: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -67166,43 +70432,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 220: + case 224: return visitVariableStatement(node); - case 240: + case 243: return visitFunctionDeclaration(node); - case 241: + case 244: return visitClassDeclaration(node); - case 226: + case 229: return visitForStatement(node); - case 227: + case 230: return visitForInStatement(node); - case 228: + case 231: return visitForOfStatement(node); - case 224: + case 227: return visitDoStatement(node); - case 225: + case 228: return visitWhileStatement(node); - case 234: + case 237: return visitLabeledStatement(node); - case 232: + case 235: return visitWithStatement(node); - case 233: + case 236: return visitSwitchStatement(node); - case 247: + case 250: return visitCaseBlock(node); - case 272: + case 275: return visitCaseClause(node); - case 273: + case 276: return visitDefaultClause(node); - case 236: + case 239: return visitTryStatement(node); - case 275: + case 278: return visitCatchClause(node); - case 219: + case 222: return visitBlock(node); - case 317: + case 321: return visitMergeDeclarationMarker(node); - case 318: + case 322: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -67338,7 +70604,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285; + return container !== undefined && container.kind === 288; } else { return false; @@ -67346,19 +70612,20 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 86: - case 81: + case 88: + case 83: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285) { + if (node.kind === 288) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -67366,6 +70633,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -67387,7 +70655,7 @@ var ts; } function substituteUnspecified(node) { switch (node.kind) { - case 277: + case 280: return substituteShorthandPropertyAssignment(node); } return node; @@ -67409,13 +70677,15 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73: + case 75: return substituteExpressionIdentifier(node); - case 205: + case 208: return substituteBinaryExpression(node); - case 203: - case 204: + case 206: + case 207: return substituteUnaryExpression(node); + case 218: + return substituteMetaProperty(node); } return node; } @@ -67459,22 +70729,22 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 44 || node.operator === 45) + if ((node.operator === 45 || node.operator === 46) && 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 === 204 + var expression = node.kind === 207 ? 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 === 204) { - expression = node.operator === 44 + if (node.kind === 207) { + expression = node.operator === 45 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -67483,6 +70753,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } function getExports(name) { var exportedNames; if (!ts.isGeneratedIdentifier(name)) { @@ -67490,7 +70766,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 285) { + if (exportContainer && exportContainer.kind === 288) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -67518,22 +70794,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285); - context.enableSubstitution(73); - var currentSourceFile; + context.enableEmitNotification(288); + context.enableSubstitution(75); + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -67545,9 +70819,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249: + case 252: return undefined; - case 255: + case 258: return visitExportAssignment(node); } return node; @@ -67557,9 +70831,9 @@ var ts; } function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -67567,19 +70841,18 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -67634,7 +70907,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 === 241) { + else if (node.parent.kind === 244) { 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 : @@ -67663,7 +70936,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 === 241) { + else if (node.parent.kind === 244) { 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 : @@ -67689,7 +70962,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -67710,15 +70983,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 === 238 || node.kind === 187) { + if (node.kind === 241 || node.kind === 190) { 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 === 155 || node.kind === 190 || node.kind === 154 || - (node.kind === 152 && ts.hasModifier(node.parent, 8))) { + else if (node.kind === 158 || node.kind === 193 || node.kind === 157 || + (node.kind === 155 && ts.hasModifier(node.parent, 8))) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -67726,7 +70999,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 === 241 || node.kind === 152) { + else if (node.parent.kind === 244 || node.kind === 155) { 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 : @@ -67750,7 +71023,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160) { + if (node.kind === 163) { 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 : @@ -67787,23 +71060,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162: + case 165: 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 161: + case 164: 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 163: + case 166: 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 157: - case 156: + case 160: + case 159: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -67811,7 +71084,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 === 241) { + else if (node.parent.kind === 244) { 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 : @@ -67824,7 +71097,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240: + case 243: 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 : @@ -67849,27 +71122,27 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158: + case 161: 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 162: - case 167: + case 165: + case 170: 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 161: + case 164: 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 163: + case 166: 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 157: - case 156: + case 160: + case 159: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -67877,7 +71150,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 === 241) { + else if (node.parent.parent.kind === 244) { 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 : @@ -67889,13 +71162,20 @@ 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 240: - case 166: + case 243: + case 169: 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 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163: + case 162: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -67903,39 +71183,39 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 241: + case 244: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242: + case 245: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182: + case 185: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167: - case 162: + case 170: + case 165: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161: + case 164: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157: - case 156: + case 160: + case 159: 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 === 241) { + else if (node.parent.parent.kind === 244) { 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 166: - case 240: + case 169: + case 243: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243: + case 246: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -67949,8 +71229,8 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 241) { - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 ? + if (node.parent.parent.kind === 244) { + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 ? 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; } @@ -67983,11 +71263,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -67997,7 +71274,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152) { + if (parseTreeNode && parseTreeNode.kind === 155) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -68048,9 +71325,9 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -68128,20 +71405,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([]), undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 && node.isDeclarationFile) { return node; } - if (node.kind === 286) { + if (node.kind === 289) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -68154,18 +71440,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { resultHasExternalModuleIndicator = false; needsDeclare = false; - var statements_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(126)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], true, [], [], false, []); + var statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], true, [], [], false, []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288) { + if (prepend.kind === 291) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -68201,12 +71487,19 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -68247,6 +71540,11 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { + var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, host.getSourceFiles(), undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { fileName = fileName.substring(2); @@ -68280,11 +71578,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73) { + if (name.kind === 75) { return name; } else { - if (name.kind === 186) { + if (name.kind === 189) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -68292,19 +71590,19 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211) { + if (elem.kind === 214) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { 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(56)) : 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(57)) : undefined, ensureType(p, type || p.type, true), ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } @@ -68326,17 +71624,17 @@ var ts; if (shouldPrintWithInitializer(node)) { return; } - var shouldUseResolverType = node.kind === 152 && + var shouldUseResolverType = node.kind === 155 && (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(121); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124); } - if (node.kind === 160) { - return ts.createKeywordTypeNode(121); + if (node.kind === 163) { + return ts.createKeywordTypeNode(124); } errorNameNode = node.name; var oldDiag; @@ -68344,12 +71642,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 || node.kind === 187) { + if (node.kind === 241 || node.kind === 190) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 - || node.kind === 155 - || node.kind === 154) { + if (node.kind === 155 + || node.kind === 158 + || node.kind === 157) { 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)); @@ -68360,25 +71658,25 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121); + return returnValue || ts.createKeywordTypeNode(124); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240: - case 245: - case 242: - case 241: case 243: + case 248: + case 245: case 244: + case 246: + case 247: return !resolver.isDeclarationVisible(node); - case 238: + case 241: return !getBindingNameVisible(node); - case 249: - case 250: - case 256: - case 255: + case 252: + case 253: + case 259: + case 258: return false; } return false; @@ -68404,6 +71702,30 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter(undefined, undefined, undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -68431,7 +71753,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 && parent.kind !== 184); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 && parent.kind !== 187); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -68451,7 +71773,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260) { + if (decl.moduleReference.kind === 263) { var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); } @@ -68471,7 +71793,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 === 252) { + if (decl.importClause.namedBindings.kind === 255) { 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; } @@ -68500,10 +71822,10 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -68513,12 +71835,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -68539,6 +71855,9 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 || input.kind === 185) && input.parent.kind !== 246); if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) @@ -68546,69 +71865,66 @@ var ts; return cleanup(ts.createProperty(undefined, ensureModifiers(input), input.name, undefined, undefined, undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 || input.kind === 182) && input.parent.kind !== 243); if (shouldEnterSuppressNewDiagnosticsContextContext) { suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212: { + case 215: { 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 165: { + case 168: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162: + case 165: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158: { + case 161: { var isPrivate = ts.hasModifier(input, 8); - var ctor = ts.createSignatureDeclaration(158, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); + var ctor = ts.createSignatureDeclaration(161, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157: { - var sig = ts.createSignatureDeclaration(156, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160: { + var sig = ts.createSignatureDeclaration(159, 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 159: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 162: { + var isPrivate = ts.hasModifier(input, 8); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, undefined)); } - case 160: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 163: { + return cleanup(ts.updateSetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), undefined)); } - case 155: + case 158: return cleanup(ts.updateProperty(input, undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154: + case 157: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156: { + case 159: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161: { + case 164: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163: { - return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121))); + case 166: { + return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124))); } - case 238: { + case 241: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -68616,13 +71932,13 @@ var ts; suppressNewDiagnosticContexts = true; return cleanup(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151: { + case 154: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, undefined, undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176: { + case 179: { var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree); var oldEnclosingDecl = enclosingDeclaration; @@ -68632,13 +71948,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166: { + case 169: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167: { + case 170: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184: { + case 187: { 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)); @@ -68648,13 +71964,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -68667,7 +71983,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 160 && ts.hasModifier(node.parent, 8); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -68676,19 +71992,19 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256: { + case 259: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255: { + case 258: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 73) { + if (input.expression.kind === 75) { return input; } else { @@ -68698,7 +72014,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(126)] : [], ts.createVariableDeclarationList([varDecl], 2)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129)] : [], ts.createVariableDeclarationList([varDecl], 2)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -68720,10 +72036,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249: { + case 252: { return transformImportEqualsDeclaration(input); } - case 250: { + case 253: { return transformImportDeclaration(input); } } @@ -68743,12 +72059,12 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243: + case 246: return cleanup(ts.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242: { + case 245: { return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240: { + case 243: { var clean = cleanup(ts.updateFunctionDeclaration(input, undefined, ensureModifiers(input), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined)); if (clean && resolver.isExpandoFunctionDeclaration(input)) { var props = resolver.getPropertiesOfContainerFunction(input); @@ -68785,22 +72101,22 @@ var ts; return clean; } } - case 245: { + case 248: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246) { + if (inner && inner.kind === 249) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304) { + if (input.flags & 8388608) { needsScopeFixMarker = false; } if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -68824,7 +72140,7 @@ var ts; return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body)); } } - case 241: { + case 244: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -68835,7 +72151,7 @@ var ts; if (!ts.hasModifier(param, 92) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73) { + if (param.name.kind === 75) { return preserveJsDoc(ts.createProperty(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } else { @@ -68860,7 +72176,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 !== 97) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99) { var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); getSymbolAccessibilityDiagnostic = function () { return ({ @@ -68869,16 +72185,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(126)] : [], ts.createVariableDeclarationList([varDecl], 2)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129)] : [], ts.createVariableDeclarationList([varDecl], 2)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87) { + if (clause.token === 89) { 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 === 97; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; } @@ -68887,10 +72203,10 @@ var ts; return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220: { + case 224: { return cleanup(transformVariableStatement(input)); } - case 244: { + case 247: { return cleanup(ts.updateEnumDeclaration(input, undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -68907,7 +72223,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245) { + if (input.kind === 248) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -68928,7 +72244,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211) { + if (e.kind === 214) { return; } if (e.name) { @@ -68978,54 +72294,34 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 ^ (4 | 256); var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0; - var parentIsFile = node.parent.kind === 285; + var parentIsFile = node.parent.kind === 288; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2; additions = 0; } return maskModifierFlags(node, mask, additions); } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); } - var prop = ts.createProperty(undefined, maskModifiers(node, undefined, (!accessors.setAccessor) ? 64 : 0), node.name, node.questionToken, ensureType(node, accessorType), undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; + return accessorType; } 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 === 87 && t.expression.kind === 97); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 && t.expression.kind === 99); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242) { + if (node.kind === 245) { return true; } return false; @@ -69047,7 +72343,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 + return accessor.kind === 162 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -69056,52 +72352,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155: - case 154: + case 158: + case 157: return !ts.hasModifier(node, 8); - case 152: - case 238: + case 155: + case 241: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240: - case 245: - case 249: - case 242: - case 241: case 243: + case 248: + case 252: + case 245: case 244: - case 220: - case 250: - case 256: - case 255: + case 246: + case 247: + case 224: + case 253: + case 259: + case 258: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { + case 165: + case 161: + case 160: case 162: + case 163: case 158: case 157: case 159: - case 160: - case 155: - case 154: - case 156: - case 161: - case 163: - case 238: - case 151: - case 212: - case 165: - case 176: + case 164: case 166: - case 167: - case 184: + case 241: + case 154: + case 215: + case 168: + case 179: + case 169: + case 170: + case 187: return true; } return false; @@ -69199,7 +72495,7 @@ var ts; } ts.noEmitNotification = noEmitNotification; function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(319); + var enabledSyntaxKindFeatures = new Array(324); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -69352,7 +72648,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); @@ -69414,15 +72710,15 @@ var ts; return ts.fileExtensionIs(file, ".tsbuildinfo"); } ts.isBuildInfoFile = isBuildInfoFile; - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -69432,21 +72728,21 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -69469,20 +72765,20 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo"; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286) { + if (sourceFile.kind === 289) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -69491,8 +72787,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -69527,11 +72822,13 @@ var ts; inputFileName; } function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts") && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts")); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts"); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json"); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" : @@ -69542,42 +72839,72 @@ var ts; outputFileName : undefined; } - function getAllProjectOutputs(configFile, ignoreCase) { + function createAddOutput() { var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts")) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json")) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } + function getAllProjectOutputs(configFile, ignoreCase) { + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts")) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json")) - continue; - if (configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { var jsFilePath = getOutputPathsForBundle(configFile.options, false).jsFilePath; @@ -69590,14 +72917,19 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json")) + continue; + if (ts.getEmitDeclarations(configFile.options)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); } ts.getFirstProjectOutput = getFirstProjectOutput; - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -69610,7 +72942,7 @@ var ts; var emitSkipped = false; var exportedModulesFromDeclarationEmit; enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -69699,14 +73031,13 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !declarationFilePath) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, false); if (ts.length(declarationTransform.diagnostics)) { @@ -69736,7 +73067,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -69744,7 +73075,7 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -69755,7 +73086,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73) { + if (node.expression.kind === 75) { resolver.collectLinkedAliases(node.expression, true); } return; @@ -69767,8 +73098,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -69806,7 +73137,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json")); + && (sourceFileOrBundle.kind !== 288 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json")); } function getSourceRoot(mapOptions) { var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || ""); @@ -69897,10 +73228,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285, 0, 0); + var sourceFile = ts.createNode(288, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -69912,7 +73244,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222, directive.pos, directive.end); + var statement = ts.createNode(225, directive.pos, directive.end); statement.expression = ts.createNode(10, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -69946,7 +73278,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -69999,6 +73331,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers)); return outputFiles; @@ -70040,6 +73373,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -70066,9 +73401,9 @@ var ts; break; } switch (node.kind) { - case 285: return printFile(node); - case 286: return printBundle(node); - case 287: return printUnparsedSource(node); + case 288: return printFile(node); + case 289: return printBundle(node); + case 290: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -70235,8 +73570,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -70248,7 +73582,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; sourceMapGenerator = _sourceMapGenerator; @@ -70264,6 +73598,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(undefined, undefined); } function getCurrentLineMap() { @@ -70273,21 +73609,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0, node); - pipelinePhase(4, node); + var substitute = pipelineEmit(4, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0, node); - pipelinePhase(2, node); + return pipelineEmit(2, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0, node); - pipelinePhase(1, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -70300,11 +73647,11 @@ var ts; return pipelineEmitWithSubstitution; } case 2: - if (!commentsDisabled && node.kind !== 285) { + if (!commentsDisabled && node.kind !== 288) { return pipelineEmitWithComments; } case 3: - if (!sourceMapsDisabled && node.kind !== 285 && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } case 4: @@ -70317,10 +73664,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2) @@ -70339,262 +73689,262 @@ var ts; case 16: case 17: return emitLiteral(node); - case 287: - case 281: + case 290: + case 284: return emitUnparsedSourceOrPrepend(node); - case 280: - return writeUnparsedNode(node); - case 282: case 283: + return writeUnparsedNode(node); + case 285: + case 286: return emitUnparsedTextLike(node); - case 284: + case 287: return emitUnparsedSyntheticReference(node); - case 73: + case 75: return emitIdentifier(node); - case 149: + case 152: return emitQualifiedName(node); - case 150: + case 153: return emitComputedPropertyName(node); - case 151: + case 154: return emitTypeParameter(node); - case 152: + case 155: return emitParameter(node); - case 153: + case 156: return emitDecorator(node); - case 154: + case 157: return emitPropertySignature(node); - case 155: + case 158: return emitPropertyDeclaration(node); - case 156: + case 159: return emitMethodSignature(node); - case 157: + case 160: return emitMethodDeclaration(node); - case 158: + case 161: return emitConstructor(node); - case 159: - case 160: + case 162: + case 163: return emitAccessorDeclaration(node); - case 161: + case 164: return emitCallSignature(node); - case 162: + case 165: return emitConstructSignature(node); - case 163: + case 166: return emitIndexSignature(node); - case 164: + case 167: return emitTypePredicate(node); - case 165: + case 168: return emitTypeReference(node); - case 166: + case 169: return emitFunctionType(node); - case 295: + case 298: return emitJSDocFunctionType(node); - case 167: + case 170: return emitConstructorType(node); - case 168: + case 171: return emitTypeQuery(node); - case 169: + case 172: return emitTypeLiteral(node); - case 170: + case 173: return emitArrayType(node); - case 171: + case 174: return emitTupleType(node); - case 172: + case 175: return emitOptionalType(node); - case 174: + case 177: return emitUnionType(node); - case 175: + case 178: return emitIntersectionType(node); - case 176: + case 179: return emitConditionalType(node); - case 177: + case 180: return emitInferType(node); - case 178: + case 181: return emitParenthesizedType(node); - case 212: + case 215: return emitExpressionWithTypeArguments(node); - case 179: + case 182: return emitThisType(); - case 180: + case 183: return emitTypeOperator(node); - case 181: + case 184: return emitIndexedAccessType(node); - case 182: + case 185: return emitMappedType(node); - case 183: + case 186: return emitLiteralType(node); - case 184: + case 187: return emitImportTypeNode(node); - case 290: + case 293: writePunctuation("*"); return; - case 291: + case 294: writePunctuation("?"); return; - case 292: + case 295: return emitJSDocNullableType(node); - case 293: + case 296: return emitJSDocNonNullableType(node); - case 294: + case 297: return emitJSDocOptionalType(node); - case 173: - case 296: + case 176: + case 299: return emitRestOrJSDocVariadicType(node); - case 185: + case 188: return emitObjectBindingPattern(node); - case 186: + case 189: return emitArrayBindingPattern(node); - case 187: + case 190: return emitBindingElement(node); - case 217: + case 220: return emitTemplateSpan(node); - case 218: + case 221: return emitSemicolonClassElement(); - case 219: + case 222: return emitBlock(node); - case 220: + case 224: return emitVariableStatement(node); - case 221: + case 223: return emitEmptyStatement(false); - case 222: + case 225: return emitExpressionStatement(node); - case 223: + case 226: return emitIfStatement(node); - case 224: + case 227: return emitDoStatement(node); - case 225: + case 228: return emitWhileStatement(node); - case 226: + case 229: return emitForStatement(node); - case 227: + case 230: return emitForInStatement(node); - case 228: + case 231: return emitForOfStatement(node); - case 229: + case 232: return emitContinueStatement(node); - case 230: + case 233: return emitBreakStatement(node); - case 231: + case 234: return emitReturnStatement(node); - case 232: + case 235: return emitWithStatement(node); - case 233: + case 236: return emitSwitchStatement(node); - case 234: + case 237: return emitLabeledStatement(node); - case 235: + case 238: return emitThrowStatement(node); - case 236: + case 239: return emitTryStatement(node); - case 237: + case 240: return emitDebuggerStatement(node); - case 238: + case 241: return emitVariableDeclaration(node); - case 239: + case 242: return emitVariableDeclarationList(node); - case 240: + case 243: return emitFunctionDeclaration(node); - case 241: + case 244: return emitClassDeclaration(node); - case 242: + case 245: return emitInterfaceDeclaration(node); - case 243: + case 246: return emitTypeAliasDeclaration(node); - case 244: + case 247: return emitEnumDeclaration(node); - case 245: + case 248: return emitModuleDeclaration(node); - case 246: + case 249: return emitModuleBlock(node); - case 247: + case 250: return emitCaseBlock(node); - case 248: + case 251: return emitNamespaceExportDeclaration(node); - case 249: + case 252: return emitImportEqualsDeclaration(node); - case 250: + case 253: return emitImportDeclaration(node); - case 251: + case 254: return emitImportClause(node); - case 252: + case 255: return emitNamespaceImport(node); - case 253: + case 256: return emitNamedImports(node); - case 254: + case 257: return emitImportSpecifier(node); - case 255: + case 258: return emitExportAssignment(node); - case 256: + case 259: return emitExportDeclaration(node); - case 257: + case 260: return emitNamedExports(node); - case 258: + case 261: return emitExportSpecifier(node); - case 259: + case 262: return; - case 260: + case 263: return emitExternalModuleReference(node); case 11: return emitJsxText(node); - case 263: case 266: + case 269: return emitJsxOpeningElementOrFragment(node); - case 264: case 267: + case 270: return emitJsxClosingElementOrFragment(node); - case 268: + case 271: return emitJsxAttribute(node); - case 269: + case 272: return emitJsxAttributes(node); - case 270: + case 273: return emitJsxSpreadAttribute(node); - case 271: + case 274: return emitJsxExpression(node); - case 272: + case 275: return emitCaseClause(node); - case 273: + case 276: return emitDefaultClause(node); - case 274: + case 277: return emitHeritageClause(node); - case 275: + case 278: return emitCatchClause(node); - case 276: + case 279: return emitPropertyAssignment(node); - case 277: + case 280: return emitShorthandPropertyAssignment(node); - case 278: + case 281: return emitSpreadAssignment(node); - case 279: + case 282: return emitEnumMember(node); - case 306: - case 312: + case 310: + case 316: return emitJSDocPropertyLikeTag(node); - case 307: + case 311: + case 313: + case 312: case 309: - case 308: - case 305: return emitJSDocSimpleTypedTag(node); - case 301: + case 305: return emitJSDocAugmentsTag(node); - case 310: + case 314: return emitJSDocTemplateTag(node); - case 311: + case 315: return emitJSDocTypedefTag(node); - case 304: + case 308: return emitJSDocCallbackTag(node); - case 299: + case 303: return emitJSDocSignature(node); - case 298: + case 302: return emitJSDocTypeLiteral(node); - case 303: - case 300: + case 307: + case 304: return emitJSDocSimpleTag(node); - case 297: + case 301: return emitJSDoc(node); } if (ts.isExpression(node)) { hint = 1; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -70610,79 +73960,79 @@ var ts; case 13: case 14: return emitLiteral(node); - case 73: + case 75: return emitIdentifier(node); - case 88: - case 97: + case 90: case 99: - case 103: case 101: - case 93: + case 105: + case 103: + case 95: writeTokenNode(node, writeKeyword); return; - case 188: + case 191: return emitArrayLiteralExpression(node); - case 189: + case 192: return emitObjectLiteralExpression(node); - case 190: + case 193: return emitPropertyAccessExpression(node); - case 191: + case 194: return emitElementAccessExpression(node); - case 192: + case 195: return emitCallExpression(node); - case 193: + case 196: return emitNewExpression(node); - case 194: + case 197: return emitTaggedTemplateExpression(node); - case 195: + case 198: return emitTypeAssertionExpression(node); - case 196: + case 199: return emitParenthesizedExpression(node); - case 197: + case 200: return emitFunctionExpression(node); - case 198: + case 201: return emitArrowFunction(node); - case 199: + case 202: return emitDeleteExpression(node); - case 200: + case 203: return emitTypeOfExpression(node); - case 201: + case 204: return emitVoidExpression(node); - case 202: + case 205: return emitAwaitExpression(node); - case 203: + case 206: return emitPrefixUnaryExpression(node); - case 204: + case 207: return emitPostfixUnaryExpression(node); - case 205: + case 208: return emitBinaryExpression(node); - case 206: + case 209: return emitConditionalExpression(node); - case 207: + case 210: return emitTemplateExpression(node); - case 208: + case 211: return emitYieldExpression(node); - case 209: + case 212: return emitSpreadExpression(node); - case 210: + case 213: return emitClassExpression(node); - case 211: + case 214: return; - case 213: + case 216: return emitAsExpression(node); - case 214: + case 217: return emitNonNullExpression(node); - case 215: + case 218: return emitMetaProperty(node); - case 261: + case 264: return emitJsxElement(node); - case 262: - return emitJsxSelfClosingElement(node); case 265: + return emitJsxSelfClosingElement(node); + case 268: return emitJsxFragment(node); - case 315: + case 319: return emitPartiallyEmittedExpression(node); - case 316: + case 320: return emitCommaList(node); } } @@ -70695,8 +74045,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -70710,8 +74063,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -70722,7 +74075,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 ? node : undefined; + var bundle = node.kind === 289 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -70731,12 +74084,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { if (shouldSkip) continue; @@ -70796,7 +74149,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 ? "text" : "internal"); } @@ -70822,7 +74175,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73) { + if (node.kind === 75) { emitExpression(node); } else { @@ -70855,7 +74208,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 && !node.name) { + if (node.parent && node.parent.kind === 298 && !node.name) { emit(node.type); } else { @@ -70913,7 +74266,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 ? "get" : "set"); + writeKeyword(node.kind === 162 ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -70951,11 +74304,17 @@ var ts; writeTrailingSemicolon(); } function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -71087,18 +74446,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134) { + if (node.readonlyToken.kind !== 137) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0, node.typeParameter); - pipelinePhase(3, node.typeParameter); + pipelineEmit(3, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56) { + if (node.questionToken.kind !== 57) { writePunctuation("?"); } } @@ -71172,57 +74530,50 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, false, true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072)) { - var dotToken = ts.createToken(24); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { var text = getLiteralTextOfNode(expression, true); - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576); } function emitNewExpression(node) { - emitTokenWithComment(96, node.pos, writeKeyword, node); + emitTokenWithComment(98, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -71262,22 +74613,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82, node.pos, writeKeyword, node); + emitTokenWithComment(84, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105, node.pos, writeKeyword, node); + emitTokenWithComment(107, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107, node.pos, writeKeyword, node); + emitTokenWithComment(109, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123, node.pos, writeKeyword, node); + emitTokenWithComment(126, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -71290,9 +74641,9 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 203 - && ((node.operator === 38 && (operand.operator === 38 || operand.operator === 44)) - || (node.operator === 39 && (operand.operator === 39 || operand.operator === 45))); + return operand.kind === 206 + && ((node.operator === 39 && (operand.operator === 39 || operand.operator === 45)) + || (node.operator === 40 && (operand.operator === 40 || operand.operator === 46))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -71305,7 +74656,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, true); increaseIndentIf(indentAfterOperator, true); emitExpression(node.right); @@ -71333,7 +74684,7 @@ var ts; emitList(node, node.templateSpans, 262144); } function emitYieldExpression(node) { - emitTokenWithComment(118, node.pos, writeKeyword, node); + emitTokenWithComment(120, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -71400,7 +74751,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -71408,8 +74759,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223) { + emitTokenWithComment(86, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226) { writeSpace(); emit(node.elseStatement); } @@ -71419,14 +74770,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83, node.pos, writeKeyword, node); + emitTokenWithComment(85, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -71435,14 +74786,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); @@ -71454,25 +74805,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21, node.expression.end, writePunctuation, node); @@ -71480,7 +74831,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239) { + if (node.kind === 242) { emit(node); } else { @@ -71489,12 +74840,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79, node.pos, writeKeyword, node); + emitTokenWithComment(81, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74, node.pos, writeKeyword, node); + emitTokenWithComment(76, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -71522,12 +74873,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98, node.pos, writeKeyword, node); + emitTokenWithComment(100, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -71535,7 +74886,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -71545,17 +74896,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57, node.label.end, writePunctuation, node); + emitTokenWithComment(58, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102, node.pos, writeKeyword, node); + emitTokenWithComment(104, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104, node.pos, writeKeyword, node); + emitTokenWithComment(106, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -71564,13 +74915,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80, node.pos, writeKeyword); + writeToken(82, node.pos, writeKeyword); writeTrailingSemicolon(); } function emitVariableDeclaration(node) { @@ -71757,7 +75108,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512) { + if (~node.flags & 1024) { writeKeyword(node.flags & 16 ? "namespace" : "module"); writeSpace(); } @@ -71765,7 +75116,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245) { + while (body.kind === 248) { writePunctuation("."); emit(body.name); body = body.body; @@ -71786,17 +75137,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60, node.name.end, writePunctuation, node); + emitTokenWithComment(62, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73) { + if (node.kind === 75) { emitExpression(node); } else { @@ -71805,12 +75156,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -71825,9 +75176,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120, asPos, writeKeyword, node); + emitTokenWithComment(122, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -71838,42 +75189,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60, nextPos, writeOperator, node); + emitTokenWithComment(62, nextPos, writeOperator, node); } else { - emitTokenWithComment(81, nextPos, writeKeyword, node); + emitTokenWithComment(83, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145, fromPos, writeKeyword, node); + emitTokenWithComment(148, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -71893,7 +75244,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -71965,7 +75316,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73) { + if (node.kind === 75) { emitExpression(node); } else { @@ -71973,13 +75324,13 @@ var ts; } } function emitCaseClause(node) { - emitTokenWithComment(75, node.pos, writeKeyword, node); + emitTokenWithComment(77, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -71989,12 +75340,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969; if (emitAsSingleStatement) { - writeToken(57, colonPos, writePunctuation, parentNode); + writeToken(58, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 | 128); } else { - emitTokenWithComment(57, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -72005,7 +75356,7 @@ var ts; emitList(node, node.types, 528); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20, openParenPos, writePunctuation, node); @@ -72059,7 +75410,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -72093,7 +75444,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289) { + if (tag.typeExpression.kind === 292) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -72112,7 +75463,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298) { + if (tag.typeExpression && tag.typeExpression.kind === 302) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -72241,8 +75592,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_20 = types; _d < types_20.length; _d++) { + var directive = types_20[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -72412,7 +75763,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -72450,8 +75801,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0, node); - pipelinePhase(5, node); + pipelineEmit(5, node); } else { emit(node); @@ -72826,6 +76176,9 @@ var ts; return (format & 65536) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -72842,7 +76195,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -72901,81 +76254,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219: + case 222: ts.forEach(node.statements, generateNames); break; - case 234: - case 232: - case 224: - case 225: + case 237: + case 235: + case 227: + case 228: generateNames(node.statement); break; - case 223: + case 226: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226: - case 228: - case 227: + case 229: + case 231: + case 230: generateNames(node.initializer); generateNames(node.statement); break; - case 233: + case 236: generateNames(node.caseBlock); break; - case 247: + case 250: ts.forEach(node.clauses, generateNames); break; - case 272: - case 273: + case 275: + case 276: ts.forEach(node.statements, generateNames); break; - case 236: + case 239: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275: + case 278: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220: + case 224: generateNames(node.declarationList); break; - case 239: + case 242: ts.forEach(node.declarations, generateNames); break; - case 238: - case 152: - case 187: case 241: + case 155: + case 190: + case 244: generateNameIfNeeded(node.name); break; - case 240: + case 243: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185: - case 186: + case 188: + case 189: ts.forEach(node.elements, generateNames); break; - case 250: + case 253: generateNames(node.importClause); break; - case 251: + case 254: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252: + case 255: generateNameIfNeeded(node.name); break; - case 253: + case 256: ts.forEach(node.elements, generateNames); break; - case 254: + case 257: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -72984,12 +76337,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276: - case 277: - case 155: - case 157: - case 159: + case 279: + case 280: + case 158: case 160: + case 162: + case 163: generateNameIfNeeded(node.name); break; } @@ -73029,7 +76382,7 @@ var ts; for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) { if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); - if (local && local.flags & (67220415 | 1048576 | 2097152)) { + if (local && local.flags & (111551 | 1048576 | 2097152)) { return false; } } @@ -73121,25 +76474,25 @@ var ts; } function generateNameForNode(node, flags) { switch (node.kind) { - case 73: + case 75: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8)); - case 245: - case 244: + case 248: + case 247: return generateNameForModuleOrEnum(node); - case 250: - case 256: + case 253: + case 259: return generateNameForImportOrExportDeclaration(node); - case 240: - case 241: - case 255: + case 243: + case 244: + case 258: return generateNameForExportDefault(); - case 210: + case 213: return generateNameForClassExpression(); - case 157: - case 159: case 160: + case 162: + case 163: return generateNameForMethodOrAccessor(node); - case 150: + case 153: return makeTempVariableName(0, true); default: return makeTempVariableName(0); @@ -73172,11 +76525,12 @@ var ts; return node; } function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314; + var isEmittedNode = node.kind !== 318; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11; var savedContainerPos = containerPos; @@ -73191,7 +76545,7 @@ var ts; } if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) { containerEnd = end; - if (node.kind === 239) { + if (node.kind === 242) { declarationListContainerEnd = end; } } @@ -73218,6 +76572,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2) { @@ -73411,6 +76766,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -73425,7 +76781,7 @@ var ts; 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 !== 314 + if (node.kind !== 318 && (emitFlags & 16) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -73438,12 +76794,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 + if (node.kind !== 318 && (emitFlags & 32) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function skipSourceTrivia(source, pos) { return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(source.text, pos); @@ -73745,6 +77102,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -74086,7 +77446,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -74264,8 +77624,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -74278,6 +77638,7 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + ts.inferredTypesContainingFile = "__inferred type names__.ts"; function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) { if (!program || hasChangedAutomaticTypeDirectiveNames) { return false; @@ -74334,7 +77695,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -74359,15 +77720,16 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -74392,7 +77754,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) { if (!resolved || resolved.extension !== undefined) { return resolved; } @@ -74408,7 +77770,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; @@ -74423,8 +77785,11 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); if (structuralIsReused !== 2) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -74432,20 +77797,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), false, false, undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, false, false, undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts") && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), false, false, undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), false, false, undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts")) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), false, false, undefined); + } } } } @@ -74456,7 +77837,7 @@ var ts; 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"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -74484,8 +77865,8 @@ var ts; ts.Debug.assert(!!missingFilePaths); if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { @@ -74499,12 +77880,13 @@ var ts; }); } oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -74541,7 +77923,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -74568,9 +77952,13 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } @@ -74719,6 +78107,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } var newSourceFiles = []; var modifiedSourceFiles = []; @@ -74784,7 +78178,7 @@ var ts; if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { oldProgram.structureIsReused = 1; } - if ((oldSourceFile.flags & 1572864) !== (newSourceFile.flags & 1572864)) { + if ((oldSourceFile.flags & 3145728) !== (newSourceFile.flags & 3145728)) { oldProgram.structureIsReused = 1; } if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { @@ -74814,25 +78208,23 @@ var ts; 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 resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - oldProgram.structureIsReused = 1; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + oldProgram.structureIsReused = 1; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } if (resolveTypeReferenceDirectiveNamesWorker) { var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { + var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -74846,10 +78238,18 @@ var ts; return oldProgram.structureIsReused = 1; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); 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 (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), undefined); + } + } if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); } @@ -74866,16 +78266,17 @@ var ts; return oldProgram.structureIsReused = 2; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { var path = toPath(f); if (getSourceFileByPath(path)) return true; if (ts.contains(missingFilePaths, path)) return false; return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -74925,20 +78326,20 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken); } @@ -74954,7 +78355,7 @@ var ts; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -75017,14 +78418,15 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4 || - sourceFile.scriptKind === 5 || isCheckJs || sourceFile.scriptKind === 7; + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4 || + sourceFile.scriptKind === 5 || isCheckJs || sourceFile.scriptKind === 7); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -75076,62 +78478,62 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 152: case 155: + case 158: + case 160: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 157: - case 156: - case 158: case 159: - case 160: - case 197: - case 240: - case 198: - case 238: + case 161: + case 162: + case 163: + case 200: + case 243: + case 201: + case 241: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 249: + case 252: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255: + case 258: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274: + case 277: var heritageClause = node; - if (heritageClause.token === 110) { + if (heritageClause.token === 112) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242: + case 245: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245: + case 248: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243: + case 246: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244: + case 247: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214: + case 217: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213: + case 216: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195: + case 198: ts.Debug.fail(); } var prevParent = parent; @@ -75144,46 +78546,47 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241: - case 157: - case 156: - case 158: - case 159: + case 244: + case 213: case 160: - case 197: - case 240: - case 198: + case 161: + case 162: + case 163: + case 200: + case 243: + case 201: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 220: + case 224: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220); + return checkModifiers(parent.modifiers, parent.kind === 224); } break; - case 155: + case 158: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 117) { + if (modifier.kind !== 119) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152: + case 155: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192: - case 193: - case 212: - case 262: - case 263: + case 195: + case 196: + case 215: + case 265: + case 266: + case 197: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -75199,21 +78602,21 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78: + case 80: if (isConstValid) { continue; } + case 118: case 116: - case 114: - case 115: - case 134: - case 126: - case 119: + case 117: + case 137: + case 129: + case 121: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; - case 117: - case 86: - case 81: + case 119: + case 88: + case 83: } } } @@ -75285,8 +78688,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 - ? b.kind === 73 && a.escapedText === b.escapedText + return a.kind === 75 + ? b.kind === 75 && a.escapedText === b.escapedText : b.kind === 10 && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -75312,7 +78715,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, false); } - if ((file.flags & 524288) || isJavaScriptFile) { + if ((file.flags & 1048576) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -75426,23 +78829,17 @@ var ts; return sourceFileWithAddedExtension; } } - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, function (diagnostic) { + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -75464,13 +78861,24 @@ var ts; }); return redirect; } - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); - if (file_1 && options.forceConsistentCasingInFileNames) { + var file_2 = filesByName.get(path); + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -75478,31 +78886,32 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -75513,14 +78922,7 @@ var ts; redirectedPath = toPath(redirect); } } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -75547,7 +78949,7 @@ var ts; var pathLowerCase = path.toLowerCase(); var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -75569,8 +78971,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -75585,7 +78997,7 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts")) { return undefined; } return getResolvedProjectReferenceToRedirect(fileName); @@ -75618,6 +79030,34 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + var outputDts = ts.changeExtension(out, ".d.ts"); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts")) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, undefined, cbResolvedRef, cbRef); @@ -75650,9 +79090,15 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, false, undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, false, undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -75666,10 +79112,16 @@ var ts; var resolvedTypeReferenceDirective = resolutions[i]; var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; @@ -75679,27 +79131,27 @@ var ts; if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile); } else { if (previousResolution) { if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } saveResolution = false; } else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -75716,20 +79168,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -75761,14 +79213,20 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, false, false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, false, false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -75786,12 +79244,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -75846,9 +79307,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -75883,15 +79341,16 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -75999,8 +79458,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -76059,8 +79518,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -76086,7 +79578,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -76215,6 +79707,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; function parseConfigHostFromCompilerHostLike(host, directoryStructureHost) { @@ -76257,9 +79755,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { @@ -76300,9 +79795,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -76494,11 +79989,16 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true); + var firstDts_1 = emitOutput_1.outputFiles && + programOfThisState.getCompilerOptions().declarationMap ? + emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : + emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + if (firstDts_1) { + ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts"), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + latestSignature = computeHash(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -76582,6 +80082,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; function containsOnlyAmbientModules(sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -76660,7 +80161,7 @@ var ts; state.program = newProgram; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -76681,7 +80182,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -76718,7 +80220,7 @@ var ts; } }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -76727,7 +80229,7 @@ var ts; function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -76746,7 +80248,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } function releaseCache(state) { ts.BuilderState.releaseCache(state); @@ -76766,7 +80268,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -76788,7 +80291,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } state.changedFilesSet.delete(state.currentChangedFilePath); @@ -76824,12 +80326,17 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -76843,7 +80350,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -76859,7 +80366,7 @@ var ts; if (sourceFile) { ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0); } } } @@ -76873,9 +80380,32 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { + return; + } + if (!isChangedSignagure(state, affectedFile.path)) return; + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); @@ -76925,7 +80455,7 @@ var ts; fn(state, referencingFilePath); }); } - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -76935,6 +80465,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -76943,8 +80476,12 @@ var ts; } } } - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) { @@ -76965,7 +80502,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -77057,7 +80594,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -77142,17 +80679,19 @@ var ts; return result; function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, false, true); + return toAffectedFileEmitResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1, false, true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -77164,7 +80703,7 @@ var ts; affected = program; } } - return toAffectedFileResult(state, ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + return toAffectedFileEmitResult(state, ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile); } function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { @@ -77201,7 +80740,7 @@ var ts; return toAffectedFileResult(state, state.program.getSemanticDiagnostics(undefined, cancellationToken), affected); } if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1); } if (ignoreSourceFile && ignoreSourceFile(affected)) { doneWithAffectedFile(state, affected); @@ -77231,8 +80770,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); if (state.affectedFilesPendingEmitIndex === undefined) { state.affectedFilesPendingEmitIndex = 0; } @@ -77262,7 +80807,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true }; return { @@ -77379,8 +80924,19 @@ var ts; if (nextDirectorySeparator === -1) { return false; } - if (dirPath.charCodeAt(0) !== 47 && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { @@ -77528,8 +81084,8 @@ var ts; !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]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); if (!seenNamesInFile.has(name) && allFilesHaveInvalidatedResolution || unmatchedRedirects || !resolution || resolution.isInvalidated || @@ -77797,6 +81353,9 @@ var ts; if (!resolution.isInvalidated && isInvalidatedResolution(resolution, getResolutionWithResolvedFileName)) { resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -77932,8 +81491,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 : 1, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -77948,6 +81508,12 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); @@ -77960,7 +81526,7 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -77975,7 +81541,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0) { return relativePath; @@ -78010,43 +81576,21 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -78063,7 +81607,30 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -78094,16 +81661,18 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -78112,22 +81681,25 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) return undefined; var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1); @@ -78296,11 +81868,17 @@ var ts; ? newLine + newLine : newLine; } + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; function createWatchStatusReporter(system, pretty) { return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -78309,7 +81887,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -78482,7 +82060,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -78524,7 +82102,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -78564,7 +82142,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -78655,7 +82233,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -78679,10 +82257,22 @@ var ts; ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) : currentDirectory, false); compilerHost.resolveModuleNames = host.resolveModuleNames ? - (function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -78884,13 +82474,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -79042,9 +82638,17 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts"); } + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -79196,18 +82800,21 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); if (permanentMarks.has(projPath)) return; if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -79227,12 +82834,32 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -79240,6 +82867,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -79256,7 +82884,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -79310,7 +82938,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -79479,7 +83107,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -79634,6 +83262,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? state.currentInvalidatedProject : @@ -79686,8 +83316,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -79838,10 +83471,12 @@ var ts; refStatus.type === ts.UpToDateStatusType.ContainerOnly) { continue; } - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } if (refStatus.type !== ts.UpToDateStatusType.UpToDate) { @@ -79891,7 +83526,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -80048,16 +83683,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -80193,8 +83834,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); watchConfigFile(state, resolved, resolvedPath); var cfg = parseConfigFile(state, resolved, resolvedPath); @@ -80223,6 +83864,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -80233,7 +83875,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -80241,7 +83883,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -80259,22 +83901,32 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -80303,7 +83955,9 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: @@ -80363,14 +84017,7 @@ var ts; ts.sort(ts.optionDeclarations, function (a, b) { return ts.compareStringsCaseInsensitive(a.name, b.name); }) : ts.filter(ts.optionDeclarations.slice(), function (v) { return !!v.showInSimplifiedHelpView; }); } - function executeCommandLine(args) { - if (args.length > 0 && args[0].charCodeAt(0) === 45 /* minus */) { - var firstOption = args[0].slice(args[0].charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); - if (firstOption === "build" || firstOption === "b") { - return performBuild(args.slice(1)); - } - } - var commandLine = ts.parseCommandLine(args); + function executeCommandLineWorker(commandLine) { if (commandLine.options.build) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_build_must_be_the_first_command_line_argument)); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); @@ -80438,7 +84085,7 @@ var ts; configParseResult.errors.forEach(reportDiagnostic); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null ts.sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, ts.sys), null, 4) + ts.sys.newLine); return ts.sys.exit(ts.ExitStatus.Success); } @@ -80456,7 +84103,7 @@ var ts; } else { if (commandLineOptions.showConfig) { - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null 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); } @@ -80473,6 +84120,21 @@ var ts; } } } + function executeCommandLine(args) { + if (args.length > 0 && args[0].charCodeAt(0) === 45 /* minus */) { + var firstOption = args[0].slice(args[0].charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); + if (firstOption === "build" || firstOption === "b") { + return performBuild(args.slice(1)); + } + } + var commandLine = ts.parseCommandLine(args); + if (commandLine.options.generateCpuProfile && ts.sys.enableCPUProfiler) { + ts.sys.enableCPUProfiler(commandLine.options.generateCpuProfile, function () { return executeCommandLineWorker(commandLine); }); + } + else { + executeCommandLineWorker(commandLine); + } + } ts.executeCommandLine = executeCommandLine; function reportWatchModeWithoutSysSupport() { if (!ts.sys.watchFile || !ts.sys.watchDirectory) { @@ -80480,8 +84142,7 @@ var ts; ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } } - function performBuild(args) { - var _a = ts.parseBuildCommand(args), buildOptions = _a.buildOptions, projects = _a.projects, errors = _a.errors; + function performBuildWorker(buildOptions, projects, errors) { // Update to pretty if host supports it updateReportDiagnostic(buildOptions); if (buildOptions.locale) { @@ -80520,6 +84181,15 @@ var ts; var builder = ts.createSolutionBuilder(buildHost, projects, buildOptions); return ts.sys.exit(buildOptions.clean ? builder.clean() : builder.build()); } + function performBuild(args) { + var _a = ts.parseBuildCommand(args), buildOptions = _a.buildOptions, projects = _a.projects, errors = _a.errors; + if (buildOptions.generateCpuProfile && ts.sys.enableCPUProfiler) { + ts.sys.enableCPUProfiler(buildOptions.generateCpuProfile, function () { return performBuildWorker(buildOptions, projects, errors); }); + } + else { + performBuildWorker(buildOptions, projects, errors); + } + } function createReportErrorSummary(options) { return shouldBePretty(options) ? function (errorCount) { return ts.sys.write(ts.getErrorSummaryText(errorCount, ts.sys.newLine)); } : diff --git a/lib/tsserver.js b/lib/tsserver.js index a7782a87174e4..c96242d3b4950 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -15,6 +15,13 @@ and limitations under the License. "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -75,15 +82,17 @@ var __rest = (this && this.__rest) || function (s, e) { for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } return t; }; var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -101,7 +110,7 @@ var ts; ts.emptyArray = []; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -136,7 +145,7 @@ var ts; } ts.createMapFromTemplate = createMapFromTemplate; // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name + // eslint-disable-next-line no-in-operator ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { @@ -200,7 +209,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -297,6 +306,21 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Like `forEach`, but iterates in reverse order. + */ + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ function firstDefined(array, callback) { if (array === undefined) { @@ -793,7 +817,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -850,6 +874,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1240,6 +1265,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1378,6 +1415,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1437,7 +1480,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1471,7 +1514,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1945,11 +1988,33 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2026,8 +2091,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2076,6 +2143,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2091,7 +2159,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2199,6 +2267,9 @@ var ts; Debug.assertNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1 /* Normal */) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -2379,6 +2450,47 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + // require() will throw an exception if the module is not installed + // It may also return undefined if not installed properly + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { // https://semver.org/#spec-item-2 // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative @@ -2777,358 +2889,366 @@ var ts; 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"; + SyntaxKind[SyntaxKind["QuestionDotToken"] = 28] = "QuestionDotToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 29] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 30] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 31] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 32] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 33] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 34] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 35] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 36] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 37] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 38] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 39] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 40] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 41] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 42] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 43] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 44] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 45] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 46] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 47] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 49] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 50] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 51] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 52] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 53] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 54] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 55] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 56] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 57] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 58] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 59] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - SyntaxKind[SyntaxKind["BacktickToken"] = 59] = "BacktickToken"; + SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 60] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 61] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 62] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 63] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 64] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 65] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 66] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 67] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 69] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 70] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 71] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 72] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 74] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 73] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 75] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 74] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 75] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 76] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 77] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 78] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 79] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 80] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 81] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 82] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 83] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 84] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 85] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 86] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 87] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 88] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 89] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 90] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 91] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 92] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 93] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 94] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 95] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 96] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 97] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 98] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 99] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 100] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 101] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 102] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 103] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 104] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 105] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 106] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 107] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 108] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 109] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 76] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 77] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 78] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 79] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 80] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 81] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 82] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 83] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 84] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 85] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 86] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 87] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 88] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 89] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 90] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 91] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 92] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 93] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 94] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 95] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 96] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 97] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 98] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 99] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 100] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 101] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 102] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 103] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 104] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 105] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 106] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 107] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 108] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 109] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 110] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 111] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 110] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 111] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 112] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 113] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 114] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 115] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 116] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 117] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 118] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 112] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 113] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 114] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 115] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 116] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 117] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 118] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 119] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 120] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 119] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 120] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 121] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 122] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 123] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 124] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 125] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 126] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 127] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 128] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 129] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 130] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 131] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 132] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 133] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 134] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 135] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 136] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 137] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 138] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 139] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 140] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 141] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 142] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 143] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 144] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 121] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 122] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 123] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 124] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 125] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 126] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 127] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 128] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 129] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 130] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 131] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 132] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 133] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 134] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 135] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 136] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 137] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 138] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 139] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 140] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 141] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 142] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 143] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 144] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 145] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 146] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 147] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 148] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 149] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 150] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 151] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 152] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 153] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 154] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 155] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 156] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 157] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 158] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 159] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 160] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 161] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 162] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 163] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 164] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 165] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 166] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 167] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 168] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 169] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 170] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 171] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 172] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 173] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 174] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 175] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 176] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 177] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 178] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 179] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 180] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 181] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 182] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 183] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 184] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 185] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 186] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 187] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 188] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 189] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 190] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 191] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 192] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 193] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 194] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 195] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 196] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 197] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 198] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 199] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 200] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 201] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 202] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 203] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 204] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 205] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 206] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 207] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 208] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 209] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 210] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 211] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 212] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 213] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 214] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 215] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 216] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 217] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 218] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 219] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 220] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 221] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 222] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 223] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 224] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 225] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 226] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 227] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 228] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 229] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 230] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 231] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 232] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 233] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 234] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 235] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 236] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 237] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 238] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 239] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 240] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 241] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 242] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 243] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 244] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 245] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 246] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 247] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 248] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 249] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 250] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 251] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 252] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 253] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 254] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 255] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 256] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 257] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 258] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 259] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 260] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 261] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 262] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 263] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 264] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 265] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 266] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 267] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 268] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 269] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 270] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 271] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 272] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 273] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 274] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 275] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 276] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 277] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 278] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 279] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 280] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 281] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 282] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 283] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 284] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 285] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 286] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 287] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 288] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 289] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 290] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 291] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 292] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 293] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 297] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 298] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 299] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 300] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 301] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 302] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 303] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 304] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 305] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 306] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 307] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 308] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 309] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 310] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 311] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 312] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 294] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 295] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 296] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 297] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 298] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 299] = "JSDocVariadicType"; + // https://jsdoc.app/about-namepaths.html + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 300] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 301] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 302] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 303] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 304] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 305] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 306] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 307] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 308] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 309] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 310] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 311] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 312] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 313] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 314] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 315] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 316] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 313] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 317] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 314] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 315] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 316] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 317] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 318] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 318] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 319] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 320] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 321] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 322] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 323] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 319] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 324] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 61] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 72] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 74] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 74] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 76] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 111] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 76] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 151] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 112] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 120] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 167] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 187] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 74] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 151] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 312] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 300] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 312] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 74] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 224] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 240] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 152] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 292] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 316] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 304] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 316] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 121] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 151] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3138,20 +3258,21 @@ var ts; NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain"; + NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 1024] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2048] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4096] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData"; // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid // walking the tree if the flags are not set. However, these flags are just a approximation // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. @@ -3161,23 +3282,23 @@ var ts; // removal, it is likely that users will add the import anyway. // The advantage of this approach is its simplicity. For the case of batch compilation, // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta"; - NodeFlags[NodeFlags["JSDoc"] = 2097152] = "JSDoc"; - /* @internal */ NodeFlags[NodeFlags["Ambient"] = 4194304] = "Ambient"; - /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 8388608] = "InWithStatement"; - NodeFlags[NodeFlags["JsonFile"] = 16777216] = "JsonFile"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta"; + NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc"; + /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient"; + /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement"; + NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 12679168] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags"; // Represents all flags that are potentially set once and // never cleared on SourceFiles which get re-used in between incremental parses. // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. - /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags"; + /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -3216,7 +3337,10 @@ var ts; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; - RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + RelationComparisonResult[RelationComparisonResult["Reported"] = 4] = "Reported"; + RelationComparisonResult[RelationComparisonResult["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable"; + RelationComparisonResult[RelationComparisonResult["ReportsUnreliable"] = 16] = "ReportsUnreliable"; + RelationComparisonResult[RelationComparisonResult["ReportsMask"] = 24] = "ReportsMask"; })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ var GeneratedIdentifierFlags; @@ -3252,6 +3376,8 @@ var ts; /* @internal */ TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator"; /* @internal */ + TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; + /* @internal */ TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; @@ -3267,12 +3393,13 @@ var ts; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; - FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Call"] = 512] = "Call"; + FlowFlags[FlowFlags["Referenced"] = 1024] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 2048] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 4096] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 8192] = "AfterFinally"; /** @internal */ - FlowFlags[FlowFlags["Cached"] = 8192] = "Cached"; + FlowFlags[FlowFlags["Cached"] = 16384] = "Cached"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -3282,6 +3409,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3302,6 +3436,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3367,7 +3503,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3417,27 +3552,40 @@ var ts; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + TypePredicateKind[TypePredicateKind["AssertsThis"] = 2] = "AssertsThis"; + TypePredicateKind[TypePredicateKind["AssertsIdentifier"] = 3] = "AssertsIdentifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3475,32 +3623,32 @@ var ts; SymbolFlags[SymbolFlags["All"] = 67108863] = "All"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 67220415] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 67897832] = "Type"; + SymbolFlags[SymbolFlags["Value"] = 111551] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 788968] = "Type"; SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; // Variables can be redeclared, but can not redeclare a block-scoped declaration with the // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 67220414] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 111550] = "FunctionScopedVariableExcludes"; // Block-scoped declarations are not allowed to be re-declared // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 67220415] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 67220415] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 111551] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 111551] = "ParameterExcludes"; SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 68008959] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 67219887] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 68008383] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 67897736] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 68008191] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 68008831] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 110991] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899503] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 788872] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 110735] = "ValueModuleExcludes"; SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 67212223] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 67154879] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 67187647] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 67635688] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 67897832] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 103359] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 46015] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 78783] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 526824] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 788968] = "TypeAliasExcludes"; SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; @@ -3508,11 +3656,15 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; /* @internal */ + SymbolFlags[SymbolFlags["ExportSupportsDefaultModifier"] = 112] = "ExportSupportsDefaultModifier"; + /* @internal */ + SymbolFlags[SymbolFlags["ExportDoesNotSupportDefaultModifier"] = -113] = "ExportDoesNotSupportDefaultModifier"; + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable"; /* @internal */ - SymbolFlags[SymbolFlags["LateBindingContainer"] = 6240] = "LateBindingContainer"; + SymbolFlags[SymbolFlags["LateBindingContainer"] = 6256] = "LateBindingContainer"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ var EnumKind; @@ -3750,7 +3902,9 @@ var ts; InferencePriority[InferencePriority["LiteralKeyof"] = 32] = "LiteralKeyof"; InferencePriority[InferencePriority["NoConstraints"] = 64] = "NoConstraints"; InferencePriority[InferencePriority["AlwaysStrict"] = 128] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 256] = "MaxValue"; InferencePriority[InferencePriority["PriorityImpliesCombination"] = 56] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ var InferenceFlags; @@ -3828,6 +3982,9 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + // NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind. + // Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES + // module kind). ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); @@ -4412,7 +4569,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -4566,6 +4723,38 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + /* @internal */ + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; /** * Returns true if file status changed */ @@ -4592,6 +4781,8 @@ var ts; ts.getFileWatcherEventKind = getFileWatcherEventKind; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + /*@internal*/ + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4696,6 +4887,32 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + /** + * patch writefile to create folder before writing the file + */ + /*@internal*/ + function patchWriteFileEnsuringDirectory(sys) { + // patch writefile to create folder before writing the file + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -4712,12 +4929,14 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does // not actually work. var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -4729,9 +4948,12 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; + var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); var FileSystemEntryKind; @@ -4742,6 +4964,7 @@ var ts; var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -4808,8 +5031,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -4835,6 +5060,90 @@ var ts; base64encode: function (input) { return bufferFrom(input).toString("base64"); }, }; return nodeSystem; + /** + * Uses the builtin inspector APIs to capture a CPU profile + * See https://nodejs.org/api/inspector.html#inspector_example_usage for details + */ + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + /** + * Strips non-TS paths from the profile, so users with private projects shouldn't + * need to worry about leaking paths by submitting a cpu profile to us + */ + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + // do nothing and ignore fallible fs operation + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + // do nothing and ignore fallible fs operation + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { // See https://github.com/Microsoft/TypeScript/issues/25652 return Buffer.from && Buffer.from !== Int8Array.from @@ -4878,7 +5187,7 @@ var ts; return useNonPollingWatchers ? createNonPollingWatchFile() : // Default to do not use polling interval as it is before this experiment branch - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, /*pollingInterval*/ undefined); }; } function getWatchDirectory() { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows @@ -4952,7 +5261,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -5010,6 +5319,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } /** Watcher for the file system entry depending on whether it is missing or present */ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : @@ -5026,6 +5341,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -5050,7 +5366,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); // Watch the missing file or directory or error presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; @@ -5062,11 +5380,23 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations + // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } /** * Watch the file or directory using fs.watchFile since fs.watch threw exception * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } /** @@ -5099,7 +5429,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -5127,7 +5457,14 @@ var ts; // Default is UTF-8 with no byte order mark return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); // If a BOM is required, emit one if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; @@ -5144,6 +5481,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -5199,6 +5537,7 @@ var ts; return fileSystemEntryExists(path, 1 /* Directory */); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } function realpath(path) { @@ -5276,16 +5615,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -5297,14 +5626,7 @@ var ts; } if (sys) { // patch writefile to create folder before writing the file - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -5323,10 +5645,9 @@ var ts; /* @internal */ var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; } - // tslint:disable-next-line variable-name ts.Diagnostics = { Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), @@ -5389,7 +5710,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -5444,7 +5764,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -5542,6 +5861,7 @@ var ts; A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -5574,7 +5894,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -5588,6 +5908,16 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(1359, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_1359", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(1360, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_1360", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), 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."), @@ -5631,7 +5961,7 @@ var ts; Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), @@ -5879,6 +6209,9 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -6001,6 +6334,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), 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}'."), @@ -6087,6 +6428,9 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -6097,6 +6441,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -6122,6 +6467,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -6309,6 +6655,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + 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}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -6327,9 +6674,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), 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}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -6368,6 +6717,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -6454,6 +6805,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -6483,6 +6836,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6600,6 +6954,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -6610,94 +6972,95 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 73 /* Identifier */; + return token >= 75 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119 /* AbstractKeyword */, - any: 121 /* AnyKeyword */, - as: 120 /* AsKeyword */, - bigint: 147 /* BigIntKeyword */, - boolean: 124 /* BooleanKeyword */, - break: 74 /* BreakKeyword */, - case: 75 /* CaseKeyword */, - catch: 76 /* CatchKeyword */, - class: 77 /* ClassKeyword */, - continue: 79 /* ContinueKeyword */, - const: 78 /* ConstKeyword */ + abstract: 121 /* AbstractKeyword */, + any: 124 /* AnyKeyword */, + as: 122 /* AsKeyword */, + asserts: 123 /* AssertsKeyword */, + bigint: 150 /* BigIntKeyword */, + boolean: 127 /* BooleanKeyword */, + break: 76 /* BreakKeyword */, + case: 77 /* CaseKeyword */, + catch: 78 /* CatchKeyword */, + class: 79 /* ClassKeyword */, + continue: 81 /* ContinueKeyword */, + const: 80 /* ConstKeyword */ }, - _a["" + "constructor"] = 125 /* ConstructorKeyword */, - _a.debugger = 80 /* DebuggerKeyword */, - _a.declare = 126 /* DeclareKeyword */, - _a.default = 81 /* DefaultKeyword */, - _a.delete = 82 /* DeleteKeyword */, - _a.do = 83 /* DoKeyword */, - _a.else = 84 /* ElseKeyword */, - _a.enum = 85 /* EnumKeyword */, - _a.export = 86 /* ExportKeyword */, - _a.extends = 87 /* ExtendsKeyword */, - _a.false = 88 /* FalseKeyword */, - _a.finally = 89 /* FinallyKeyword */, - _a.for = 90 /* ForKeyword */, - _a.from = 145 /* FromKeyword */, - _a.function = 91 /* FunctionKeyword */, - _a.get = 127 /* GetKeyword */, - _a.if = 92 /* IfKeyword */, - _a.implements = 110 /* ImplementsKeyword */, - _a.import = 93 /* ImportKeyword */, - _a.in = 94 /* InKeyword */, - _a.infer = 128 /* InferKeyword */, - _a.instanceof = 95 /* InstanceOfKeyword */, - _a.interface = 111 /* InterfaceKeyword */, - _a.is = 129 /* IsKeyword */, - _a.keyof = 130 /* KeyOfKeyword */, - _a.let = 112 /* LetKeyword */, - _a.module = 131 /* ModuleKeyword */, - _a.namespace = 132 /* NamespaceKeyword */, - _a.never = 133 /* NeverKeyword */, - _a.new = 96 /* NewKeyword */, - _a.null = 97 /* NullKeyword */, - _a.number = 136 /* NumberKeyword */, - _a.object = 137 /* ObjectKeyword */, - _a.package = 113 /* PackageKeyword */, - _a.private = 114 /* PrivateKeyword */, - _a.protected = 115 /* ProtectedKeyword */, - _a.public = 116 /* PublicKeyword */, - _a.readonly = 134 /* ReadonlyKeyword */, - _a.require = 135 /* RequireKeyword */, - _a.global = 146 /* GlobalKeyword */, - _a.return = 98 /* ReturnKeyword */, - _a.set = 138 /* SetKeyword */, - _a.static = 117 /* StaticKeyword */, - _a.string = 139 /* StringKeyword */, - _a.super = 99 /* SuperKeyword */, - _a.switch = 100 /* SwitchKeyword */, - _a.symbol = 140 /* SymbolKeyword */, - _a.this = 101 /* ThisKeyword */, - _a.throw = 102 /* ThrowKeyword */, - _a.true = 103 /* TrueKeyword */, - _a.try = 104 /* TryKeyword */, - _a.type = 141 /* TypeKeyword */, - _a.typeof = 105 /* TypeOfKeyword */, - _a.undefined = 142 /* UndefinedKeyword */, - _a.unique = 143 /* UniqueKeyword */, - _a.unknown = 144 /* UnknownKeyword */, - _a.var = 106 /* VarKeyword */, - _a.void = 107 /* VoidKeyword */, - _a.while = 108 /* WhileKeyword */, - _a.with = 109 /* WithKeyword */, - _a.yield = 118 /* YieldKeyword */, - _a.async = 122 /* AsyncKeyword */, - _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a["" + "constructor"] = 128 /* ConstructorKeyword */, + _a.debugger = 82 /* DebuggerKeyword */, + _a.declare = 129 /* DeclareKeyword */, + _a.default = 83 /* DefaultKeyword */, + _a.delete = 84 /* DeleteKeyword */, + _a.do = 85 /* DoKeyword */, + _a.else = 86 /* ElseKeyword */, + _a.enum = 87 /* EnumKeyword */, + _a.export = 88 /* ExportKeyword */, + _a.extends = 89 /* ExtendsKeyword */, + _a.false = 90 /* FalseKeyword */, + _a.finally = 91 /* FinallyKeyword */, + _a.for = 92 /* ForKeyword */, + _a.from = 148 /* FromKeyword */, + _a.function = 93 /* FunctionKeyword */, + _a.get = 130 /* GetKeyword */, + _a.if = 94 /* IfKeyword */, + _a.implements = 112 /* ImplementsKeyword */, + _a.import = 95 /* ImportKeyword */, + _a.in = 96 /* InKeyword */, + _a.infer = 131 /* InferKeyword */, + _a.instanceof = 97 /* InstanceOfKeyword */, + _a.interface = 113 /* InterfaceKeyword */, + _a.is = 132 /* IsKeyword */, + _a.keyof = 133 /* KeyOfKeyword */, + _a.let = 114 /* LetKeyword */, + _a.module = 134 /* ModuleKeyword */, + _a.namespace = 135 /* NamespaceKeyword */, + _a.never = 136 /* NeverKeyword */, + _a.new = 98 /* NewKeyword */, + _a.null = 99 /* NullKeyword */, + _a.number = 139 /* NumberKeyword */, + _a.object = 140 /* ObjectKeyword */, + _a.package = 115 /* PackageKeyword */, + _a.private = 116 /* PrivateKeyword */, + _a.protected = 117 /* ProtectedKeyword */, + _a.public = 118 /* PublicKeyword */, + _a.readonly = 137 /* ReadonlyKeyword */, + _a.require = 138 /* RequireKeyword */, + _a.global = 149 /* GlobalKeyword */, + _a.return = 100 /* ReturnKeyword */, + _a.set = 141 /* SetKeyword */, + _a.static = 119 /* StaticKeyword */, + _a.string = 142 /* StringKeyword */, + _a.super = 101 /* SuperKeyword */, + _a.switch = 102 /* SwitchKeyword */, + _a.symbol = 143 /* SymbolKeyword */, + _a.this = 103 /* ThisKeyword */, + _a.throw = 104 /* ThrowKeyword */, + _a.true = 105 /* TrueKeyword */, + _a.try = 106 /* TryKeyword */, + _a.type = 144 /* TypeKeyword */, + _a.typeof = 107 /* TypeOfKeyword */, + _a.undefined = 145 /* UndefinedKeyword */, + _a.unique = 146 /* UniqueKeyword */, + _a.unknown = 147 /* UnknownKeyword */, + _a.var = 108 /* VarKeyword */, + _a.void = 109 /* VoidKeyword */, + _a.while = 110 /* WhileKeyword */, + _a.with = 111 /* WithKeyword */, + _a.yield = 120 /* YieldKeyword */, + _a.async = 125 /* AsyncKeyword */, + _a.await = 126 /* AwaitKeyword */, + _a.of = 151 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - 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 */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 74 /* CaretEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6744,6 +7107,14 @@ var ts; */ 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,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 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, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 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, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 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, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 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, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + /** + * Generated by scripts/regenerate-unicode-identifier-parts.js on node v12.4.0 with unicode 12.1 + * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords + * unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and + * unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start + */ + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 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, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 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, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 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, 2809, 2809, 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, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 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, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 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, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 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, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 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, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 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, 43824, 43866, 43868, 43879, 43888, 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, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 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, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -6770,15 +7141,17 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -6951,6 +7324,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7274,11 +7648,12 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -7302,17 +7677,18 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */; }, + isIdentifier: function () { return token === 75 /* Identifier */ || token > 111 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -7322,6 +7698,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -7336,6 +7713,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7435,7 +7821,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -7643,6 +8029,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024 /* UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: @@ -7725,21 +8112,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92 /* backslash */) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024 /* UnicodeEscape */; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters pos += 6; start = pos; @@ -7763,7 +8170,7 @@ var ts; } } } - return token = 73 /* Identifier */; + return token = 75 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -7827,14 +8234,14 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); // Special handling for shebang if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); @@ -7898,12 +8305,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 34 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* ExclamationEqualsToken */; } pos++; - return token = 52 /* ExclamationToken */; + return token = 53 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -7912,19 +8319,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* PercentEqualsToken */; + return pos += 2, token = 68 /* PercentEqualsToken */; } pos++; - return token = 43 /* PercentToken */; + return token = 44 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 54 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* AmpersandEqualsToken */; + return pos += 2, token = 72 /* AmpersandEqualsToken */; } pos++; - return token = 49 /* AmpersandToken */; + return token = 50 /* AmpersandToken */; case 40 /* openParen */: pos++; return token = 20 /* OpenParenToken */; @@ -7933,13 +8340,13 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AsteriskEqualsToken */; + return pos += 2, token = 65 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 41 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -7947,28 +8354,28 @@ var ts; asteriskSeen = true; continue; } - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 44 /* PlusPlusToken */; + return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* PlusEqualsToken */; + return pos += 2, token = 63 /* PlusEqualsToken */; } pos++; - return token = 38 /* PlusToken */; + return token = 39 /* PlusToken */; case 44 /* comma */: pos++; return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 45 /* MinusMinusToken */; + return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* MinusEqualsToken */; + return pos += 2, token = 64 /* MinusEqualsToken */; } pos++; - return token = 39 /* MinusToken */; + return token = 40 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -8029,10 +8436,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* SlashEqualsToken */; + return pos += 2, token = 67 /* SlashEqualsToken */; } pos++; - return token = 42 /* SlashToken */; + return token = 43 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -8090,7 +8497,7 @@ var ts; return token; case 58 /* colon */: pos++; - return token = 57 /* ColonToken */; + return token = 58 /* ColonToken */; case 59 /* semicolon */: pos++; return token = 26 /* SemicolonToken */; @@ -8106,20 +8513,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 46 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 31 /* LessThanEqualsToken */; + return pos += 2, token = 32 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 29 /* LessThanSlashToken */; + return pos += 2, token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8132,15 +8539,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 33 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 37 /* EqualsGreaterThanToken */; + return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8152,10 +8559,18 @@ var ts; } } pos++; - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 56 /* QuestionToken */; + if (text.charCodeAt(pos) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28 /* QuestionDotToken */; + } + if (text.charCodeAt(pos) === 63 /* question */) { + pos++; + return token = 60 /* QuestionQuestionToken */; + } + return token = 57 /* QuestionToken */; case 91 /* openBracket */: pos++; return token = 22 /* OpenBracketToken */; @@ -8164,10 +8579,10 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* CaretEqualsToken */; + return pos += 2, token = 74 /* CaretEqualsToken */; } pos++; - return token = 51 /* CaretToken */; + return token = 52 /* CaretToken */; case 123 /* openBrace */: pos++; return token = 18 /* OpenBraceToken */; @@ -8182,26 +8597,34 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 55 /* BarBarToken */; + return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* BarEqualsToken */; + return pos += 2, token = 73 /* BarEqualsToken */; } pos++; - return token = 50 /* BarToken */; + return token = 51 /* BarToken */; case 125 /* closeBrace */: pos++; return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 53 /* TildeToken */; + return token = 54 /* TildeToken */; case 64 /* at */: pos++; - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 92 /* backslash */: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -8210,9 +8633,9 @@ var ts; return token = 0 /* Unknown */; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { tokenValue += scanIdentifierParts(); @@ -8220,44 +8643,44 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1 /* PrecedingLineBreak */; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0 /* Unknown */; } } } function reScanGreaterToken() { - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 47 /* GreaterThanGreaterThanToken */; + return token = 48 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 32 /* GreaterThanEqualsToken */; + return token = 33 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 42 /* SlashToken */ || token === 65 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -8319,12 +8742,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46 /* LessThanLessThanToken */) { + if (token === 47 /* LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57 /* QuestionToken */; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -8334,10 +8762,10 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 29 /* LessThanSlashToken */; + return token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; @@ -8346,7 +8774,7 @@ var ts; // First non-whitespace character on this line. var firstNonWhitespace = 0; // These initial values are special because the first line is: - // firstNonWhitespace = 0 to indicate that we want leading whitspace, + // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { @@ -8380,17 +8808,22 @@ var ts; // they allow dashes function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; + // An identifier or keyword has already been parsed - check for a `-` and then append it and everything after it to the token + // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token + // Any caller should be expecting this behavior and should only read the pos or token value after calling it. while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45 /* minus */) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -8408,12 +8841,12 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9 /* tab */: case 11 /* verticalTab */: @@ -8424,13 +8857,13 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 123 /* openBrace */: return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: @@ -8440,23 +8873,44 @@ var ts; case 93 /* closeBracket */: return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 62 /* greaterThan */: - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 44 /* comma */: return token = 27 /* CommaToken */; case 46 /* dot */: return token = 24 /* DotToken */; case 96 /* backtick */: - return token = 59 /* BacktickToken */; - } - if (isIdentifierStart(ch, 99 /* Latest */)) { - while (isIdentifierPart(text.charCodeAt(pos), 99 /* Latest */) && pos < end) { + return token = 61 /* BacktickToken */; + case 92 /* backslash */: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0 /* Unknown */; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -8532,13 +8986,40 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; } } ts.createScanner = createScanner; + /* @internal */ + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt + var size = str.length; + // Account for out-of-bounds indices: + if (i < 0 || i >= size) { + return undefined; // String.codePointAt returns `undefined` for OOB indexes + } + // Get the first code unit + var first = str.charCodeAt(i); + // check if it’s the start of a surrogate pair + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { // high surrogate and there is a next code unit + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + /* @internal */ + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -8618,6 +9099,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str += " "; }, @@ -8705,7 +9188,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -8793,28 +9276,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144 /* HasAggregatedChildData */)) { + if (!(node.flags & 524288 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 262144 /* HasAggregatedChildData */; + node.flags |= 524288 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 288 /* SourceFile */) { node = node.parent; } return node; @@ -8822,11 +9305,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return true; } return false; @@ -8911,7 +9394,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -8994,7 +9477,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 === 313 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 317 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9013,7 +9496,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9059,6 +9542,8 @@ var ts; ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } + // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text + // had to include a backslash: `not \${a} substitution`. 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. @@ -9071,15 +9556,21 @@ var ts; return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } case 14 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings - return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings - return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 17 /* TemplateTail */: - return "}" + escapeText(node.text, 96 /* backtick */) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + switch (node.kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + return "`" + rawText + "`"; + case 15 /* TemplateHead */: + return "`" + rawText + "${"; + case 16 /* TemplateMiddle */: + return "}" + rawText + "${"; + case 17 /* TemplateTail */: + return "}" + rawText + "`"; + } + break; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 13 /* RegularExpressionLiteral */: @@ -9105,7 +9596,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 241 /* VariableDeclaration */ && node.parent.kind === 278 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9137,16 +9628,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 248 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 288 /* SourceFile */ || + node.kind === 248 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -9158,9 +9649,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 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9174,24 +9665,61 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /** + * Returns whether the source file will be treated as if it were in strict mode at runtime. + */ + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + // We can only verify strict mode for JS/TS files + switch (node.scriptKind) { + case 1 /* JS */: + case 3 /* TS */: + case 2 /* JSX */: + case 4 /* TSX */: + break; + default: + return false; + } + // Strict mode does not matter for declaration files. + if (node.isDeclarationFile) { + return false; + } + // If `alwaysStrict` is set, then treat the file as strict. + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + // Starting with a "use strict" directive indicates the file is strict. + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + // ECMAScript Modules are always strict. + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + // Other modules are strict unless otherwise specified. + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 278 /* CatchClause */: + case 248 /* ModuleDeclaration */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 219 /* Block */: + case 222 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9201,9 +9729,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 299 /* JSDocSignature */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 303 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9213,25 +9741,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9241,8 +9769,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9251,15 +9779,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 224 /* VariableStatement */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -9289,13 +9817,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -9306,11 +9834,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9355,7 +9883,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 222 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9369,7 +9897,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* 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 @@ -9378,25 +9906,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 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9404,6 +9932,7 @@ var ts; // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9433,7 +9962,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -9445,19 +9974,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 101 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 95 /* ImportKeyword */; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 95 /* ImportKeyword */ + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 225 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9466,11 +10001,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 155 /* Parameter */ || + node.kind === 154 /* TypeParameter */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 201 /* ArrowFunction */ || + node.kind === 199 /* 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 '/**/' @@ -9486,48 +10021,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= node.kind && node.kind <= 187 /* LastTypeNode */) { return true; } switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: return true; - case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + case 109 /* VoidKeyword */: + return node.parent.kind !== 204 /* VoidExpression */; + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 154 /* TypeParameter */: + return node.parent.kind === 185 /* MappedType */ || node.parent.kind === 180 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 73 /* Identifier */: + case 75 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 193 /* 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 === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */ || node.kind === 193 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: - case 101 /* ThisKeyword */: { + case 152 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 103 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 171 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 187 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9536,40 +10071,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 (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= parent.kind && parent.kind <= 187 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return node === parent.constraint; - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9594,23 +10129,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 250 /* CaseBlock */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9620,26 +10155,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* 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 === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* 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); @@ -9662,10 +10197,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 173 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 168 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9675,12 +10210,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 172 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return node.properties; } } @@ -9688,14 +10223,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 282 /* EnumMember */: + case 155 /* Parameter */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 241 /* VariableDeclaration */: return true; } } @@ -9707,8 +10242,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 242 /* VariableDeclarationList */ + && node.parent.parent.kind === 224 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9719,13 +10254,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return true; } return false; @@ -9736,7 +10271,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 237 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9744,17 +10279,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 222 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 160 /* MethodDeclaration */ && node.parent.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 160 /* MethodDeclaration */ && + (node.parent.kind === 192 /* ObjectLiteralExpression */ || + node.parent.kind === 213 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9767,7 +10302,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9808,14 +10343,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 288 /* 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 150 /* ComputedPropertyName */: + case 153 /* 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 @@ -9830,9 +10365,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* 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; @@ -9843,26 +10378,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 248 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 247 /* EnumDeclaration */: + case 288 /* SourceFile */: return node; } } @@ -9872,9 +10407,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return container; } } @@ -9896,27 +10431,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* 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; @@ -9932,21 +10467,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 200 /* FunctionExpression */ || func.kind === 201 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 199 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 195 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 /* SuperKeyword */ + return node.kind === 101 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -9955,8 +10490,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 99 /* SuperKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 101 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -9964,20 +10499,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 101 /* ThisKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 103 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: return node; } return undefined; @@ -9985,10 +10520,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9997,25 +10532,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 244 /* ClassDeclaration */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* 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 === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 244 /* ClassDeclaration */; + case 155 /* 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 === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 161 /* Constructor */ + || parent.kind === 160 /* MethodDeclaration */ + || parent.kind === 163 /* SetAccessor */) + && grandparent.kind === 244 /* ClassDeclaration */; } return false; } @@ -10031,10 +10566,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10043,9 +10578,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 266 /* JsxOpeningElement */ || + parent.kind === 265 /* JsxSelfClosingElement */ || + parent.kind === 267 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10053,57 +10588,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 216 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 212 /* SpreadElement */: + case 210 /* TemplateExpression */: + case 214 /* OmittedExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 211 /* YieldExpression */: + case 205 /* AwaitExpression */: + case 218 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 152 /* QualifiedName */: + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); - case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node); + case 75 /* Identifier */: + if (node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -10113,49 +10648,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 190 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 225 /* ExpressionStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 234 /* ReturnStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 238 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 229 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 156 /* Decorator */: + case 274 /* JsxExpression */: + case 273 /* JsxSpreadAttribute */: + case 281 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10163,7 +10698,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10172,7 +10707,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 263 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10184,15 +10719,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 131072 /* JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 4194304 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10200,15 +10735,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 /* StringKeyword */ || node.typeArguments[0].kind === 136 /* NumberKeyword */); + (node.typeArguments[0].kind === 142 /* StringKeyword */ || node.typeArguments[0].kind === 139 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + if (callExpression.kind !== 195 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 75 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -10239,21 +10774,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - 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 === 60 /* EqualsToken */ && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 /* EqualsToken */ && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -10263,13 +10802,14 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(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 === 55 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -10283,14 +10823,20 @@ var ts; } 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); }); + 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 === 60 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -10316,11 +10862,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 200 /* FunctionExpression */ || e.kind === 201 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 200 /* FunctionExpression */ || + initializer.kind === 213 /* ClassExpression */ || + initializer.kind === 201 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10337,14 +10883,16 @@ 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 === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && 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 === 60 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -10352,8 +10900,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 === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -10372,19 +10920,20 @@ var ts; * my.app = self.my.app || class { } */ function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 /* ThisKeyword */ || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -10399,10 +10948,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { @@ -10417,55 +10969,116 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0]); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */) || + isEntityNameExpression(node.expression) || + isBindableStaticElementAccessExpression(node.expression, /*excludeThisKeyword*/ true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */ || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0 /* None */; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8 /* ObjectDefinePropertyExports */; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9 /* ObjectDefinePrototypeProperty */; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 60 /* EqualsToken */ || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left)) { return 0 /* None */; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } return 6 /* Prototype */; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); } + /** + * Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions + * throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand) + */ + /* @internal */ + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; + } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; + } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101 /* ThisKeyword */) { + if (lhs.expression.kind === 103 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") { // exports.name = expr OR module.exports.name = expr return 1 /* ExportsProperty */; } @@ -10488,7 +11101,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 225 /* ExpressionStatement */ && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10497,7 +11111,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10506,14 +11120,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 186 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10523,12 +11137,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 252 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 263 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 187 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10537,11 +11151,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10549,19 +11163,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 253 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 155 /* Parameter */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 280 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10575,7 +11189,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 /* JSDocTypedefTag */ || node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 315 /* JSDocTypedefTag */ || node.kind === 308 /* JSDocCallbackTag */ || node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10585,7 +11199,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 /* EqualsToken */ + node.expression.operatorToken.kind === 62 /* EqualsToken */ ? node.expression.right : undefined; } @@ -10594,18 +11208,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 /* BarBarToken */ + (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return node.initializer; } } @@ -10616,7 +11230,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 248 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10631,11 +11245,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 154 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10646,12 +11260,12 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 279 /* PropertyAssignment */ || + parent.kind === 258 /* ExportAssignment */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 225 /* ExpressionStatement */ && node.kind === 193 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10662,7 +11276,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10685,7 +11299,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10710,7 +11324,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10720,7 +11334,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 === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10733,31 +11347,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 62 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 191 /* ArrayLiteralExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10784,22 +11398,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 222 /* Block */: + case 224 /* VariableStatement */: + case 235 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return true; } return false; @@ -10816,33 +11430,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 181 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 199 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* 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 !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 202 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10864,11 +11478,12 @@ var ts; var parent = name.parent; switch (name.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -10891,8 +11506,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10900,32 +11515,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 193 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 152 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 171 /* TypeQuery */ || parent.kind === 168 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 190 /* BindingElement */: + case 257 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 261 /* ExportSpecifier */: + case 271 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10941,22 +11556,39 @@ var ts; // export = // export default // module.exports = + // {} + // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); + return node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 251 /* NamespaceExportDeclaration */ || + node.kind === 254 /* ImportClause */ && !!node.name || + node.kind === 255 /* NamespaceImport */ || + node.kind === 257 /* ImportSpecifier */ || + node.kind === 261 /* ExportSpecifier */ || + node.kind === 258 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 280 /* ShorthandPropertyAssignment */ || + node.kind === 279 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 279 /* PropertyAssignment */ ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -10970,24 +11602,24 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 112 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -11014,22 +11646,31 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 76 /* FirstKeyword */ <= token && token <= 151 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 121 /* FirstContextualKeyword */ <= token && token <= 151 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 112 /* FirstFutureReservedWord */ <= token && token <= 120 /* LastFutureReservedWord */; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -11053,14 +11694,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11074,10 +11715,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11090,7 +11731,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 /* PlusToken */ || node.operator === 39 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -11110,10 +11751,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 /* ComputedPropertyName */ || name.kind === 194 /* ElementAccessExpression */)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; /** @@ -11127,12 +11771,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11148,7 +11792,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -11159,11 +11803,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 75 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -11178,7 +11822,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 75 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -11187,11 +11831,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 155 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 190 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11199,15 +11843,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 161 /* Constructor */ + || kind === 200 /* FunctionExpression */ + || kind === 243 /* FunctionDeclaration */ + || kind === 201 /* ArrowFunction */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 248 /* ModuleDeclaration */ + || kind === 288 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11226,38 +11870,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operator) { - case 41 /* AsteriskAsteriskToken */: - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 42 /* AsteriskAsteriskToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 1 /* Right */; } } @@ -11266,15 +11910,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 208 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 206 /* PrefixUnaryExpression */ || expression.kind === 207 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11284,73 +11928,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 197 /* TaggedTemplateExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 19; - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 73 /* Identifier */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 75 /* Identifier */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 210 /* TemplateExpression */: + case 199 /* ParenthesizedExpression */: + case 214 /* OmittedExpression */: return 20; default: return -1; @@ -11359,41 +12003,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: + return 4; + case 56 /* BarBarToken */: return 5; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return 6; - case 50 /* BarToken */: + case 51 /* BarToken */: return 7; - case 51 /* CaretToken */: + case 52 /* CaretToken */: return 8; - case 49 /* AmpersandToken */: + case 50 /* AmpersandToken */: return 9; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return 10; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: return 11; - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 38 /* PlusToken */: - case 39 /* MinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: return 13; - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: return 14; - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -11470,6 +12116,10 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -11477,7 +12127,8 @@ var ts; // There is no reason for this other than that JSON.stringify does not handle it either. var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + // Template strings should be preserved as much as possible + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -11506,22 +12157,23 @@ var ts; } ts.escapeString = escapeString; /** - * Strip off existed single quotes or double quotes from a given string + * Strip off existed surrounding single quotes, double quotes, or backticks from a given string * * @return non-quoted string */ function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 /* singleQuote */ || + charCode === 34 /* doubleQuote */ || + charCode === 96 /* backtick */; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0 /* nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); @@ -11572,6 +12224,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -11583,7 +12236,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -11593,17 +12246,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -11617,6 +12282,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -11636,6 +12302,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -11650,12 +12318,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -11663,7 +12331,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -11719,7 +12387,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -11838,6 +12506,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; /** Get the type annotation for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); @@ -11859,11 +12528,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 75 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101 /* ThisKeyword */; + return id.originalKeywordKind === 103 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -11874,10 +12543,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 163 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11897,10 +12566,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 162 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 163 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11946,7 +12615,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 === 297 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12186,7 +12855,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 73 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 75 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -12194,29 +12863,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117 /* StaticKeyword */: return 32 /* Static */; - case 116 /* PublicKeyword */: return 4 /* Public */; - case 115 /* ProtectedKeyword */: return 16 /* Protected */; - case 114 /* PrivateKeyword */: return 8 /* Private */; - case 119 /* AbstractKeyword */: return 128 /* Abstract */; - case 86 /* ExportKeyword */: return 1 /* Export */; - case 126 /* DeclareKeyword */: return 2 /* Ambient */; - case 78 /* ConstKeyword */: return 2048 /* Const */; - case 81 /* DefaultKeyword */: return 512 /* Default */; - case 122 /* AsyncKeyword */: return 256 /* Async */; - case 134 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 119 /* StaticKeyword */: return 32 /* Static */; + case 118 /* PublicKeyword */: return 4 /* Public */; + case 117 /* ProtectedKeyword */: return 16 /* Protected */; + case 116 /* PrivateKeyword */: return 8 /* Private */; + case 121 /* AbstractKeyword */: return 128 /* Abstract */; + case 88 /* ExportKeyword */: return 1 /* Export */; + case 129 /* DeclareKeyword */: return 2 /* Ambient */; + case 80 /* ConstKeyword */: return 2048 /* Const */; + case 83 /* DefaultKeyword */: return 512 /* Default */; + case 125 /* AsyncKeyword */: return 256 /* Async */; + case 137 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 /* BarBarToken */ - || token === 54 /* AmpersandAmpersandToken */ - || token === 52 /* ExclamationToken */; + return token === 56 /* BarBarToken */ + || token === 55 /* AmpersandAmpersandToken */ + || token === 53 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 /* FirstAssignment */ && token <= 72 /* LastAssignment */; + return token >= 62 /* FirstAssignment */ && token <= 74 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -12229,14 +12898,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 /* EqualsToken */ + ? node.operatorToken.kind === 62 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -12244,8 +12913,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 192 /* ObjectLiteralExpression */ + || kind === 191 /* ArrayLiteralExpression */; } return false; } @@ -12255,9 +12924,15 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function isDottedName(node) { + return node.kind === 75 /* Identifier */ || node.kind === 103 /* ThisKeyword */ || + node.kind === 193 /* PropertyAccessExpression */ && isDottedName(node.expression) || + node.kind === 199 /* ParenthesizedExpression */ && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -12273,21 +12948,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 192 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 191 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12585,8 +13260,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12663,35 +13338,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 208 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 279 /* 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 277 /* ShorthandPropertyAssignment */: + case 280 /* 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 188 /* ArrayLiteralExpression */: + case 191 /* 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 === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12737,8 +13412,8 @@ var ts; /** * Mutates the map with newMap such that keys in map will be same as newMap. */ - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; // Needs update map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); @@ -12752,6 +13427,15 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + /** + * Mutates the map with newMap such that keys in map will be same as newMap. + */ + function mutateMap(map, newMap, options) { + // Needs update + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; // Add new values that are not already present newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { @@ -12761,7 +13445,6 @@ var ts; }); } ts.mutateMap = mutateMap; - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -12846,32 +13529,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) - || kind === 121 /* AnyKeyword */ - || kind === 144 /* UnknownKeyword */ - || kind === 136 /* NumberKeyword */ - || kind === 147 /* BigIntKeyword */ - || kind === 137 /* ObjectKeyword */ - || kind === 124 /* BooleanKeyword */ - || kind === 139 /* StringKeyword */ - || kind === 140 /* SymbolKeyword */ - || kind === 101 /* ThisKeyword */ - || kind === 107 /* VoidKeyword */ - || kind === 142 /* UndefinedKeyword */ - || kind === 97 /* NullKeyword */ - || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + return (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) + || kind === 124 /* AnyKeyword */ + || kind === 147 /* UnknownKeyword */ + || kind === 139 /* NumberKeyword */ + || kind === 150 /* BigIntKeyword */ + || kind === 140 /* ObjectKeyword */ + || kind === 127 /* BooleanKeyword */ + || kind === 142 /* StringKeyword */ + || kind === 143 /* SymbolKeyword */ + || kind === 103 /* ThisKeyword */ + || kind === 109 /* VoidKeyword */ + || kind === 145 /* UndefinedKeyword */ + || kind === 99 /* NullKeyword */ + || kind === 136 /* NeverKeyword */ + || kind === 215 /* ExpressionWithTypeArguments */ + || kind === 293 /* JSDocAllType */ + || kind === 294 /* JSDocUnknownType */ + || kind === 295 /* JSDocNullableType */ + || kind === 296 /* JSDocNonNullableType */ + || kind === 297 /* JSDocOptionalType */ + || kind === 298 /* JSDocFunctionType */ + || kind === 299 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */ || node.kind === 194 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -12884,6 +13567,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -12991,7 +13678,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13108,17 +13795,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 154 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245 /* InterfaceDeclaration */) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 161 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13148,14 +13835,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 241 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 242 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 224 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13219,7 +13906,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13301,27 +13989,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: var expr = hostNode.expression; + if (expr.kind === 208 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + expr = expr.left; + } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13333,6 +14024,17 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + /** @internal */ + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -13345,39 +14047,46 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return declaration; - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: { + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 152 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: case 4 /* ThisProperty */: case 5 /* Property */: case 3 /* PrototypeProperty */: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 309 /* JSDocEnumTag */: + return nameForNamelessJSDocTypedef(declaration); + case 258 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194 /* ElementAccessExpression */: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -13400,8 +14109,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -13579,7 +14288,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 301 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13599,10 +14308,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13647,198 +14355,216 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73 /* Identifier */; + return node.kind === 75 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 152 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 153 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 154 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 155 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 157 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 158 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 159 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 161 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 164 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 165 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 166 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 163 /* SetAccessor */ || node.kind === 162 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 167 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 168 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 169 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 170 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 171 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 172 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 173 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 174 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 177 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 178 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 179 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 180 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 181 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 182 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 183 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 184 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 185 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 186 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 187 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 188 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 189 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 190 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 191 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 194 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 195 /* CallExpression */; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + return isPropertyAccessChain(node) + || isElementAccessChain(node) + || isCallChain(node); + } + ts.isOptionalChain = isOptionalChain; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 196 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 197 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 198 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -13847,376 +14573,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 199 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315 /* PartiallyEmittedExpression */) { + while (node.kind === 319 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 200 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 201 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 202 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 203 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 204 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 205 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 206 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 207 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 208 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 209 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 210 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 211 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 212 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 213 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 214 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 216 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 217 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 218 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 220 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 221 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 222 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 224 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 223 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 225 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 226 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 227 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 228 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 229 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 230 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 231 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 232 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 233 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 233 /* BreakStatement */ || node.kind === 232 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 234 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 235 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 236 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 237 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 238 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 239 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 240 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 241 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 242 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 243 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 244 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 245 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 246 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 247 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 248 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 249 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 250 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 251 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 252 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 253 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 254 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 255 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 256 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 257 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 258 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 259 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 260 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 261 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 262 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 264 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 265 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 266 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 267 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 268 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 269 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 270 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 271 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 272 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 273 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 274 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 275 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 276 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 277 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 278 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 279 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 280 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 281 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 288 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 289 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 290 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 284 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return true; default: return false; @@ -14225,105 +14951,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 283 /* UnparsedPrologue */ || + node.kind === 287 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 292 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 293 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 294 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 295 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 296 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 297 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 298 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 299 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297 /* JSDocComment */; + return node.kind === 301 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302 /* JSDocAuthorTag */; + return node.kind === 306 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301 /* JSDocAugmentsTag */; + return node.kind === 305 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303 /* JSDocClassTag */; + return node.kind === 307 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305 /* JSDocEnumTag */; + return node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308 /* JSDocThisTag */; + return node.kind === 312 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307 /* JSDocReturnTag */; + return node.kind === 311 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309 /* JSDocTypeTag */; + return node.kind === 313 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310 /* JSDocTemplateTag */; + return node.kind === 314 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311 /* JSDocTypedefTag */; + return node.kind === 315 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312 /* JSDocPropertyTag */; + return node.kind === 316 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 /* JSDocPropertyTag */ || node.kind === 306 /* JSDocParameterTag */; + return node.kind === 316 /* JSDocPropertyTag */ || node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298 /* JSDocTypeLiteral */; + return node.kind === 302 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 308 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299 /* JSDocSignature */; + return node.kind === 303 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14334,7 +15060,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 313 /* SyntaxList */; + return n.kind === 317 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14344,7 +15070,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 152 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14353,7 +15079,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 <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 151 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14406,17 +15132,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 81 /* DefaultKeyword */: - case 86 /* ExportKeyword */: - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 117 /* StaticKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 83 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 119 /* StaticKeyword */: return true; } return false; @@ -14429,7 +15155,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 119 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -14438,23 +15164,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ + return kind === 75 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 153 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + return kind === 75 /* Identifier */ + || kind === 188 /* ObjectBindingPattern */ + || kind === 189 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14469,13 +15195,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: return false; @@ -14484,14 +15210,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 170 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14506,29 +15232,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 161 /* Constructor */ + || kind === 158 /* PropertyDeclaration */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 166 /* IndexSignature */ + || kind === 221 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; default: return false; @@ -14538,11 +15264,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 165 /* ConstructSignature */ + || kind === 164 /* CallSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */ + || kind === 166 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14551,12 +15277,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 279 /* PropertyAssignment */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 281 /* SpreadAssignment */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14571,8 +15297,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return true; } return false; @@ -14583,8 +15309,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 189 /* ArrayBindingPattern */ + || kind === 188 /* ObjectBindingPattern */; } return false; } @@ -14592,15 +15318,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 191 /* ArrayLiteralExpression */ + || kind === 192 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 190 /* BindingElement */ + || kind === 214 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14609,9 +15335,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: return true; } return false; @@ -14632,8 +15358,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return true; } return false; @@ -14645,8 +15371,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return true; } return false; @@ -14655,26 +15381,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */ + || kind === 187 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 156 /* Decorator */: return true; default: return false; @@ -14682,12 +15408,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 195 /* CallExpression */ || node.kind === 196 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 210 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14698,34 +15424,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 73 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 197 /* TaggedTemplateExpression */: + case 191 /* ArrayLiteralExpression */: + case 199 /* ParenthesizedExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 75 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 103 /* TrueKeyword */: - case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: - case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 210 /* TemplateExpression */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 105 /* TrueKeyword */: + case 101 /* SuperKeyword */: + case 217 /* NonNullExpression */: + case 218 /* MetaProperty */: + case 95 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -14738,13 +15464,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 198 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14753,11 +15479,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 44 /* PlusPlusToken */ || - expr.operator === 45 /* MinusMinusToken */; + case 206 /* PrefixUnaryExpression */: + return expr.operator === 45 /* PlusPlusToken */ || + expr.operator === 46 /* MinusMinusToken */; default: return false; } @@ -14774,15 +15500,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 316 /* CommaListExpression */: - case 315 /* PartiallyEmittedExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: + case 201 /* ArrowFunction */: + case 208 /* BinaryExpression */: + case 212 /* SpreadElement */: + case 216 /* AsExpression */: + case 214 /* OmittedExpression */: + case 320 /* CommaListExpression */: + case 319 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14790,21 +15516,26 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 198 /* TypeAssertionExpression */ + || kind === 216 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 315 /* PartiallyEmittedExpression */; + return node.kind === 319 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 314 /* NotEmittedStatement */; + return node.kind === 318 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ + function isSyntheticReference(node) { + return node.kind === 323 /* SyntheticReferenceExpression */; + } + ts.isSyntheticReference = isSyntheticReference; + /* @internal */ function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -14812,21 +15543,42 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; /* @internal */ + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + /* @internal */ + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + /* @internal */ + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + /* @internal */ + function isExternalModuleIndicator(result) { + // Exported top-level member indicates moduleness + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; + /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 230 /* ForInStatement */ || node.kind === 231 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14850,113 +15602,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ - || kind === 73 /* Identifier */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */ + || kind === 75 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + return kind === 75 /* Identifier */ + || kind === 248 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 256 /* NamedImports */ + || kind === 255 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 248 /* ModuleDeclaration */ || node.kind === 247 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 311 /* JSDocTypedefTag */ - || kind === 304 /* JSDocCallbackTag */ - || kind === 312 /* JSDocPropertyTag */; + return kind === 201 /* ArrowFunction */ + || kind === 190 /* BindingElement */ + || kind === 244 /* ClassDeclaration */ + || kind === 213 /* ClassExpression */ + || kind === 161 /* Constructor */ + || kind === 247 /* EnumDeclaration */ + || kind === 282 /* EnumMember */ + || kind === 261 /* ExportSpecifier */ + || kind === 243 /* FunctionDeclaration */ + || kind === 200 /* FunctionExpression */ + || kind === 162 /* GetAccessor */ + || kind === 254 /* ImportClause */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 257 /* ImportSpecifier */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 271 /* JsxAttribute */ + || kind === 160 /* MethodDeclaration */ + || kind === 159 /* MethodSignature */ + || kind === 248 /* ModuleDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 255 /* NamespaceImport */ + || kind === 155 /* Parameter */ + || kind === 279 /* PropertyAssignment */ + || kind === 158 /* PropertyDeclaration */ + || kind === 157 /* PropertySignature */ + || kind === 163 /* SetAccessor */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 154 /* TypeParameter */ + || kind === 241 /* VariableDeclaration */ + || kind === 315 /* JSDocTypedefTag */ + || kind === 308 /* JSDocCallbackTag */ + || kind === 316 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 243 /* FunctionDeclaration */ + || kind === 262 /* MissingDeclaration */ + || kind === 244 /* ClassDeclaration */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 247 /* EnumDeclaration */ + || kind === 248 /* ModuleDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 258 /* ExportAssignment */ + || kind === 251 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 314 /* NotEmittedStatement */ - || kind === 318 /* EndOfDeclarationMarker */ - || kind === 317 /* MergeDeclarationMarker */; + return kind === 233 /* BreakStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 227 /* DoStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 223 /* EmptyStatement */ + || kind === 230 /* ForInStatement */ + || kind === 231 /* ForOfStatement */ + || kind === 229 /* ForStatement */ + || kind === 226 /* IfStatement */ + || kind === 237 /* LabeledStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 236 /* SwitchStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 239 /* TryStatement */ + || kind === 224 /* VariableStatement */ + || kind === 228 /* WhileStatement */ + || kind === 235 /* WithStatement */ + || kind === 318 /* NotEmittedStatement */ + || kind === 322 /* EndOfDeclarationMarker */ + || kind === 321 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 310 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 154 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 314 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14983,10 +15735,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 222 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 239 /* TryStatement */ || node.parent.kind === 278 /* CatchClause */) { return false; } } @@ -14996,83 +15748,88 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 263 /* ExternalModuleReference */ + || kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 /* ThisKeyword */ - || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + return kind === 103 /* ThisKeyword */ + || kind === 75 /* Identifier */ + || kind === 193 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 264 /* JsxElement */ + || kind === 274 /* JsxExpression */ + || kind === 265 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 268 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 271 /* JsxAttribute */ + || kind === 273 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 274 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 266 /* JsxOpeningElement */ + || kind === 265 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 275 /* CaseClause */ + || kind === 276 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 312 /* LastJSDocNode */; + return node.kind >= 292 /* FirstJSDocNode */ && node.kind <= 316 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 297 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 /* 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 >= 300 /* FirstJSDocTagNode */ && node.kind <= 312 /* LastJSDocTagNode */; + return node.kind >= 304 /* FirstJSDocTagNode */ && node.kind <= 316 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; + /* @internal */ + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; + } + ts.isOptionalChainRoot = isOptionalChainRoot; /** True if has jsdoc nodes attached to it. */ /* @internal */ // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times @@ -15100,12 +15857,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 271 /* JsxAttribute */ || node.kind === 273 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 168 /* TypeReference */ || node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15141,7 +15898,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 256 /* NamedImports */ || node.kind === 260 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15159,7 +15916,7 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature() { } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15176,6 +15933,7 @@ var ts; this.text = text; this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } + // eslint-disable-next-line prefer-const ts.objectAllocator = { getNodeConstructor: function () { return Node; }, getTokenConstructor: function () { return Node; }, @@ -15622,7 +16380,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } /** * Parse a path into an array containing a root component (at index 0) and zero or more path @@ -15700,6 +16458,37 @@ var ts; return ""; return pathComponents.slice(1).join(ts.directorySeparator); } + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); + } + return result; + } + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); + } + return [getPathFromPathComponents(aParts), getPathFromPathComponents(bParts)]; + } + // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. + // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); + } })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -15722,7 +16511,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -15803,7 +16592,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -16242,14 +17031,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; ts.supportedJSAndJsonExtensions = [".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json" /* Json */]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json" /* Json */]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -16263,7 +17052,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json" /* Json */]); + return __spreadArrays(supportedExtensions, [".json" /* Json */]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -16575,14 +17364,17 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { + function skipTypeChecking(sourceFile, options, host) { // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a // '/// ' directive. - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16686,17 +17478,15 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 288 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73 /* Identifier */) { + else if (kind === 75 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -16745,19 +17535,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 <= 148 /* LastToken */) { + if (!node || node.kind <= 151 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16765,9 +17555,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -16775,7 +17565,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16783,51 +17573,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 157 /* 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 276 /* PropertyAssignment */: + case 279 /* 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 238 /* VariableDeclaration */: + case 241 /* 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 187 /* BindingElement */: + case 190 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -16839,345 +17629,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || + case 167 /* TypePredicate */: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 174 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 180 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 187 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 181 /* ParenthesizedType */: + case 183 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 185 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 156 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* 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 242 /* InterfaceDeclaration */: + case 245 /* 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 243 /* TypeAliasDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 292 /* JSDocTypeExpression */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 297 /* JSDocOptionalType */: + case 299 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297 /* JSDocComment */: + case 301 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302 /* JSDocAuthorTag */: + case 306 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 292 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocSignature */: + case 303 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 300 /* JSDocTag */: - case 303 /* JSDocClassTag */: + case 304 /* JSDocTag */: + case 307 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17186,12 +17981,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100 /* JSON */) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -17229,7 +18026,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -17258,14 +18055,12 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; + var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17275,6 +18070,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; // Flags that dictate what parsing context we're in. For example: // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is // that some tokens that would be considered identifiers may be considered keywords. @@ -17395,18 +18191,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(225 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 39 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -17415,7 +18211,7 @@ var ts; break; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -17431,6 +18227,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17456,10 +18255,10 @@ var ts; switch (scriptKind) { case 1 /* JS */: case 2 /* JSX */: - contextFlags = 65536 /* JavaScriptFile */; + contextFlags = 131072 /* JavaScriptFile */; break; case 6 /* JSON */: - contextFlags = 65536 /* JavaScriptFile */ | 16777216 /* JsonFile */; + contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */; break; default: contextFlags = 0 /* None */; @@ -17482,11 +18281,12 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304 /* Ambient */; + contextFlags |= 8388608 /* Ambient */; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -17551,7 +18351,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(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(288 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17572,16 +18372,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048 /* DisallowInContext */); + setContextFlag(val, 4096 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 4096 /* YieldContext */); + setContextFlag(val, 8192 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 8192 /* DecoratorContext */); + setContextFlag(val, 16384 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 16384 /* AwaitContext */); + setContextFlag(val, 32768 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -17622,40 +18422,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(2048 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(4096 /* YieldContext */, func); + return doInsideOfContext(8192 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384 /* AwaitContext */, func); + return doInsideOfContext(32768 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); + return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096 /* YieldContext */); + return inContext(8192 /* YieldContext */); } function inDisallowInContext() { - return inContext(2048 /* DisallowInContext */); + return inContext(4096 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(8192 /* DecoratorContext */); + return inContext(16384 /* DecoratorContext */); } function inAwaitContext() { - return inContext(16384 /* AwaitContext */); + return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -17691,9 +18491,17 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + // if the keyword had an escape + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + // issue a parse error for the escape + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -17762,20 +18570,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 73 /* Identifier */) { + if (token() === 75 /* 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() === 118 /* YieldKeyword */ && inYieldContext()) { + if (token() === 120 /* 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() === 123 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 126 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 109 /* LastReservedWord */; + return token() > 111 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -17863,7 +18671,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 73 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 75 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -17893,7 +18701,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768 /* ThisNodeHasError */; + node.flags |= 65536 /* ThisNodeHasError */; } return node; } @@ -17905,7 +18713,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73 /* Identifier */) { + if (kind === 75 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -17926,18 +18734,18 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73 /* Identifier */); + var node = createNode(75 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 73 /* Identifier */) { + if (token() !== 75 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(73 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -17968,7 +18776,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(153 /* 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 @@ -17989,20 +18797,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 85 /* EnumKeyword */; - case 86 /* ExportKeyword */: + return nextToken() === 87 /* EnumKeyword */; + case 88 /* ExportKeyword */: nextToken(); - if (token() === 81 /* DefaultKeyword */) { + if (token() === 83 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 /* AsteriskToken */ && token() !== 120 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); - case 81 /* DefaultKeyword */: + return token() !== 41 /* AsteriskToken */ && token() !== 122 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 83 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 117 /* StaticKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + case 119 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -18015,16 +18823,16 @@ var ts; function canFollowModifier() { return token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */ - || token() === 40 /* AsteriskToken */ + || token() === 41 /* AsteriskToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 /* ClassKeyword */ || token() === 91 /* FunctionKeyword */ || - token() === 111 /* InterfaceKeyword */ || - (token() === 119 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 /* ClassKeyword */ || token() === 93 /* FunctionKeyword */ || + token() === 113 /* InterfaceKeyword */ || + (token() === 121 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -18044,7 +18852,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -18060,7 +18868,7 @@ var ts; case 12 /* ObjectLiteralMembers */: switch (token()) { case 22 /* OpenBracketToken */: - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; @@ -18130,7 +18938,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 87 /* ExtendsKeyword */ || next === 110 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 89 /* ExtendsKeyword */ || next === 112 /* ImplementsKeyword */; } return true; } @@ -18147,8 +18955,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 /* ImplementsKeyword */ || - token() === 87 /* ExtendsKeyword */) { + if (token() === 112 /* ImplementsKeyword */ || + token() === 89 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -18178,14 +18986,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -18204,9 +19012,9 @@ var ts; case 22 /* HeritageClauses */: return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; + return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -18226,7 +19034,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() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -18301,7 +19109,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 12679168 /* ContextFlags */; + var nodeContextFlags = node.flags & 25358336 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -18402,20 +19210,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 161 /* Constructor */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 221 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 160 /* 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 === 73 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 125 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 75 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 128 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -18424,8 +19232,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: return true; } } @@ -18434,58 +19242,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 224 /* VariableStatement */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 225 /* ExpressionStatement */: + case 238 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 236 /* SwitchStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 223 /* EmptyStatement */: + case 239 /* TryStatement */: + case 237 /* LabeledStatement */: + case 227 /* DoStatement */: + case 240 /* DebuggerStatement */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 157 /* PropertySignature */: + case 164 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 241 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18506,7 +19314,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 155 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18573,7 +19381,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18611,6 +19419,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18631,7 +19442,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24 /* DotToken */)) { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -18642,7 +19453,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(152 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18673,13 +19484,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(210 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18691,7 +19502,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(220 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -18720,6 +19531,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -18741,24 +19562,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 169 /* FunctionType */: + case 170 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -18766,20 +19587,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(167 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(182 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(293 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(297 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18787,7 +19608,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(296 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18808,63 +19629,80 @@ var ts; if (token() === 27 /* CommaToken */ || token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || - token() === 30 /* GreaterThanToken */ || - token() === 60 /* EqualsToken */ || - token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + token() === 31 /* GreaterThanToken */ || + token() === 62 /* EqualsToken */ || + token() === 51 /* BarToken */) { + var result = createNode(294 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(295 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(298 /* JSDocFunctionType */); nextToken(); - fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(58 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { + var parameter = createNode(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */ || token() === 98 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(134 /* ModuleKeyword */); + if (moduleSpecifier) { + var moduleTag = createNode(300 /* JSDocNamepathType */, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + case 27 /* CommaToken */: + case 5 /* WhitespaceTrivia */: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(299 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + if (token() === 62 /* EqualsToken */) { + return createPostfixType(297 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); - parseExpected(105 /* TypeOfKeyword */); + var node = createNode(171 /* TypeQuery */); + parseExpected(107 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(87 /* ExtendsKeyword */)) { + if (parseOptional(89 /* 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 @@ -18883,18 +19721,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60 /* EqualsToken */)) { + if (parseOptional(62 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (token() === 29 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(57 /* ColonToken */)) { + if (parseOptional(58 /* ColonToken */)) { return parseType(); } return undefined; @@ -18903,12 +19741,12 @@ var ts; return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 /* AtToken */ || + token() === 59 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */) { + var node = createNodeWithJSDoc(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); @@ -18930,7 +19768,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.questionToken = parseOptionalToken(57 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -18952,16 +19790,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(57 /* ColonToken */)) { + else if (parseOptional(58 /* ColonToken */)) { return true; } - else if (isType && token() === 37 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); nextToken(); return true; } @@ -19008,10 +19846,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { - parseExpected(96 /* NewKeyword */); + if (kind === 165 /* ConstructSignature */) { + parseExpected(98 /* NewKeyword */); } - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -19055,21 +19893,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* 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() !== 56 /* QuestionToken */) { + if (token() !== 57 /* 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() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 166 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19077,17 +19915,17 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + node.kind = 159 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 157 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* 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. @@ -19099,7 +19937,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return true; } var idToken = false; @@ -19121,20 +19959,20 @@ var ts; // the start of a member declaration if (idToken) { return token() === 20 /* OpenParenToken */ || - token() === 28 /* LessThanToken */ || - token() === 56 /* QuestionToken */ || - token() === 57 /* ColonToken */ || + token() === 29 /* LessThanToken */ || + token() === 57 /* QuestionToken */ || + token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + return parseSignatureMember(164 /* CallSignature */); } - if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + if (token() === 98 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19145,7 +19983,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; } function nextTokenIsDot() { return nextToken() === 24 /* DotToken */; @@ -19153,14 +19991,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20 /* OpenParenToken */: - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(172 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19177,37 +20015,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { - return nextToken() === 134 /* ReadonlyKeyword */; + if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + return nextToken() === 137 /* ReadonlyKeyword */; } - if (token() === 134 /* ReadonlyKeyword */) { + if (token() === 137 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 96 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(94 /* InKeyword */); + parseExpected(96 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(185 /* MappedType */); parseExpected(18 /* OpenBraceToken */); - if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 137 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { - parseExpectedToken(134 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { + parseExpectedToken(137 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); parseExpected(23 /* CloseBracketToken */); - if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56 /* QuestionToken */) { - parseExpectedToken(56 /* QuestionToken */); + if (node.questionToken.kind !== 57 /* QuestionToken */) { + parseExpectedToken(57 /* QuestionToken */); } } node.type = parseTypeAnnotation(); @@ -19218,23 +20056,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(176 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 4194304 /* JSDoc */) && type.kind === 295 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 175 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(174 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(181 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19242,9 +20080,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(98 /* NewKeyword */) ? 170 /* ConstructorType */ : 169 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(38 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -19252,14 +20090,14 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(186 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 39 /* MinusToken */; + unaryMinusExpression = createNode(206 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 40 /* MinusToken */; nextToken(); } - var expression = token() === 103 /* TrueKeyword */ || token() === 88 /* FalseKeyword */ + var expression = token() === 105 /* TrueKeyword */ || token() === 90 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -19272,23 +20110,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93 /* ImportKeyword */; + return token() === 95 /* ImportKeyword */; } function parseImportType() { - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); - if (parseOptional(105 /* TypeOfKeyword */)) { + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; + var node = createNode(187 /* ImportType */); + if (parseOptional(107 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); node.argument = parseType(); parseExpected(21 /* CloseParenToken */); if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } @@ -19298,50 +20136,54 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 140 /* SymbolKeyword */: - case 124 /* BooleanKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 143 /* SymbolKeyword */: + case 127 /* BooleanKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 63 /* AsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 56 /* QuestionToken */: + case 60 /* QuestionQuestionToken */: + // If there is '??', consider that is prefix '?' in JSDoc type. + scanner.reScanQuestionToken(); + // falls through + case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseLiteralTypeNode(); - case 39 /* MinusToken */: + case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 107 /* VoidKeyword */: - case 97 /* NullKeyword */: + case 109 /* VoidKeyword */: + case 99 /* NullKeyword */: return parseTokenNode(); - case 101 /* ThisKeyword */: { + case 103 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -19349,51 +20191,54 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportType(); + case 123 /* AssertsKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 134 /* ReadonlyKeyword */: - case 140 /* SymbolKeyword */: - case 143 /* UniqueKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 105 /* TypeOfKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 137 /* ReadonlyKeyword */: + case 143 /* SymbolKeyword */: + case 146 /* UniqueKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 107 /* TypeOfKeyword */: + case 136 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: - case 28 /* LessThanToken */: - case 50 /* BarToken */: - case 49 /* AmpersandToken */: - case 96 /* NewKeyword */: + case 29 /* LessThanToken */: + case 51 /* BarToken */: + case 50 /* AmpersandToken */: + case 98 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 137 /* ObjectKeyword */: - case 40 /* AsteriskToken */: - case 56 /* QuestionToken */: - case 52 /* ExclamationToken */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 140 /* ObjectKeyword */: + case 41 /* AsteriskToken */: + case 57 /* QuestionToken */: + case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 128 /* InferKeyword */: - case 93 /* ImportKeyword */: + case 131 /* InferKeyword */: + case 95 /* ImportKeyword */: + case 123 /* AssertsKeyword */: return true; - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return !inStartOfParameter; - case 39 /* MinusToken */: + case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -19411,27 +20256,27 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + case 53 /* ExclamationToken */: + type = createPostfixType(296 /* JSDocNonNullableType */, type); break; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type - if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { + if (!(contextFlags & 4194304 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(295 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(184 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(173 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19450,16 +20295,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(183 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); - parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var node = createNode(180 /* InferType */); + parseExpected(131 /* InferKeyword */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19467,11 +20312,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130 /* KeyOfKeyword */: - case 143 /* UniqueKeyword */: - case 134 /* ReadonlyKeyword */: + case 133 /* KeyOfKeyword */: + case 146 /* UniqueKeyword */: + case 137 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 128 /* InferKeyword */: + case 131 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -19492,13 +20337,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(178 /* IntersectionType */, parseTypeOperatorOrHigher, 50 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(177 /* UnionType */, parseIntersectionTypeOrHigher, 51 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { return true; } return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -19508,7 +20353,7 @@ var ts; // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 101 /* ThisKeyword */) { + if (isIdentifier() || token() === 103 /* ThisKeyword */) { nextToken(); return true; } @@ -19530,8 +20375,8 @@ 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() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 56 /* QuestionToken */ || token() === 60 /* EqualsToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 57 /* QuestionToken */ || token() === 62 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -19540,7 +20385,7 @@ var ts; } if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -19552,7 +20397,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(167 /* TypePredicate */, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19563,45 +20409,52 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167 /* TypePredicate */); + node.assertsModifier = parseExpectedToken(123 /* AssertsKeyword */); + node.parameterName = token() === 103 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132 /* IsKeyword */) ? parseType() : undefined; + return finishNode(node); + } function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 98 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89 /* ExtendsKeyword */)) { + var node = createNode(179 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(56 /* QuestionToken */); + parseExpected(57 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -19610,14 +20463,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 96 /* NewKeyword */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 73 /* Identifier */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 98 /* NewKeyword */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 75 /* Identifier */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -19628,18 +20481,18 @@ var ts; return true; } switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 28 /* LessThanToken */: - case 123 /* AwaitKeyword */: - case 118 /* YieldKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 29 /* LessThanToken */: + case 126 /* AwaitKeyword */: + case 120 /* 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. @@ -19658,9 +20511,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && - token() !== 58 /* AtToken */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && + token() !== 59 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -19683,7 +20536,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -19728,7 +20581,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 === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -19744,7 +20597,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118 /* YieldKeyword */) { + if (token() === 120 /* 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()) { @@ -19773,15 +20626,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(211 /* 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() === 40 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19792,20 +20645,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(201 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(201 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(155 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -19830,8 +20683,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(37 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -19841,10 +20694,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() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 122 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 125 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* 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. @@ -19854,12 +20707,12 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { return 0 /* False */; } } @@ -19873,8 +20726,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 37 /* EqualsGreaterThanToken */: - case 57 /* ColonToken */: + case 38 /* EqualsGreaterThanToken */: + case 58 /* ColonToken */: case 18 /* OpenBraceToken */: return 1 /* True */; default: @@ -19898,30 +20751,30 @@ var ts; // 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 !== 122 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 /* 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 !== 101 /* ThisKeyword */) { + if (!isIdentifier() && second !== 103 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 57 /* ColonToken */: + case 58 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 60 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -19930,7 +20783,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 28 /* LessThanToken */); + ts.Debug.assert(first === 29 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -19940,11 +20793,11 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87 /* ExtendsKeyword */) { + if (third === 89 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 60 /* EqualsToken */: - case 30 /* GreaterThanToken */: + case 62 /* EqualsToken */: + case 31 /* GreaterThanToken */: return false; default: return true; @@ -19965,11 +20818,19 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -19982,23 +20843,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() === 122 /* AsyncKeyword */) { + if (token() === 125 /* 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() === 37 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(201 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20008,7 +20869,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -20021,7 +20882,7 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -20032,8 +20893,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -20058,20 +20919,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(56 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* 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(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(209 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57 /* ColonToken */); + node.colonToken = parseExpectedToken(58 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + : createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -20079,7 +20940,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 96 /* InKeyword */ || t === 151 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20108,16 +20969,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() === 41 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 /* InKeyword */ && inDisallowInContext()) { + if (token() === 96 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -20138,51 +20999,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94 /* InKeyword */) { + if (inDisallowInContext() && token() === 96 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(208 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(216 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(202 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(203 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(204 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123 /* AwaitKeyword */) { + if (token() === 126 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -20192,7 +21053,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(205 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20216,7 +21077,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 /* AsteriskAsteriskToken */ ? + return token() === 42 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -20233,10 +21094,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41 /* AsteriskAsteriskToken */) { + if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 198 /* 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 { @@ -20261,23 +21122,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 82 /* DeleteKeyword */: + case 84 /* DeleteKeyword */: return parseDeleteExpression(); - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return parseVoidExpression(); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 123 /* AwaitKeyword */: + case 126 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -20300,16 +21161,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 123 /* AwaitKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 126 /* AwaitKeyword */: return false; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -20332,21 +21193,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20387,14 +21248,14 @@ 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() === 93 /* ImportKeyword */) { + if (token() === 95 /* ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { @@ -20402,21 +21263,22 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); - node.keywordToken = 93 /* ImportKeyword */; + var node = createNode(218 /* MetaProperty */, fullStart); + node.keywordToken = 95 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; + sourceFile.flags |= 2097152 /* PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 /* 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. + // CallExpression or OptionalExpression. As such, we need to consume the rest + // of it here to be complete. return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { @@ -20468,11 +21330,11 @@ var ts; // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -20484,7 +21346,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(193 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20493,8 +21355,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 266 /* JsxOpeningElement */) { + var node = createNode(264 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20503,15 +21365,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 269 /* JsxOpeningFragment */) { + var node = createNode(268 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 265 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20522,11 +21384,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 28 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(208 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20556,7 +21418,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29 /* LessThanSlashToken */: + case 30 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; case 11 /* JsxText */: @@ -20564,7 +21426,7 @@ var ts; return parseJsxText(); case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -20585,16 +21447,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(272 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28 /* LessThanToken */); - if (token() === 30 /* GreaterThanToken */) { + parseExpected(29 /* LessThanToken */); + if (token() === 31 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(269 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20602,23 +21464,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30 /* GreaterThanToken */) { + if (token() === 31 /* 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(263 /* JsxOpeningElement */, fullStart); + node = createNode(266 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(42 /* SlashToken */); + parseExpected(43 /* SlashToken */); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(265 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20632,10 +21494,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() === 101 /* ThisKeyword */ ? + var expression = token() === 103 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20643,7 +21505,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(274 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -20669,9 +21531,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(271 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -20684,7 +21546,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(273 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -20692,78 +21554,110 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(267 /* JsxClosingElement */); + parseExpected(30 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(270 /* JsxClosingFragment */); + parseExpected(30 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); - parseExpected(28 /* LessThanToken */); + var node = createNode(198 /* TypeAssertionExpression */); + parseExpected(29 /* LessThanToken */); node.type = parseType(); - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 /* OpenBracketToken */ + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 /* QuestionDotToken */ + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + propertyAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23 /* CloseBracketToken */); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + indexedAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24 /* DotToken */); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(217 /* 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(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - if (token() === 23 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23 /* CloseBracketToken */); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, /*typeArguments*/ undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, /*typeArguments*/ undefined); continue; } return expression; @@ -20772,48 +21666,70 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32 /* OptionalChain */) { + tagExpression.flags |= 32 /* OptionalChain */; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); + var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); // handle 'foo<()' - if (token() === 28 /* LessThanToken */ || token() === 46 /* LessThanLessThanToken */) { + if (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the // stack. var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(195 /* CallExpression */, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + // We failed to parse anything, so report a missing identifier here. + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32 /* OptionalChain */; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20 /* OpenParenToken */); @@ -20822,12 +21738,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* LessThanToken */) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(30 /* GreaterThanToken */)) { + if (!parseExpected(31 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -20844,21 +21760,23 @@ var ts; 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. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] - case 57 /* ColonToken */: // foo: + case 58 /* 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 57 /* QuestionToken */: // foo? + case 34 /* EqualsEqualsToken */: // foo == + case 36 /* EqualsEqualsEqualsToken */: // foo === + case 35 /* ExclamationEqualsToken */: // foo != + case 37 /* ExclamationEqualsEqualsToken */: // foo !== + case 55 /* AmpersandAmpersandToken */: // foo && + case 56 /* BarBarToken */: // foo || + case 60 /* QuestionQuestionToken */: // foo ?? + case 52 /* CaretToken */: // foo ^ + case 50 /* AmpersandToken */: // foo & + case 51 /* 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 @@ -20870,6 +21788,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -20882,11 +21801,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -20894,7 +21813,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 122 /* AsyncKeyword */: + case 125 /* 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. @@ -20902,14 +21821,14 @@ var ts; break; } return parseFunctionExpression(); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassExpression(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionExpression(); - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -20920,28 +21839,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(199 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(212 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(214 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(191 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -20953,25 +21872,25 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 281 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(53 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -20979,24 +21898,24 @@ 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() !== 57 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(60 /* EqualsToken */); + node.kind = 280 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(62 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276 /* PropertyAssignment */; - parseExpected(57 /* ColonToken */); + node.kind = 279 /* PropertyAssignment */; + parseExpected(58 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(192 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21015,10 +21934,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(200 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -21026,7 +21945,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -21038,26 +21957,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96 /* NewKeyword */); + parseExpected(98 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); - node_2.keywordToken = 96 /* NewKeyword */; + var node_2 = createNode(218 /* MetaProperty */, fullStart); + node_2.keywordToken = 98 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, /*optionalChain*/ undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(196 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21067,7 +21986,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(222 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21100,25 +22019,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(223 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); - parseExpected(92 /* IfKeyword */); + var node = createNode(226 /* IfStatement */); + parseExpected(94 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); - parseExpected(83 /* DoKeyword */); + var node = createNode(227 /* DoStatement */); + parseExpected(85 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(108 /* WhileKeyword */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21130,8 +22049,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); - parseExpected(108 /* WhileKeyword */); + var node = createNode(228 /* WhileStatement */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21140,12 +22059,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90 /* ForKeyword */); - var awaitToken = parseOptionalToken(123 /* AwaitKeyword */); + parseExpected(92 /* ForKeyword */); + var awaitToken = parseOptionalToken(126 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 106 /* VarKeyword */ || token() === 112 /* LetKeyword */ || token() === 78 /* ConstKeyword */) { + if (token() === 108 /* VarKeyword */ || token() === 114 /* LetKeyword */ || token() === 80 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -21153,23 +22072,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(151 /* OfKeyword */) : parseOptional(151 /* OfKeyword */)) { + var forOfStatement = createNode(231 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + else if (parseOptional(96 /* InKeyword */)) { + var forInStatement = createNode(230 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(229 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21187,7 +22106,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 233 /* BreakStatement */ ? 76 /* BreakKeyword */ : 81 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21195,8 +22114,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); - parseExpected(98 /* ReturnKeyword */); + var node = createNode(234 /* ReturnStatement */); + parseExpected(100 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -21204,39 +22123,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); - parseExpected(109 /* WithKeyword */); + var node = createNode(235 /* WithStatement */); + parseExpected(111 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); + node.statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); - parseExpected(75 /* CaseKeyword */); + var node = createNode(275 /* CaseClause */); + parseExpected(77 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); - parseExpected(81 /* DefaultKeyword */); - parseExpected(57 /* ColonToken */); + var node = createNode(276 /* DefaultClause */); + parseExpected(83 /* DefaultKeyword */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 77 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); - parseExpected(100 /* SwitchKeyword */); + var node = createNode(236 /* SwitchStatement */); + parseExpected(102 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(250 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21251,29 +22170,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); - parseExpected(102 /* ThrowKeyword */); + var node = createNode(238 /* ThrowStatement */); + parseExpected(104 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); - parseExpected(104 /* TryKeyword */); + var node = createNode(239 /* TryStatement */); + parseExpected(106 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 78 /* 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() === 89 /* FinallyKeyword */) { - parseExpected(89 /* FinallyKeyword */); + if (!node.catchClause || token() === 91 /* FinallyKeyword */) { + parseExpected(91 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); - parseExpected(76 /* CatchKeyword */); + var result = createNode(278 /* CatchClause */); + parseExpected(78 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21 /* CloseParenToken */); @@ -21286,8 +22205,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); - parseExpected(80 /* DebuggerKeyword */); + var node = createNode(240 /* DebuggerStatement */); + parseExpected(82 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -21297,13 +22216,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + if (expression.kind === 75 /* Identifier */ && parseOptional(58 /* ColonToken */)) { + node.kind = 237 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 225 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21315,11 +22234,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 79 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 93 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -21328,12 +22247,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* 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 @@ -21356,41 +22275,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146 /* GlobalKeyword */: + case 149 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 73 /* Identifier */ || token() === 86 /* ExportKeyword */; - case 93 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 75 /* Identifier */ || token() === 88 /* ExportKeyword */; + case 95 /* ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); - if (token() === 60 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || token() === 81 /* DefaultKeyword */ || - token() === 120 /* AsKeyword */) { + if (token() === 62 /* EqualsToken */ || token() === 41 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 83 /* DefaultKeyword */ || + token() === 122 /* AsKeyword */) { return true; } continue; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: nextToken(); continue; default: @@ -21403,50 +22322,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 92 /* IfKeyword */: - case 83 /* DoKeyword */: - case 108 /* WhileKeyword */: - case 90 /* ForKeyword */: - case 79 /* ContinueKeyword */: - case 74 /* BreakKeyword */: - case 98 /* ReturnKeyword */: - case 109 /* WithKeyword */: - case 100 /* SwitchKeyword */: - case 102 /* ThrowKeyword */: - case 104 /* TryKeyword */: - case 80 /* DebuggerKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 94 /* IfKeyword */: + case 85 /* DoKeyword */: + case 110 /* WhileKeyword */: + case 92 /* ForKeyword */: + case 81 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 100 /* ReturnKeyword */: + case 111 /* WithKeyword */: + case 102 /* SwitchKeyword */: + case 104 /* ThrowKeyword */: + case 106 /* TryKeyword */: + case 82 /* 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 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78 /* ConstKeyword */: - case 86 /* ExportKeyword */: + case 80 /* ConstKeyword */: + case 88 /* ExportKeyword */: return isStartOfDeclaration(); - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 111 /* InterfaceKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 141 /* TypeKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 113 /* InterfaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 144 /* TypeKeyword */: + case 149 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 119 /* StaticKeyword */: + case 137 /* 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); @@ -21469,63 +22389,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); - case 112 /* LetKeyword */: + case 108 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); + case 114 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); } break; - case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); - case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); - case 92 /* IfKeyword */: + case 93 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(243 /* FunctionDeclaration */)); + case 79 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(244 /* ClassDeclaration */)); + case 94 /* IfKeyword */: return parseIfStatement(); - case 83 /* DoKeyword */: + case 85 /* DoKeyword */: return parseDoStatement(); - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return parseWhileStatement(); - case 90 /* ForKeyword */: + case 92 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); - case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); - case 98 /* ReturnKeyword */: + case 81 /* ContinueKeyword */: + return parseBreakOrContinueStatement(232 /* ContinueStatement */); + case 76 /* BreakKeyword */: + return parseBreakOrContinueStatement(233 /* BreakStatement */); + case 100 /* ReturnKeyword */: return parseReturnStatement(); - case 109 /* WithKeyword */: + case 111 /* WithKeyword */: return parseWithStatement(); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return parseSwitchStatement(); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return parseThrowStatement(); - case 104 /* TryKeyword */: + case 106 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return parseTryStatement(); - case 80 /* DebuggerKeyword */: + case 82 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 58 /* AtToken */: + case 59 /* AtToken */: return parseDeclaration(); - case 122 /* AsyncKeyword */: - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 85 /* EnumKeyword */: - case 86 /* ExportKeyword */: - case 93 /* ImportKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 119 /* AbstractKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 87 /* EnumKeyword */: + case 88 /* ExportKeyword */: + case 95 /* ImportKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 121 /* AbstractKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: + case 149 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -21534,52 +22455,71 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126 /* DeclareKeyword */; + return modifier.kind === 129 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304 /* Ambient */; + m.flags |= 8388608 /* Ambient */; } - return doInsideOfContext(4194304 /* Ambient */, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: return parseVariableStatement(node); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassDeclaration(node); - case 111 /* InterfaceKeyword */: + case 113 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 141 /* TypeKeyword */: + case 144 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 85 /* EnumKeyword */: + case 87 /* EnumKeyword */: return parseEnumDeclaration(node); - case 146 /* GlobalKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 149 /* GlobalKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); switch (token()) { - case 81 /* DefaultKeyword */: - case 60 /* EqualsToken */: + case 83 /* DefaultKeyword */: + case 62 /* EqualsToken */: return parseExportAssignment(node); - case 120 /* AsKeyword */: + case 122 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -21588,7 +22528,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(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21611,24 +22551,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(214 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -21636,14 +22576,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(188 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(189 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -21665,10 +22605,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(241 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 /* Identifier */ && - token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 /* Identifier */ && + token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -21678,14 +22618,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(242 /* VariableDeclarationList */); switch (token()) { - case 106 /* VarKeyword */: + case 108 /* VarKeyword */: break; - case 112 /* LetKeyword */: + case 114 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -21701,7 +22641,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() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -21716,25 +22656,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 224 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + node.kind = 243 /* FunctionDeclaration */; + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* 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(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125 /* ConstructorKeyword */) { - return parseExpected(125 /* ConstructorKeyword */); + if (token() === 128 /* ConstructorKeyword */) { + return parseExpected(128 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -21746,25 +22686,25 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; - fillSignature(57 /* ColonToken */, 0 /* None */, node); + node.kind = 161 /* Constructor */; + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 160 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; - if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 158 /* PropertyDeclaration */; + if (!node.questionToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -21779,17 +22719,17 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. node.initializer = ts.hasModifier(node, 32 /* Static */) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseInitializer); + : doOutsideOfContext(8192 /* YieldContext */ | 4096 /* DisallowInContext */, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* 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(56 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -21797,13 +22737,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57 /* ColonToken */, 0 /* None */, node); + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58 /* AtToken */) { + if (token() === 59 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -21820,7 +22760,7 @@ var ts; } nextToken(); } - if (token() === 40 /* AsteriskToken */) { + if (token() === 41 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -21836,18 +22776,18 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 138 /* SetKeyword */ || idToken === 127 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 141 /* SetKeyword */ || idToken === 130 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { case 20 /* OpenParenToken */: // Method declaration - case 28 /* LessThanToken */: // Generic Method declaration - case 52 /* ExclamationToken */: // Non-null assertion on property name - case 57 /* ColonToken */: // Type Annotation for declaration - case 60 /* EqualsToken */: // Initializer for declaration - case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 29 /* LessThanToken */: // Generic Method declaration + case 53 /* ExclamationToken */: // Non-null assertion on property name + case 58 /* ColonToken */: // Type Annotation for declaration + case 62 /* EqualsToken */: // Initializer for declaration + case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -21865,10 +22805,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58 /* AtToken */)) { + if (!parseOptional(59 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(156 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -21888,7 +22828,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 80 /* 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)) { @@ -21907,7 +22847,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -21918,20 +22858,20 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(221 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 128 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -21945,27 +22885,37 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 40 /* AsteriskToken */ || + token() === 41 /* AsteriskToken */ || token() === 22 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608 /* Ambient */; + } + return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75 /* 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 */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 213 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 244 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77 /* ClassKeyword */); + parseExpected(79 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -21991,7 +22941,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -22003,33 +22953,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + ts.Debug.assert(tok === 89 /* ExtendsKeyword */ || tok === 112 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(277 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 29 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; - parseExpected(111 /* InterfaceKeyword */); + node.kind = 245 /* InterfaceDeclaration */; + parseExpected(113 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22037,11 +22986,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; - parseExpected(141 /* TypeKeyword */); + node.kind = 246 /* TypeAliasDeclaration */; + parseExpected(144 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -22051,14 +23000,14 @@ 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(279 /* EnumMember */); + var node = createNodeWithJSDoc(282 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; - parseExpected(85 /* EnumKeyword */); + node.kind = 247 /* EnumDeclaration */; + parseExpected(87 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -22070,7 +23019,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(249 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22081,7 +23030,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 248 /* 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 */; @@ -22093,11 +23042,11 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; - if (token() === 146 /* GlobalKeyword */) { + node.kind = 248 /* ModuleDeclaration */; + if (token() === 149 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 512 /* GlobalAugmentation */; + node.flags |= 1024 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(); @@ -22113,15 +23062,15 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146 /* GlobalKeyword */) { + if (token() === 149 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132 /* NamespaceKeyword */)) { + else if (parseOptional(135 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(131 /* ModuleKeyword */); + parseExpected(134 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } @@ -22129,52 +23078,52 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 /* RequireKeyword */ && + return token() === 138 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 42 /* SlashToken */; + return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; - parseExpected(120 /* AsKeyword */); - parseExpected(132 /* NamespaceKeyword */); + node.kind = 251 /* NamespaceExportDeclaration */; + parseExpected(122 /* AsKeyword */); + parseExpected(135 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 /* CommaToken */ && token() !== 145 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 148 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 253 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 40 /* AsteriskToken */ || // import * + token() === 41 /* AsteriskToken */ || // import * token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145 /* FromKeyword */); + parseExpected(148 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 252 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -22186,7 +23135,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(254 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22196,7 +23145,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(256 /* NamedImports */); } return finishNode(importClause); } @@ -22206,8 +23155,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); - parseExpected(135 /* RequireKeyword */); + var node = createNode(263 /* ExternalModuleReference */); + parseExpected(138 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -22229,9 +23178,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); - parseExpected(40 /* AsteriskToken */); - parseExpected(120 /* AsKeyword */); + var namespaceImport = createNode(255 /* NamespaceImport */); + parseExpected(41 /* AsteriskToken */); + parseExpected(122 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -22244,14 +23193,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 256 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(261 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(257 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22265,9 +23214,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(120 /* AsKeyword */); + parseExpected(122 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -22276,24 +23225,24 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 257 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; - if (parseOptional(40 /* AsteriskToken */)) { - parseExpected(145 /* FromKeyword */); + node.kind = 259 /* ExportDeclaration */; + if (parseOptional(41 /* AsteriskToken */)) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(260 /* 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() === 145 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(145 /* FromKeyword */); + if (token() === 148 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -22301,12 +23250,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; - if (parseOptional(60 /* EqualsToken */)) { + node.kind = 258 /* ExportAssignment */; + if (parseOptional(62 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(81 /* DefaultKeyword */); + parseExpected(83 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -22321,15 +23270,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */ + || node.kind === 253 /* ImportDeclaration */ + || node.kind === 258 /* ExportAssignment */ + || node.kind === 259 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -22337,7 +23284,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -22388,9 +23335,9 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(292 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); + result.type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -22400,8 +23347,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = parseJSDocCommentWorker(start, length); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22412,11 +23359,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536 /* JavaScriptFile */) { + if (contextFlags & 131072 /* JavaScriptFile */) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -22481,7 +23428,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -22500,7 +23447,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 40 /* AsteriskToken */: + case 41 /* 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 @@ -22551,7 +23498,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297 /* JSDocComment */, start); + var result = createNode(301 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22587,14 +23534,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { indentText += scanner.getTokenText(); if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40 /* AsteriskToken */) { + else if (token() === 41 /* AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -22602,7 +23549,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -22686,7 +23633,7 @@ var ts; } indent = 0; break; - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 3 /* SavingBackticks */) { comments.push(scanner.getTokenText()); break; @@ -22711,7 +23658,7 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -22719,7 +23666,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59 /* BacktickToken */: + case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { state = 2 /* SavingComments */; } @@ -22728,7 +23675,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -22751,7 +23698,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300 /* JSDocTag */, start); + var result = createNode(304 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22779,15 +23726,15 @@ var ts; skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(59 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(60 /* EqualsToken */)) { + if (parseOptionalToken(62 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -22796,9 +23743,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -22814,8 +23761,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(312 /* JSDocPropertyTag */, start) : - createNode(306 /* JSDocParameterTag */, start); + createNode(316 /* JSDocPropertyTag */, start) : + createNode(310 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22832,20 +23779,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) { + if (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -22857,7 +23804,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307 /* JSDocReturnTag */, start); + var result = createNode(311 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -22866,13 +23813,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309 /* JSDocTypeTag */, start); + var result = createNode(313 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302 /* JSDocAuthorTag */, start); + var result = createNode(306 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -22894,20 +23841,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 5 /* WhitespaceTrivia */: case 24 /* DotToken */: - case 58 /* AtToken */: + case 59 /* AtToken */: comments.push(scanner.getTokenText()); break; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (!seenLessThan || seenGreaterThan) { return; } @@ -22926,14 +23873,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301 /* JSDocAugmentsTag */, start); + var result = createNode(305 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -22945,7 +23892,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(193 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -22953,19 +23900,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303 /* JSDocClassTag */, start); + var tag = createNode(307 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308 /* JSDocThisTag */, start); + var tag = createNode(312 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305 /* JSDocEnumTag */, start); + var tag = createNode(309 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22974,7 +23921,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311 /* JSDocTypedefTag */, start); + var typedefTag = createNode(315 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22988,9 +23935,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start); } - if (child.kind === 309 /* JSDocTypeTag */) { + if (child.kind === 313 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -23003,7 +23950,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23022,7 +23969,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(248 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23036,22 +23983,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304 /* JSDocCallbackTag */, start); + var callbackTag = createNode(308 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299 /* JSDocSignature */, start); + var jsdocSignature = createNode(303 /* 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(58 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 307 /* JSDocReturnTag */) { + if (tag && tag.kind === 311 /* JSDocReturnTag */) { return tag; } } @@ -23093,10 +24040,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) && + if (child && (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23109,13 +24056,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -23124,7 +24071,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -23160,13 +24107,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(154 /* 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(27 /* CommaToken */)); - var result = createNode(310 /* JSDocTemplateTag */, start); + var result = createNode(314 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23199,18 +24146,21 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73 /* Identifier */, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + var result = createNode(75 /* Identifier */, pos); + if (token() !== 75 /* Identifier */) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -23331,7 +24281,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return true; } return false; @@ -23897,10 +24847,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73 /* Identifier */) { + if (lhs.kind === 75 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101 /* ThisKeyword */) { + if (lhs.kind === 103 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -24050,12 +25000,21 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -24065,7 +25024,7 @@ var ts; }, ]; /* @internal */ - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -24167,7 +25126,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -24204,6 +25164,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -24212,6 +25173,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -24219,6 +25181,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -24237,6 +25200,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -24264,6 +25228,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -24273,6 +25238,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -24289,6 +25255,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -24308,7 +25275,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, // Strict Type Checks { @@ -24442,7 +25410,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { // this option can only be specified in tsconfig.json @@ -24457,7 +25426,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -24481,7 +25451,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -24578,6 +25549,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -24627,14 +25599,20 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + transpileOptionValue: true }, { name: "stripInternal", @@ -24650,6 +25628,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -24670,6 +25654,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -24685,7 +25670,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -24743,6 +25729,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -24772,7 +25765,11 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + /* @internal */ + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -24836,7 +25833,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; /* @internal */ @@ -25336,7 +26334,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 !== 276 /* PropertyAssignment */) { + if (element.kind !== 279 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25392,15 +26390,15 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97 /* NullKeyword */: + case 99 /* 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 + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25418,13 +26416,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 206 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25441,7 +26439,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25492,13 +26490,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), 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 config = __assign(__assign({ compilerOptions: __assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? 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 }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -25723,8 +26721,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -25890,7 +26887,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -26579,8 +27576,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -26839,7 +27837,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27023,6 +28021,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -27033,6 +28032,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -27242,7 +28244,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); @@ -27278,7 +28280,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; @@ -27299,7 +28301,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -27779,35 +28781,67 @@ var ts; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1 /* Instantiated */; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0 /* NonInstantiated */; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; - // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case 259 /* ExportDeclaration */: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0 /* NonInstantiated */; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1 /* Instantiated */) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. + case 249 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0 /* NonInstantiated */: // child is non-instantiated - continue searching @@ -27826,9 +28860,9 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: - return getModuleInstanceState(node); - case 73 /* Identifier */: + case 248 /* ModuleDeclaration */: + return getModuleInstanceState(node, visited); + case 75 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -27837,6 +28871,36 @@ var ts; } return 1 /* Instantiated */; } + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1 /* Instantiated */) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + } var ContainerFlags; (function (ContainerFlags) { // The current node is not a container, and no container manipulation should happen before @@ -27865,7 +28929,9 @@ var ts; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -27899,7 +28965,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -27967,7 +29033,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -27978,7 +29044,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { setValueDeclaration(symbol, node); } } @@ -27994,7 +29060,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 === 255 /* ExportAssignment */) { + if (node.kind === 258 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -28003,7 +29069,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28015,39 +29081,42 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: + case 169 /* FunctionType */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 155 /* 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 === 295 /* 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 === 298 /* 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; @@ -28147,7 +29216,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 === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 258 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28165,7 +29234,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0 /* None */, name); } } @@ -28182,7 +29251,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 261 /* ExportSpecifier */ || (node.kind === 252 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28206,11 +29275,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { + if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 67220415 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -28249,7 +29318,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 !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28277,12 +29346,12 @@ var ts; if (!isIIFE) { currentFlow = { flags: 2 /* Start */ }; if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { - currentFlow.container = node; + currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -28290,19 +29359,20 @@ var ts; flowNodeCreated = ts.identity; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~1408 /* ReachabilityAndEmitFlags */; + node.flags &= ~2816 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 128 /* HasImplicitReturn */; + node.flags |= 256 /* HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 256 /* HasExplicitReturn */; + node.flags |= 512 /* HasExplicitReturn */; + node.endFlowNode = currentFlow; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28319,7 +29389,7 @@ var ts; else if (containerFlags & 64 /* IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 /* ContainsThis */ : node.flags & ~64 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; } else { bindChildren(node); @@ -28346,8 +29416,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28379,79 +29449,93 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 /* FirstStatement */ && node.kind <= 240 /* LastStatement */ && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 225 /* ExpressionStatement */: + bindExpressionStatement(node); + break; + case 237 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + bindAccessExpressionFlow(node); + break; + case 195 /* CallExpression */: bindCallExpressionFlow(node); break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; + case 307 /* JSDocClassTag */: + bindJSDocClassTag(node); + break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 288 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28462,29 +29546,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: - return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 203 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || + return expr.kind === 75 /* Identifier */ || expr.kind === 103 /* ThisKeyword */ || expr.kind === 101 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && + ts.isElementAccessExpression(expr) && + ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { @@ -28496,7 +29580,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 193 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28510,17 +29594,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableReference(expr.left); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -28529,11 +29613,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -28542,20 +29626,14 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4 /* BranchLabel */, - antecedents: undefined - }; + return { flags: 4 /* BranchLabel */, antecedents: undefined }; } function createLoopLabel() { - return { - flags: 8 /* LoopLabel */, - antecedents: undefined - }; + return { flags: 8 /* LoopLabel */, antecedents: undefined }; } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; + flow.flags |= flow.flags & 1024 /* Referenced */ ? 2048 /* Shared */ : 1024 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -28570,31 +29648,36 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 103 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 88 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { - return unreachableFlow; + if (expression.kind === 105 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 90 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (!ts.isOptionalChainRoot(expression.parent)) { + return unreachableFlow; + } } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16 /* Assignment */, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -28609,47 +29692,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 229 /* ForStatement */: + case 209 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 206 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 55 /* BarBarToken */); + return node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* BarBarToken */ || + node.operatorToken.kind === 60 /* QuestionQuestionToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && - node.parent.operator === 52 /* ExclamationToken */) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); } @@ -28677,7 +29765,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 237 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -28709,15 +29797,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 231 /* ForOfStatement */) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 242 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -28739,7 +29827,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 234 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -28759,7 +29847,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -28851,7 +29939,7 @@ var ts; // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. - var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = { flags: 4096 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -28869,7 +29957,7 @@ var ts; } } if (!(currentFlow.flags & 1 /* Unreachable */)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096 /* AfterFinally */, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192 /* AfterFinally */, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -28887,9 +29975,10 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276 /* 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). + // case clauses have unreachable end points (e.g. they all return). Note, we no longer need + // this property in control flow analysis, it's there only for backwards compatibility. node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -28943,6 +30032,17 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + // A top level call expression with a dotted function name and at least one argument + // is potentially an assertion and is therefore included in the control flow. + if (node.expression.kind === 195 /* CallExpression */) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -28954,14 +30054,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 227 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -28972,10 +30072,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 191 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 212 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -28983,16 +30083,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 279 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 280 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 281 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -29000,7 +30100,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -29011,7 +30111,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52 /* ExclamationToken */) { + if (node.operator === 53 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -29021,20 +30121,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -29048,7 +30148,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 62 /* EqualsToken */ && node.left.kind === 194 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29059,7 +30159,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 193 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29098,27 +30198,102 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 309 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - // If the target of the call expression is a function expression or arrow function we have - // 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 === 196 /* ParenthesizedExpression */) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193 /* PropertyAccessExpression */: + bind(node.name); + break; + case 194 /* ElementAccessExpression */: + bind(node.argumentExpression); + break; + case 195 /* CallExpression */: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + // For an optional chain, we emulate the behavior of a logical expression: + // + // a?.b -> a && a.b + // a?.b.c -> a && a.b.c + // a?.b?.c -> a && a.b && a.b.c + // a?.[x = 1] -> a && a[x = 1] + // + // To do this we descend through the chain until we reach the root of a chain (the expression with a `?.`) + // and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest + // of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost + // chain node. We then treat the entire node as the right side of the expression. + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + // If the target of the call expression is a function expression or arrow function we have + // an immediately invoked function expression (IIFE). Initialize the flowNode property to + // the current control flow (which includes evaluation of the IIFE arguments). + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 /* FunctionExpression */ || expr.kind === 201 /* ArrowFunction */) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29127,54 +30302,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 272 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 298 /* JSDocFunctionType */: + case 169 /* FunctionType */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 170 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 278 /* CatchClause */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 250 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 222 /* 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 @@ -29207,45 +30382,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 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 192 /* ObjectLiteralExpression */: + case 245 /* InterfaceDeclaration */: + case 272 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 299 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 303 /* JSDocSignature */: + case 166 /* IndexSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 298 /* JSDocFunctionType */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 246 /* TypeAliasDeclaration */: + case 185 /* 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 @@ -29272,11 +30447,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 4194304 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 32 /* ExportContext */; + if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* ExportContext */; } else { - node.flags &= ~32 /* ExportContext */; + node.flags &= ~64 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -29346,7 +30521,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 === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 281 /* SpreadAssignment */ || prop.name.kind !== 75 /* Identifier */) { continue; } var identifier = prop.name; @@ -29358,7 +30533,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 === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 279 /* PropertyAssignment */ || prop.kind === 280 /* ShorthandPropertyAssignment */ || prop.kind === 160 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29390,10 +30565,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29424,9 +30599,37 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + container = file; + break; + case 4 /* ThisProperty */: + container = declName.parent.expression; + break; + case 3 /* PrototypeProperty */: + container = declName.parent.expression.name; + break; + case 5 /* Property */: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0 /* None */: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75 /* Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -29442,10 +30645,11 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 112 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 120 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */)) { + !(node.flags & 8388608 /* Ambient */) && + !(node.flags & 4194304 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29479,7 +30683,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 73 /* Identifier */) { + if (inStrictMode && node.expression.kind === 75 /* 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); @@ -29490,7 +30694,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73 /* Identifier */) { + if (name && name.kind === 75 /* 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 @@ -29531,8 +30735,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 288 /* SourceFile */ && + blockScopeContainer.kind !== 248 /* 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. @@ -29558,7 +30762,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -29593,7 +30797,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -29627,7 +30831,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 > 148 /* LastToken */) { + if (node.kind > 151 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -29667,8 +30871,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -29689,7 +30893,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 73 /* Identifier */: + case 75 /* 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. @@ -29698,31 +30902,32 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); break; } // falls through - case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + case 103 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -29750,76 +30955,76 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 182 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 282 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* 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 240 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); + case 243 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 162 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); + case 163 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: + case 170 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 185 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -29838,64 +31043,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); + case 246 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + case 247 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 288 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 222 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 306 /* JSDocParameterTag */: - if (node.parent.kind === 299 /* JSDocSignature */) { + case 310 /* JSDocParameterTag */: + if (node.parent.kind === 303 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 298 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 302 /* JSDocTypeLiteral */) { break; } // falls through - case 312 /* JSDocPropertyTag */: + case 316 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30003,8 +31209,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); } @@ -30014,7 +31219,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 /* Property */ | 1048576 /* ExportValue */ | 32 /* Class */ : 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, lhs, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); } } function bindModuleExportsAssignment(node) { @@ -30039,13 +31244,13 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 === 60 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } @@ -30053,38 +31258,59 @@ var ts; // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } break; default: ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4 /* Property */, "__computed" /* Computed */); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101 /* ThisKeyword */) { + if (node.expression.kind === 103 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30097,8 +31323,7 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.left.expression, node.left, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -30117,32 +31342,38 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 288 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { // This can be an alias for the 'exports' or 'module.exports' names, e.g. // var util = module.exports; // util.property = function ... bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -30151,10 +31382,10 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; @@ -30170,6 +31401,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30180,17 +31414,47 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var includes = 0 /* None */; + var excludes = 0 /* None */; + // Method-like + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192 /* Method */; + excludes = 103359 /* MethodExcludes */; + } + // Maybe accessor-like + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this + // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) + includes |= 65536 /* SetAccessor */ | 4 /* Property */; + excludes |= 78783 /* SetAccessorExcludes */; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 /* GetAccessor */ | 4 /* Property */; + excludes |= 46015 /* GetAccessorExcludes */; + } + } + if (includes === 0 /* None */) { + includes = 4 /* Property */; + excludes = 0 /* PropertyExcludes */; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 /* SourceFile */ + : propertyAccess.parent.parent.kind === 288 /* SourceFile */; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30219,7 +31483,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 === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -30236,7 +31500,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -30248,7 +31512,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -30259,8 +31523,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); + if (node.kind === 244 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; @@ -30293,19 +31557,16 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 /* RegularEnum */ : 0 /* None */); - var enumExcludes = (isEnum ? 68008191 /* RegularEnumExcludes */ : 0 /* None */); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */ | enumFlags, 67220415 /* BlockScopedVariableExcludes */ | enumExcludes); + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -30317,18 +31578,18 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */ | enumFlags, 67220414 /* FunctionScopedVariableExcludes */ | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 306 /* JSDocParameterTag */ && container.kind !== 299 /* JSDocSignature */) { + if (node.kind === 310 /* JSDocParameterTag */ && container.kind !== 303 /* JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { + if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); @@ -30337,34 +31598,34 @@ var ts; bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -30375,8 +31636,8 @@ var ts; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -30396,26 +31657,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 180 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } // reachability checks @@ -30430,11 +31691,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 223 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 248 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30448,7 +31709,7 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 8388608 /* Ambient */) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -30478,12 +31739,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30495,7 +31756,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -30532,58 +31793,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 155 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 161 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -30594,6 +31855,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } if (node.typeArguments) { transformFlags |= 1 /* AssertTypeScript */; } @@ -30605,7 +31869,7 @@ var ts; transformFlags |= 2048 /* ContainsLexicalThis */; } } - if (expression.kind === 93 /* ImportKeyword */) { + if (expression.kind === 95 /* ImportKeyword */) { transformFlags |= 524288 /* ContainsDynamicImport */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -30628,17 +31892,20 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* QuestionQuestionToken */) { + transformFlags |= 4 /* AssertESNext */; + } + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 192 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 191 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ - || operatorTokenKind === 64 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 42 /* AsteriskAsteriskToken */ + || operatorTokenKind === 66 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 64 /* AssertES2016 */; } @@ -30681,8 +31948,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 === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 216 /* AsExpression */ + || expressionKind === 198 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -30722,11 +31989,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87 /* ExtendsKeyword */: + case 89 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; - case 110 /* ImplementsKeyword */: + case 112 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; @@ -30917,9 +32184,12 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -30929,9 +32199,12 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If an ElementAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31019,43 +32292,43 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { - case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 125 /* AsyncKeyword */: + case 205 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; break; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 217 /* NonNullExpression */: + case 137 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 267 /* JsxClosingElement */: + case 268 /* JsxFragment */: + case 269 /* JsxOpeningFragment */: + case 270 /* JsxClosingFragment */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 274 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31063,11 +32336,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: - case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 280 /* ShorthandPropertyAssignment */: + case 119 /* StaticKeyword */: + case 218 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31084,103 +32357,103 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; break; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 167 /* TypePredicate */: + case 168 /* TypeReference */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 171 /* TypeQuery */: + case 172 /* TypeLiteral */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 180 /* InferType */: + case 181 /* ParenthesizedType */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: + case 251 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 153 /* 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. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; excludeFlags = 536870912 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31193,26 +32466,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31230,67 +32503,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 191 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 155 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 161 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 139 /* StringKeyword */: - case 137 /* ObjectKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 142 /* StringKeyword */: + case 140 /* ObjectKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 278 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: - case 99 /* SuperKeyword */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: + case 199 /* ParenthesizedExpression */: + case 101 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31309,7 +32582,7 @@ var ts; /** @internal */ var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -31382,7 +32655,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -31465,7 +32738,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 === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 171 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -31516,6 +32789,180 @@ var ts; WideningKind[WideningKind["Normal"] = 0] = "Normal"; WideningKind[WideningKind["GeneratorYield"] = 1] = "GeneratorYield"; })(WideningKind || (WideningKind = {})); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + 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"] = 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 */, + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ + }); + var typeofNEFacts = ts.createMapFromTemplate({ + 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 TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; + TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; + TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; + CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; + CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; + })(CheckMode || (CheckMode = {})); + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + ContextFlags[ContextFlags["NoConstraints"] = 2] = "NoConstraints"; + })(ContextFlags || (ContextFlags = {})); + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; + })(AccessFlags || (AccessFlags = {})); + var CallbackCheck; + (function (CallbackCheck) { + CallbackCheck[CallbackCheck["None"] = 0] = "None"; + CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; + CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; + })(CallbackCheck || (CallbackCheck = {})); + var MappedTypeModifiers; + (function (MappedTypeModifiers) { + MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; + })(MappedTypeModifiers || (MappedTypeModifiers = {})); + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var MembersOrExportsResolutionKind; + (function (MembersOrExportsResolutionKind) { + MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; + MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; + })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); + var UnusedKind; + (function (UnusedKind) { + UnusedKind[UnusedKind["Local"] = 0] = "Local"; + UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; + })(UnusedKind || (UnusedKind = {})); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); + var DeclarationMeaning; + (function (DeclarationMeaning) { + DeclarationMeaning[DeclarationMeaning["GetAccessor"] = 1] = "GetAccessor"; + DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; + DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; + })(DeclarationMeaning || (DeclarationMeaning = {})); + var DeclarationSpaces; + (function (DeclarationSpaces) { + DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; + DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; + DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; + DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; + })(DeclarationSpaces || (DeclarationSpaces = {})); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -31563,11 +33010,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -31601,6 +33046,9 @@ var ts; var requireSymbol = createSymbol(4 /* Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; + // This object is reused for `checkOptionalExpression` return values to avoid frequent GC due to nursery object allocations. + // This object represents a pool-size of 1. + var pooledOptionalTypeResult = { isOptional: false, type: undefined }; // for public members that accept a Node or one of its subtypes, we must guard against // synthetic nodes created during transformations by calling `getParseTreeNode`. // for most of these, we perform the guard only on `checker` to avoid any possible @@ -31649,8 +33097,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -31767,7 +33218,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -31783,6 +33234,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -31801,6 +33255,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -31829,7 +33284,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -31841,7 +33296,7 @@ var ts; // Ensure file is type checked checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { addUnusedDiagnostics(); } @@ -31853,7 +33308,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -31893,6 +33348,7 @@ var ts; var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 262144 /* ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); var nullType = createIntrinsicType(65536 /* Null */, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 262144 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); @@ -31922,6 +33378,7 @@ var ts; var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 1048576 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -31945,7 +33402,7 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); + var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 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); @@ -32042,6 +33499,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -32054,113 +33514,18 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - // Suggestion diagnostics must have a file. Keyed by source file name. - var suggestionDiagnostics = ts.createMultiMap(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - 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"] = 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 */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ - }); - var typeofNEFacts = ts.createMapFromTemplate({ - 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 suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -32178,71 +33543,8 @@ var ts; var comparableRelation = ts.createMap(); var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; - TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; - TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); - var CheckMode; - (function (CheckMode) { - CheckMode[CheckMode["Normal"] = 0] = "Normal"; - CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; - CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; - CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; - CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; - CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; - })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - })(AccessFlags || (AccessFlags = {})); - var CallbackCheck; - (function (CallbackCheck) { - CallbackCheck[CallbackCheck["None"] = 0] = "None"; - CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; - CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; - })(CallbackCheck || (CallbackCheck = {})); - var MappedTypeModifiers; - (function (MappedTypeModifiers) { - MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; - })(MappedTypeModifiers || (MappedTypeModifiers = {})); - var ExpandingFlags; - (function (ExpandingFlags) { - ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; - ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; - ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; - ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; - })(ExpandingFlags || (ExpandingFlags = {})); - var MembersOrExportsResolutionKind; - (function (MembersOrExportsResolutionKind) { - MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; - MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; - })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); - var UnusedKind; - (function (UnusedKind) { - UnusedKind[UnusedKind["Local"] = 0] = "Local"; - UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; - })(UnusedKind || (UnusedKind = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -32254,7 +33556,7 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; @@ -32307,11 +33609,11 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32333,35 +33635,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= 67220415 /* BlockScopedVariableExcludes */; + result |= 111551 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= 67220414 /* FunctionScopedVariableExcludes */; + result |= 111550 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) result |= 0 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= 68008959 /* EnumMemberExcludes */; + result |= 900095 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= 67219887 /* FunctionExcludes */; + result |= 110991 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 68008383 /* ClassExcludes */; + result |= 899503 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 67897736 /* InterfaceExcludes */; + result |= 788872 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 68008191 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 68008831 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 110735 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) - result |= 67212223 /* MethodExcludes */; + result |= 103359 /* MethodExcludes */; if (flags & 32768 /* GetAccessor */) - result |= 67154879 /* GetAccessorExcludes */; + result |= 46015 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) - result |= 67187647 /* SetAccessorExcludes */; + result |= 78783 /* SetAccessorExcludes */; if (flags & 262144 /* TypeParameter */) - result |= 67635688 /* TypeParameterExcludes */; + result |= 526824 /* TypeParameterExcludes */; if (flags & 524288 /* TypeAlias */) - result |= 67897832 /* TypeAliasExcludes */; + result |= 788968 /* TypeAliasExcludes */; if (flags & 2097152 /* Alias */) result |= 2097152 /* AliasExcludes */; return result; @@ -32396,7 +33698,11 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* Assignment */) { - ts.Debug.assert(source !== target); + if (source === target) { + // This can happen when an export assigned namespace exports something also erroneously exported at the top level + // See `declarationFileNoCrashOnExtraExportModifier` for an example + return target; + } if (!(target.flags & 33554432 /* Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -32525,7 +33831,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -32535,7 +33841,7 @@ var ts; // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); if (mainModule_1.flags & 1920 /* Namespace */) { - // If we’re merging an augmentation to a pattern ambient module, we want to + // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you // all the exports both from the pattern and from the augmentation, but @@ -32584,7 +33890,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32614,8 +33920,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -32628,7 +33934,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304 /* Ambient */) { + declaration.flags & 8388608 /* Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -32642,17 +33948,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 190 /* 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, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 190 /* 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, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 241 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -32675,22 +33981,22 @@ 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 === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 /* ExportSpecifier */ || (usage.parent.kind === 258 /* 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 === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 258 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 224 /* VariableStatement */: + case 229 /* ForStatement */: + case 231 /* 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)) { @@ -32711,16 +34017,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 158 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 160 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -32741,14 +34047,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 201 /* ArrowFunction */: + case 158 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 222 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return true; default: return false; @@ -32794,12 +34100,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 !== 297 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 301 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 155 /* Parameter */ || + lastLocation.kind === 154 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -32816,13 +34122,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 === 152 /* Parameter */ || + lastLocation.kind === 155 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 179 /* 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; @@ -32837,14 +34143,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + case 248 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -32868,7 +34174,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 261 /* ExportSpecifier */)) { break; } } @@ -32882,12 +34188,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -32897,20 +34203,20 @@ var ts; if (!ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -32925,7 +34231,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 213 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -32933,11 +34239,11 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 89 /* ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -32953,34 +34259,34 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -32993,7 +34299,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -33002,7 +34308,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 === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 155 /* Parameter */) { location = location.parent; } // @@ -33017,24 +34323,25 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244 /* ClassDeclaration */)) { location = location.parent; } break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 155 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 155 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33054,7 +34361,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 288 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33120,21 +34427,21 @@ var ts; // we want to check for block-scoped if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 67220415 /* Value */) === 67220415 /* Value */))) { + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415 /* Value */) === 67220415 /* Value */) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -33150,10 +34457,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 201 /* ArrowFunction */ && location.kind !== 200 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -33166,12 +34473,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33183,7 +34490,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 === 151 /* TypeParameter */) { + if (decl.kind === 154 /* 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 @@ -33238,10 +34545,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33251,9 +34558,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -33272,8 +34579,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 /* Type */ & 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1920 /* Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -33282,12 +34589,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later @@ -33311,15 +34618,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */ & ~67897832 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 /* Type */ & ~1024 /* NamespaceModule */ & ~67220415 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~67897832 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -33329,11 +34636,15 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); + if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + // constructor functions aren't block scoped + return; + } // 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 === 244 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { @@ -33365,13 +34676,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33381,7 +34692,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33446,7 +34757,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -33458,7 +34774,7 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -33482,7 +34798,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -33512,9 +34828,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -33549,7 +34866,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default" /* Default */)) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -33569,34 +34891,56 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; } - var aliasLike = resolveEntityName(expression, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 261 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); + case 258 /* ExportAssignment */: + case 208 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280 /* ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 279 /* PropertyAssignment */: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193 /* PropertyAccessExpression */: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -33606,7 +34950,7 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); @@ -33640,7 +34984,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -33656,17 +35000,15 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 258 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); + // We defer checking of the reference of an `import =` until the import itself is referenced, + // This way a chain of imports can be elided if ultimately the final input is only used in a type + // position. + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // import foo = + checkExpressionCached(node.moduleReference); + } } } } @@ -33678,18 +35020,18 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 73 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 75 /* Identifier */ || entityName.parent.kind === 152 /* 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 === 249 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 252 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -33702,9 +35044,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); @@ -33712,9 +35054,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 152 /* QualifiedName */ || name.kind === 193 /* PropertyAccessExpression */) { + var left = name.kind === 152 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 152 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -33766,7 +35108,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -33805,6 +35147,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -33816,9 +35172,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -33849,7 +35202,7 @@ var ts; if (patternAmbientModules) { var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference); if (pattern) { - // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // If the module reference matched a pattern ambient module ('*.foo') but there's also a // module augmentation by the specific name requested ('a.foo'), we store the merged symbol // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports // from a.foo. @@ -33920,7 +35273,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -33929,9 +35282,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* ValueModule */; if (merged.exports === undefined) { - merged.flags = merged.flags | 512 /* ValueModule */; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -33939,15 +35296,16 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 288 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34021,7 +35379,7 @@ var ts; return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -34158,7 +35516,8 @@ var ts; */ function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + // Type parameters end up in the `members` lists but are not externally visible + if (container && !(symbol.flags & 262144 /* TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { @@ -34167,7 +35526,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -34175,7 +35545,7 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { @@ -34183,33 +35553,42 @@ var ts; // fast path, `symbol` is either already the alias or isn't aliased return symbol; } + // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return + // the container itself as the alias for the symbol + var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + /** + * Checks if two symbols, through aliasing and/or merging, refer to the same thing + */ + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 67220415 /* Value */); + return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34287,31 +35666,61 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + case 248 /* ModuleDeclaration */: + var sym = getSymbolOfNode(location); + // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten + // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred + // to one another anyway) + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + // Type parameters are bound into `members` lists so they can merge across declarations + // This is troublesome, since in all other respects, they behave like locals :cries: + // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol + // lookup logic in terms of `resolveName` would be nice + // 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! + var table_1; + // TODO: Should this filtered table be cached in some way? + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 67220415 /* Value */ ? 67220415 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -34342,12 +35751,12 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { // If symbol is directly available by its name in the symbol table @@ -34364,7 +35773,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, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34400,7 +35809,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, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34415,10 +35824,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: continue; default: return false; @@ -34429,11 +35838,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -34476,7 +35885,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -34535,14 +35944,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -34585,21 +35994,21 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 171 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 153 /* ComputedPropertyName */) { // Typeof value - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 152 /* QualifiedName */ || entityName.kind === 193 /* PropertyAccessExpression */ || + entityName.parent.kind === 252 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 67897832 /* Type */; + meaning = 788968 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -34641,15 +36050,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructorType */ : 169 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 165 /* ConstructSignature */ : 164 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -34672,14 +36081,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -34710,6 +36122,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -34720,7 +36135,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -34748,37 +36164,37 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(144 /* UnknownKeyword */); + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139 /* StringKeyword */); + return ts.createKeywordTypeNode(142 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136 /* NumberKeyword */); + return ts.createKeywordTypeNode(139 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147 /* BigIntKeyword */); + return ts.createKeywordTypeNode(150 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124 /* BooleanKeyword */); + return ts.createKeywordTypeNode(127 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); return enumLiteralName; } if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* Type */); } if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); @@ -34787,7 +36203,7 @@ var ts; if (type.flags & 256 /* NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048 /* BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -34801,38 +36217,38 @@ var ts; if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143 /* UniqueKeyword */, ts.createKeywordTypeNode(140 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(146 /* UniqueKeyword */, ts.createKeywordTypeNode(143 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107 /* VoidKeyword */); + return ts.createKeywordTypeNode(109 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(145 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97 /* NullKeyword */); + return ts.createKeywordTypeNode(99 /* NullKeyword */); } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133 /* NeverKeyword */); + return ts.createKeywordTypeNode(136 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140 /* SymbolKeyword */); + return ts.createKeywordTypeNode(143 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* ObjectKeyword */); + return ts.createKeywordTypeNode(140 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -34846,10 +36262,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { @@ -34857,6 +36279,7 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; @@ -34864,15 +36287,9 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832 /* Type */) + ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); - } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -34880,7 +36297,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 177 /* UnionType */ : 178 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -34944,51 +36361,31 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 /* Type */ : 67220415 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; 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 === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415 /* Value */); + return symbolToTypeNode(symbol, context, 111551 /* Value */); } 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) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 67897832 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* Type */); } else { return createElidedInformationPlaceholder(context); } } 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.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -35001,15 +36398,45 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 288 /* SourceFile */ || declaration.parent.kind === 249 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions 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 + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; + var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + // 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.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -35022,12 +36449,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170 /* ConstructorType */, context); return signatureNode; } } @@ -35040,7 +36467,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2 /* WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -35048,7 +36475,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { @@ -35062,12 +36489,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -35075,6 +36502,8 @@ var ts; else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && + // Use `import` types for refs to other scopes, only anonymize something defined in the same scope + ts.findAncestor(type.symbol.valueDeclaration, function (d) { return d === ts.getSourceFileOfNode(context.enclosingDeclaration); }) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return createAnonymousTypeNode(type); } @@ -35097,7 +36526,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 67897832 /* Type */, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -35110,7 +36539,7 @@ var ts; } var flags = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832 /* Type */, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -35162,11 +36591,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35213,7 +36642,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); @@ -35224,25 +36653,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } - var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); + var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -35253,20 +36686,30 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { // Copy comments to node for declaration emit - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + ts.setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -35307,7 +36750,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 139 /* StringKeyword */ : 136 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 142 /* StringKeyword */ : 139 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -35320,7 +36763,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -35331,7 +36774,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 === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35339,23 +36782,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 /* Identifier */ ? + var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? + ts.createToken(123 /* AssertsKeyword */) : + undefined; + var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 121 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 124 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(124 /* 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); @@ -35375,9 +36821,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35387,15 +36833,14 @@ var ts; 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) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 152 /* 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) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(57 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -35405,29 +36850,32 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 190 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; // get symbol of the first identifier of the entityName - var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var firstIdentifier = getFirstIdentifier(accessExpression); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; @@ -35460,6 +36908,13 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent + // No need to lookup an alias for the symbol in itself + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -35540,7 +36995,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 288 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35576,7 +37031,7 @@ var ts; // using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -35585,7 +37040,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 67220415 /* Value */; + var isTypeOf = meaning === 111551 /* Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -35632,16 +37087,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216 /* InInitialEntityName */; } - var parent = chain[index - 1]; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { @@ -35664,7 +37135,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); } function typeParameterToName(type, context) { if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { @@ -35673,7 +37144,10 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ true); + var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 75 /* Identifier */)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -35719,9 +37193,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -35730,6 +37201,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -35757,12 +37231,1072 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + // See getNameForSymbolFromNameType for a stringy equivalent + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384 /* StringOrNumberLiteral */) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192 /* UniqueESSymbol */) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + // Make type parameters created within this context not consume the name outside this context + // The symbol serializer ends up creating many sibling scopes that all need "separate" contexts when + // it comes to naming things - within a normal `typeToTypeNode` call, the node builder only ever descends + // through the type tree, so the only cases where we could have used distinct sibling scopes was when there + // were multiple generic overloads with similar generated type parameter names + // The effect: + // When we write out + // export const x: (x: T) => T + // export const y: (x: T) => T + // we write it out like that, rather than as + // export const x: (x: T) => T + // export const y: (x: T_1) => T_1 + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159 /* MethodSignature */, /*useAcessors*/ false); + // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of + // declaration mapping + // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration + // emit codepaths which want to apply more specific contexts (so we can still refer to the root real declaration + // we're trying to emit from later on) + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.mapMap(symbolTable, function (_symbol, name) { return [ts.unescapeLeadingUnderscores(name), true]; }), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false); + if (accessibleResult.accessibility === 0 /* Accessible */) { + // Lookup the root symbol of the chain of refs we'll use to access it and serialize it + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4 /* Property */)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export=" /* ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + symbolTable = ts.createSymbolTable(); + // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) + symbolTable.set("export=" /* ExportEquals */, exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75 /* Identifier */; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from + // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1 /* Export */); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(/*alias*/ undefined, id); })), + /*moduleSpecifier*/ undefined)])); + } + // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + // Pass 2: Combine all `export {}` declarations + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), + /*moduleSpecifier*/ undefined)]); + } + // Pass 2b: Also combine all `export {} from "..."` declarations as needed + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + // remove group members from statements and then merge group members and add back to statements + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + // Pass 3: Move all `export {}`'s to `export` modifiers where possible + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + // all clauses removed, filter the export declaration + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + // some items filtered, others not - update the export declaration + // (mutating because why not, we're building a whole new tree here anyway) + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + // Not a cleanup, but as a final step: If there is a mix of `export` and non-`export` declarations, but no `export =` or `export {}` add a `export {};` so + // declaration privacy is respected. + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1 /* Export */) & ~2 /* Ambient */; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + // deferredPrivates will be filled up by visiting the symbol table + // And will continue to iterate as elements are added while visited `deferredPrivates` + // (As that's how a map iterator is defined to work) + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + // cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but + // still skip reserializing it if we encounter the merged product later on + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; // Already printed + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + // Only actually serialize symbols within the correct enclosing declaration, otherwise do nothing with the out-of-context symbol + var skipMembershipCheck = !isPrivate; // We only call this on exported symbols when we know they're in the correct scope + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias + // or a merge of some number of those. + // An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping + // each symbol in only one of the representations + // Also, synthesizing a default export of some kind + // If it's an alias: emit `export default ref` + // If it's a property: emit `export default _default` with a `_default` prop + // If it's a class/interface/function: emit a class/interface/function with a `default` modifier + // These forms can merge, eg (`export default 12; export default interface A {}`) + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default" /* Default */; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( + context.encounteredError = true; + // TODO: Issue error via symbol tracker? + return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); + if (symbol.flags & 16 /* Function */) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288 /* TypeAlias */) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + // Need to skip over export= symbols below - json source files get a single `Property` flagged + // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. + if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) + && symbol.escapedName !== "export=" /* ExportEquals */ + && !(symbol.flags & 4194304 /* Prototype */) + && !(symbol.flags & 32 /* Class */)) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384 /* Enum */) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 4 /* Property */) { + // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, + // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property + // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if (symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */)) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64 /* Interface */) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152 /* Alias */) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608 /* ExportStar */) { + // synthesize export * from "moduleReference" + // Straightforward - only one thing to do - make an export declaration + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*exportClause*/ undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + } + } + function includePrivateSymbol(symbol) { + ts.Debug.assertDefined(deferredPrivates); + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` + // Note: This _mutates_ `node` without using `updateNode` - the assumption being that all nodes should be manufactured fresh by the node builder + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0 /* None */; + if (additionalModifierFlags & 1 /* Export */ && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private + newModifierFlags |= 1 /* Export */; + } + if (addingDeclare && !(newModifierFlags & 1 /* Export */) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope + newModifierFlags |= 2 /* Ambient */; + } + if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* Default */; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; // Reset computed flags cache + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608 /* InTypeAlias */; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 164 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 165 /* ConstructSignature */); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather + // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, + // so we don't even have placeholders to fill in. + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, /*suppressNewPrivateContext*/ false); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + ts.forEach(mergedMembers, includePrivateSymbol); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + return ts.createExportSpecifier(name === localName ? undefined : localName, name); + })))]); + addResult(ts.createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ + // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` + var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined + : isConstVariable(symbol) ? 2 /* Const */ + : 1 /* Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a seperate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0 /* None */); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0 /* Call */); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + // Each overload becomes a separate function declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, 243 /* FunctionDeclaration */, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + // Module symbol emit will take care of module-y members, provided it has exports + if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + // handle remote props first - we need to make an `import` declaration that points at the module containing each remote + // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) + // Example: + // import Foo_1 = require("./exporter"); + // export namespace ns { + // import Foo = Foo_1.Foo; + // export { Foo }; + // export const c: number; + // } + // This is needed because in JS, statements like `const x = require("./f")` support both type and value lookup, even if they're + // normally just value lookup (so it functions kinda like an alias even when it's not an alias) + // _Usually_, we'll simply print the top-level as an alias instead of a `var` in such situations, however is is theoretically + // possible to encounter a situation where a type has members from both the current file and other files - in those situations, + // emit akin to the above would be needed. + // Add a namespace + var fakespace = ts.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16 /* Namespace */); + fakespace.flags ^= 8 /* Synthesized */; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + // TODO: implement handling for the localVsRemoteMap.get("remote") - should be difficult to trigger (see comment above), as only interesting cross-file js merges should make this possible + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, /*propertyAsAlias*/ true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8 /* Synthesized */; // reset synthesized + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); // namespaces can never be default exported + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); + // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics + var staticMembers = symbol.flags & (16 /* Function */ | 512 /* ValueModule */) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var constructors = serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 161 /* Constructor */); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + // A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration + // `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + // synthesize an alias, eg `export { symbolName as Name }` + // need to mark the alias `symbol` points + // at as something we need to serialize as a private declaration as well + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" /* ExportEquals */ && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match + verbatimTargetName = "default" /* Default */; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first + switch (node.kind) { + case 252 /* ImportEqualsDeclaration */: + // Could be a local `import localName = ns.member` or + // an external `import localName = require("whatever")` + var isLocalImport = !(target.flags & 512 /* ValueModule */); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0 /* None */); + break; + case 251 /* NamespaceExportDeclaration */: + // export as namespace foo + // TODO: Not part of a file's local or export symbol tables + // Is bound into file.symbol.globalExports instead, which we don't currently traverse + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + break; + case 254 /* ImportClause */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(ts.createIdentifier(localName), /*namedBindings*/ undefined), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0 /* None */); + break; + case 255 /* NamespaceImport */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + break; + case 257 /* ImportSpecifier */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0 /* None */); + break; + case 261 /* ExportSpecifier */: + // does not use localName because the symbol name in this case refers to the name in the exports table, + // which we must exactly preserve + var specifier = node.parent.parent.moduleSpecifier; + // targetName is only used when the target is local, as otherwise the target is an alias that points at + // another file + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258 /* ExportAssignment */: + serializeMaybeAliasAssignment(symbol); + break; + case 208 /* BinaryExpression */: + // Could be best encoded as though an export specifier or as though an export assignment + // If name is default or export=, do an export assignment + // Otherwise do an export specifier + if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + case 193 /* PropertyAccessExpression */: + // A PAE alias is _always_ going to exist as an append to a top-level export, where our top level + // handling should always be sufficient to encode the export action itself + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304 /* Prototype */) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export=" /* ExportEquals */; + var isDefault = name === "default" /* Default */; + var isExportAssignment = isExportEquals || isDefault; + // synthesize export = ref + // ref should refer to either be a locally scoped symbol which we need to emit, or + // a reference to another namespace/module which we may need to emit an `import` statement for + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + // serialize what the alias points to, preserve the declaration's initializer + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + if (target) { + // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it + // eg, `namespace A { export class B {} }; exports = A.B;` + // Technically, this is all that's required in the case where the assignment is an entity name expression + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + // We disable the context's symbol traker for the duration of this name serialization + // as, by virtue of being here, the name is required to print something, and we don't want to + // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue + // a visibility error here (as they're not visible within any scope), but we want to hoist them + // into the containing scope anyway, so we want to skip the visibility checks. + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + } + else { + if (first_1 === expr) { + // serialize as `export {target as name}` + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + // serialize as `import _Ref = t.arg.et; export { _Ref as name }` + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + // serialize as an anonymous property declaration + var varName = getUnusedName(name, symbol); + // We have to use `getWidenedType` here since the object within a json file is unwidened within the file + // (Unwidened types can only exist in expression contexts and should never be serialized) + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); + } + else { + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2 /* Const */)); + addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + // Only object types which are not constructable, or indexable, whose members all come from the + // context source file, and whose property names are all valid identifiers and not late-bound, _and_ + // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + !getIndexInfoOfType(typeToSerialize, 0 /* String */) && + !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols + // need to be merged namespace members + return []; + } + if (p.flags & 4194304 /* Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 /* Static */ : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 /* Accessor */ && useAccessors) { + var result = []; + if (p.flags & 65536 /* SetAccessor */) { + result.push(ts.setTextRange(ts.createSetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "arg", + /*questionToken*/ undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], + /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768 /* GetAccessor */) { + result.push(ts.setTextRange(ts.createGetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + // This is an else/if as accessors and properties can't merge in TS, but might in JS + // If this happens, we assume the accessor takes priority, as it imposes more constraints + else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { + return ts.setTextRange(createProperty( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | staticFlag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), + // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 + // interface members can't have initializers, however class members _can_ + /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0 /* Call */); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + // Each overload becomes a separate method declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; // TODO: Clone + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216 /* Optional */) { + decl.questionToken = ts.createToken(57 /* QuestionToken */); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 /* UniqueESSymbol */ && + type.symbol === symbol) { + context.flags |= 1048576 /* AllowUniqueESSymbolType */; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124 /* AnyKeyword */); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99 /* NullKeyword */)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, "x", + /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144 /* TypeParameter */) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1 /* Construct */) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // No base type, every constructor is empty - elide the extraneous `constructor()` + } + if (baseType) { + // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations + var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; // Every signature was identical - elide constructor list as it is inherited + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + // Each overload becomes a separate constructor declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0 /* String */, 1 /* Number */]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2 /* Const */)); + addResult(statement, 0 /* None */); + return ts.createExpressionWithTypeArguments(/*typeArgs*/ undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + // We don't use `isValueSymbolAccessible` below. since that considers alternative containers (like modules) + // which we can't write out in a syntactically valid way as an expression + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (input === "default" /* Default */) { + input = "_default"; + } + else if (input === "export=" /* ExportEquals */) { + input = "_exports"; + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + var flags = context.flags; + context.flags |= 16777216 /* InInitialEntityName */; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = ts.isIdentifierText(nameCandidate, languageVersion) && !ts.isStringANonContextualKeyword(nameCandidate) ? nameCandidate : getUnusedName("_default", symbol); + } + // The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createToken(123 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); @@ -35807,8 +38341,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 !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181 /* ParenthesizedType */; }); + if (node.kind === 246 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -35816,11 +38350,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 249 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 288 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35858,9 +38392,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -35873,17 +38407,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 241 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -35900,27 +38437,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 241 /* 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 247 /* EnumDeclaration */: + case 252 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -35928,53 +38466,54 @@ 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 !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 252 /* ImportEqualsDeclaration */ && parent.kind !== 288 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* 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 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 161 /* Constructor */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 155 /* Parameter */: + case 249 /* ModuleBlock */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 168 /* TypeReference */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 181 /* 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 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 288 /* SourceFile */: + case 251 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return false; default: return false; @@ -35983,14 +38522,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 258 /* ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 261 /* ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -36008,8 +38550,10 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); - if (importSymbol) { + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -36072,8 +38616,10 @@ var ts; } return ts.Debug.assertNever(propertyName); } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. + /** + * Pop an entry from the type resolution stack and return its associated result value. The result value will + * be true if no circularities were detected, or false if a circularity was found. + */ function popTypeResolution() { resolutionTargets.pop(); resolutionPropertyNames.pop(); @@ -36082,12 +38628,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 241 /* VariableDeclaration */: + case 242 /* VariableDeclarationList */: + case 257 /* ImportSpecifier */: + case 256 /* NamedImports */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: return false; default: return true; @@ -36120,7 +38666,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36172,7 +38718,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(194 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36187,23 +38733,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 190 /* BindingElement */ && parent.kind === 188 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 279 /* PropertyAssignment */ || node.kind === 280 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36221,11 +38767,11 @@ var ts; 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)) { + if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 188 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36293,30 +38839,30 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 /* NullKeyword */ || expr.kind === 73 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 /* NullKeyword */ || expr.kind === 75 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 191 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 155 /* Parameter */ && + (node.parent.kind === 200 /* FunctionExpression */ || node.parent.kind === 201 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration 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 === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230 /* 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 === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231 /* 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, @@ -36335,8 +38881,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { + declaration.kind === 241 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -36349,11 +38895,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 155 /* 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 === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 163 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36420,12 +38966,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4 /* ThisProperty */) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -36443,6 +38991,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { @@ -36468,9 +39019,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -36563,9 +39114,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 === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 /* Constructor */ || + thisContainer.kind === 243 /* FunctionDeclaration */ || + (thisContainer.kind === 200 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -36640,7 +39191,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -36663,7 +39214,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -36702,7 +39253,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 155 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -36764,16 +39315,20 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 258 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -36814,6 +39369,9 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } @@ -36828,7 +39386,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -36855,59 +39413,65 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 163 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return errorType; - } - var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { // If there are no specified types, try to infer it from the body of the get accessor if it exists. if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } // Otherwise, fall back to 'any'. else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* 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)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -36915,19 +39479,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -36939,8 +39494,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 208 /* BinaryExpression */ || + (declaration.kind === 193 /* PropertyAccessExpression */ || declaration.kind === 194 /* ElementAccessExpression */) && + declaration.parent.kind === 208 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -36979,7 +39535,7 @@ var ts; // type symbol, call getDeclaredTypeOfSymbol. // This check is important because without it, a call to getTypeOfSymbol could end // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 67220415 /* Value */ + links.type = targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -37007,7 +39563,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -37088,39 +39644,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 185 /* MappedType */: + case 179 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 185 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 179 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */ || node.kind === 245 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37128,7 +39695,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, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37137,9 +39704,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || + node.kind === 213 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37158,19 +39726,19 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37263,24 +39831,18 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37318,14 +39880,21 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } - // A valid base type is `any`, any non-generic object type or intersection of non-generic - // object types. + // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { + if (type.flags & 262144 /* TypeParameter */) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } + // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? + // There's no reason a `T` should be allowed while a `Readonly` should not. return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } @@ -37333,7 +39902,7 @@ var ts; 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 === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37369,8 +39938,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { - if (declaration.flags & 64 /* ContainsThis */) { + if (declaration.kind === 245 /* InterfaceDeclaration */) { + if (declaration.flags & 128 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -37378,7 +39947,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832 /* Type */, /*ignoreErrors*/ true); + var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -37391,9 +39960,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37409,7 +39984,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -37425,9 +40000,10 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243 /* TypeAliasDeclaration */; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("Type alias symbol with no valid declaration found"); + } var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -37443,17 +40019,17 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 208 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37461,18 +40037,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304 /* Ambient */); + return !(member.flags & 8388608 /* Ambient */); } switch (expr.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 39 /* MinusToken */ && + case 206 /* PrefixUnaryExpression */: + return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37486,10 +40063,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -37513,7 +40090,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -37585,23 +40162,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: + case 186 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -37627,7 +40204,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -37643,14 +40220,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -37705,9 +40282,12 @@ var ts; * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 /* _ */ && @@ -37760,7 +40340,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -37801,7 +40381,8 @@ var ts; // In the event we attempt to resolve the late-bound name of this member recursively, // fall back to the early-bound name of this member. links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -37817,9 +40398,9 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); } lateSymbol.nameType = type; @@ -37860,6 +40441,21 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + || assignmentKind === 4 /* ThisProperty */ + || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; @@ -37870,7 +40466,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 /* LateBindingContainer */ + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) : symbol.members || emptySymbols; } @@ -37900,7 +40496,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4 /* Reference */) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -37963,9 +40559,9 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { var sig = new Signature(checker); @@ -37996,13 +40592,18 @@ var ts; result.mapper = undefined; return result; } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.isOptionalCall = true; + return result; + } function getExpandedParameters(sig) { if (sig.hasRestParameter) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -38022,7 +40623,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38066,8 +40667,9 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true); + // Allow matching non-generic signatures to have excess parameters and different return types. + // Prefer matching this types if possible. + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -38091,7 +40693,7 @@ var ts; for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true)) { + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -38100,7 +40702,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -38118,7 +40720,7 @@ var ts; // signatures from the type, whose ordering would be non-obvious) var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -38130,8 +40732,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -38144,8 +40746,8 @@ var ts; } // A signature `this` type might be a read or a write position... It's very possible that it should be invariant // and we should refuse to merge signatures if there are `this` types and they do not match. However, so as to be - // permissive when calling, for now, we'll union the `this` types just like the overlapping-union-signature check does - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2 /* Subtype */); + // permissive when calling, for now, we'll intersect the `this` types just like we do for param types in union signatures. + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -38256,7 +40858,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -38279,19 +40881,19 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } @@ -38299,7 +40901,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38355,14 +40957,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38505,8 +41111,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && - constraintDeclaration.operator === 130 /* KeyOfKeyword */; + return constraintDeclaration.kind === 183 /* TypeOperator */ && + constraintDeclaration.operator === 133 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -38519,7 +41125,7 @@ var ts; else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T', - // the modifiers type is T. Otherwise, the modifiers type is {}. + // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; @@ -38530,8 +41136,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - 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); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -38747,11 +41353,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; 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). @@ -38761,6 +41367,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908 /* DisjointDomains */) { @@ -38773,8 +41382,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -38860,8 +41469,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -39209,10 +41818,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 === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 297 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39246,13 +41855,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; - } - function createThisTypePredicate(type) { - return { kind: 0 /* This */, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } /** * Gets the minimum number of type arguments needed to satisfy all non-optional type @@ -39318,7 +41924,7 @@ var ts; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415 /* Value */, undefined, undefined, /*isUse*/ false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this" /* This */) { @@ -39328,7 +41934,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { + if (type && type.kind === 186 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -39342,16 +41948,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 === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 162 /* GetAccessor */ || declaration.kind === 163 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 161 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -39409,13 +42015,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return node.name.kind === 153 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39458,9 +42064,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -39489,13 +42092,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73 /* Identifier */) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 /* ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -39505,8 +42105,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signature.isOptionalCall) { + type = propagateOptionalTypeMarker(type, /*wasOptional*/ true); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -39531,7 +42133,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 161 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39541,12 +42143,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39636,7 +42238,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 161 /* Constructor */ || kind === 165 /* ConstructSignature */ || kind === 170 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -39650,7 +42252,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 136 /* NumberKeyword */ : 139 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 139 /* NumberKeyword */ : 142 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -39677,21 +42279,20 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 180 /* 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 === 165 /* TypeReference */) { + if (grandParent.kind === 168 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -39716,7 +42317,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 === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -39740,7 +42341,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -39773,8 +42374,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -39789,7 +42390,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -39798,16 +42399,38 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; + return type; + } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4 /* Reference */, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; return type; } + function getTypeArguments(type) { + if (!type.resolvedTypeArguments) { + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -39817,13 +42440,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -39831,10 +42454,13 @@ var ts; return errorType; } } + if (node.kind === 168 /* TypeReference */ && isAliasedType(node)) { + return createDeferredTypeReference(type, node, /*mapper*/ undefined); + } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -39855,27 +42481,27 @@ var ts; * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -39886,34 +42512,22 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); } - // JS enums are 'string' or 'number', not an enum type. - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5 /* EnumTagType */)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -39922,55 +42536,31 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 67897832 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value imported from commonjs. + * These should really be aliases, but this special-case code fakes alias resolution + * by producing a type from a value. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); - } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && // Make sure this is a commonjs export by checking that symbol -> type -> symbol doesn't roundtrip. + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } } function getSubstitutionType(typeVariable, substitute) { @@ -39989,7 +42579,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 174 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -39998,9 +42588,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 301 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 179 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40011,7 +42601,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 168 /* TypeReference */ || node.kind === 187 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40048,10 +42638,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40063,7 +42653,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40076,10 +42666,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832 /* Type */; + var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -40112,9 +42711,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return declaration; } } @@ -40134,10 +42733,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { // Don't track references for global symbols anyway, so value if `isReference` is arbitrary @@ -40206,7 +42805,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -40233,15 +42832,55 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 /* ArrayType */ || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176 /* RestType */) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 /* OptionalType */ && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); + } + // Return true when the given node is transitively contained in type constructs that eagerly + // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments + // of type aliases are eagerly resolved. + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181 /* ParenthesizedType */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 184 /* IndexedAccessType */: + case 179 /* ConditionalType */: + case 183 /* TypeOperator */: + return isAliasedType(parent); + case 246 /* TypeAliasDeclaration */: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 /* TupleType */ && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, /*mapper*/ undefined); + } + else { + var elementTypes = node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 137 /* ReadonlyKeyword */; } // We represent tuple types as type references to synthesized generic interface types created by // this function. The types are of the form: @@ -40278,7 +42917,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -40312,27 +42951,13 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* 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; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { // don't slice off rest element index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -40381,8 +43006,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -40411,8 +43036,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -40497,10 +43122,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { continue; } if (first) { @@ -40519,14 +43144,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } // This function assumes the constituent type list is sorted and deduplicated. function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { @@ -40593,8 +43214,8 @@ var ts; // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -40632,6 +43253,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } // If the given list of types contains more than one union of primitive types, replace the // first with a union containing an intersection of those primitive types, then remove the // other unions and return true. Otherwise, do nothing and return false. @@ -40750,6 +43380,12 @@ var ts; // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768 /* Undefined */)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536 /* Null */)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } else { // 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. @@ -40854,20 +43490,22 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130 /* KeyOfKeyword */: + case 133 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 140 /* SymbolKeyword */ + case 146 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 143 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -40903,7 +43541,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -40914,13 +43552,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 103 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -41051,13 +43689,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 184 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 153 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41182,7 +43817,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 !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41394,7 +44029,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 67220415 /* Value */ | 67897832 /* Type */ : 67897832 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41417,14 +44052,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 /* Value */ + var errorMessage = targetMeaning === 111551 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -41433,16 +44068,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + if (meaning === 111551 /* Value */) { + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41466,7 +44101,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -41655,12 +44294,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -41673,89 +44326,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 124 /* AnyKeyword */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return anyType; - case 144 /* UnknownKeyword */: + case 147 /* UnknownKeyword */: return unknownType; - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return stringType; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return numberType; - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return bigintType; - case 124 /* BooleanKeyword */: + case 127 /* BooleanKeyword */: return booleanType; - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return esSymbolType; - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return voidType; - case 142 /* UndefinedKeyword */: + case 145 /* UndefinedKeyword */: return undefinedType; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullType; - case 133 /* NeverKeyword */: + case 136 /* NeverKeyword */: return neverType; - case 137 /* ObjectKeyword */: - return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 140 /* ObjectKeyword */: + return node.flags & 131072 /* JavaScriptFile */ ? anyType : nonPrimitiveType; + case 182 /* ThisType */: + case 103 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: - return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 167 /* TypePredicate */: + return node.assertsModifier ? voidType : booleanType; + case 215 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + return getTypeFromArrayOrTupleTypeNode(node); + case 175 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 181 /* ParenthesizedType */: + case 296 /* JSDocNonNullableType */: + case 292 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 180 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 187 /* 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 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -41844,20 +44497,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1 /* Identifier */, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0 /* This */, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -41911,17 +44551,17 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -41937,7 +44577,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -41950,13 +44590,14 @@ var ts; // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -41964,8 +44605,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 152 /* QualifiedName */ || + node.parent.kind === 168 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -41974,7 +44616,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 /* Block */ || n.kind === 179 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -41983,12 +44625,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 182 /* ThisType */: return !!tp.isThisType; - case 73 /* Identifier */: + case 75 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42042,7 +44684,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -42138,15 +44780,18 @@ var ts; // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32 /* Mapped */) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4 /* Reference */) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -42210,35 +44855,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: - return node.operatorToken.kind === 55 /* BarBarToken */ && + case 208 /* BinaryExpression */: + return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 271 /* 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 271 /* JsxExpression */: { + case 274 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42258,7 +44903,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* 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); @@ -42270,7 +44915,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42373,23 +45018,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 274 /* JsxExpression */: + case 199 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -42561,7 +45206,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -42570,9 +45215,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -42646,7 +45291,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -42714,11 +45359,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 163 /* SetAccessor */: return [3 /*break*/, 2]; + case 162 /* GetAccessor */: return [3 /*break*/, 2]; + case 160 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 280 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 279 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -42753,7 +45398,7 @@ var ts; } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { return compareSignaturesRelated(source, target, 0 /* None */, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -42766,7 +45411,7 @@ var ts; /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -42790,8 +45435,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 /* MethodDeclaration */ && + kind !== 159 /* MethodSignature */ && kind !== 161 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -42824,11 +45469,11 @@ var ts; // with respect to T. var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (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) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -42839,15 +45484,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -42868,6 +45515,9 @@ var ts; // wouldn't be co-variant for T without this rule. result &= callbackCheck === 1 /* Bivariant */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -42880,7 +45530,7 @@ var ts; } return 0 /* False */; } - if (source.kind === 1 /* Identifier */) { + if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -42889,7 +45539,9 @@ var ts; return 0 /* False */; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -42935,12 +45587,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { - return relation === 1 /* Succeeded */; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { + return !!(entry & 1 /* Succeeded */); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -42951,7 +45603,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); } else { enumRelation.set(id, 2 /* Failed */); @@ -43030,7 +45682,7 @@ var ts; if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { - return related === 1 /* Succeeded */; + return !!(related & 1 /* Succeeded */); } } if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { @@ -43062,9 +45714,14 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -43094,7 +45751,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -43107,8 +45764,131 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0 /* False */; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; // Suppress the next relation error + lastSkippedInfo = undefined; // Reset skipped info cache + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + return; + } + // The first error will be the innermost, while the last will be the outermost - so by popping off the end, + // we can build from left to right + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + // Parenthesize a `new` if there is one + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + // If leading, just print back the arg (irrespective of if it's a valid identifier) + if (path.length === 0) { + path = "" + str; + } + // Otherwise write a dotted name if possible + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + // Failing that, check if the name is already a computed name + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + // And finally write out a computed name as a last resort + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + // Don't flatten signature compatability errors at the start of a chain - instead prefer + // to unify (the with no arguments bit is excessive for printback) and print them back + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + // Remove the innermost secondary error as it will duplicate the error already reported by `reportRelationError` on entry + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; // Teporarily override elision to ensure error is reported + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -43121,6 +45901,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 /* TypeParameter */ && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -43139,8 +45921,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43233,7 +46015,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -43243,11 +46025,11 @@ var ts; return 0 /* False */; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = 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, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -43262,23 +46044,23 @@ var ts; return 0 /* False */; } var result = 0 /* False */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); 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 & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { if (target.flags & 1048576 /* Union */) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined, isIntersectionConstituent)) { return 0 /* False */; } } @@ -43286,9 +46068,9 @@ var ts; else if (target.flags & 2097152 /* Intersection */) { isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, /*isIntersectionConstituent*/ false)) { return 0 /* False */; } } @@ -43307,15 +46089,15 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); } if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152 /* Intersection */) { + if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) { // 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 @@ -43325,21 +46107,30 @@ 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 & 1048576 /* Union */)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) { + if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { @@ -43359,6 +46150,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } @@ -43395,7 +46187,7 @@ var ts; // check excess properties against discriminant type only, not the entire union return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -43410,6 +46202,11 @@ var ts; // 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) + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + // Note that extraneous children (as in `extra`) don't pass this check, + // since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute. + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -43438,9 +46235,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -43576,14 +46373,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { return related; } @@ -43603,7 +46400,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -43630,10 +46427,10 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t); } else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 3 /* Bivariant */) { // In the bivariant case we first compare contravariantly without reporting @@ -43642,16 +46439,16 @@ var ts; // which is generally easier to reason about. related = isRelatedTo(t, s, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } if (!related) { @@ -43662,17 +46459,6 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8 /* Unmeasurable */) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16 /* Unreliable */) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -43683,24 +46469,24 @@ var ts; return 0 /* False */; } var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2 /* Failed */) { + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24 /* ReportsMask */; + if (saved & 8 /* ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16 /* ReportsUnreliable */) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; } } if (!maybeKeys) { @@ -43731,14 +46517,26 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 /* True */ || depth === 0) { // If result is definitely true, record all maybe keys as having succeeded for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */); + relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); } maybeCount = maybeStart; } @@ -43746,7 +46544,7 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); + relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -43786,7 +46584,7 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); // 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. @@ -43794,7 +46592,7 @@ var ts; source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43876,7 +46674,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -43887,7 +46685,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43896,25 +46694,25 @@ var ts; if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43923,13 +46721,23 @@ var ts; // 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. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43938,14 +46746,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43959,7 +46767,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43978,7 +46786,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); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -44005,8 +46813,8 @@ var ts; // relates to X. Thus, we include intersection types on the source side here. 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, /*excludedProperties*/ undefined); + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; + result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); if (result) { @@ -44020,7 +46828,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; // Use variance error (there is no structural one) and return false } else if (result) { return result; @@ -44041,8 +46849,8 @@ var ts; } } return 0 /* False */; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { @@ -44051,7 +46859,7 @@ var ts; // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially // be assuming identity of the type parameter. originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -44079,7 +46887,7 @@ var ts; // comparison unexpectedly succeeds. This can happen when the structural comparison result // is a Ternary.Maybe for example caused by the recursion depth limiter. originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44155,11 +46963,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) @@ -44167,7 +46975,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -44175,8 +46983,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -44189,15 +46997,15 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, /*isIntersectionConstituent*/ false); if (result) { result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); if (result) { @@ -44232,7 +47040,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { @@ -44272,10 +47080,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -44313,10 +47121,10 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0 /* False */; } @@ -44336,7 +47144,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -44352,12 +47160,12 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) { @@ -44367,8 +47175,8 @@ var ts; 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(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined) @@ -44380,7 +47188,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -44405,8 +47213,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -44420,12 +47229,14 @@ var ts; // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members var properties = target.flags & 1048576 /* Union */ ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304 /* Prototype */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0 /* False */; } @@ -44488,14 +47299,15 @@ var ts; } } var result = -1 /* True */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 /* Instantiated */ && ts.getObjectFlags(target) & 64 /* Instantiated */ && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters // as they are known to always be the same. for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0 /* False */; } @@ -44509,7 +47321,7 @@ var ts; // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -44518,10 +47330,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -44534,11 +47346,23 @@ var ts; } return result; } + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } /** * See signatureAssignableTo, compareSignaturesIdentical */ - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -44604,7 +47428,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -44660,23 +47484,27 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + // undefined=unknown, true=discriminated, false=not discriminated + // The state of each type progresses from left to right. Discriminated types stop at 'true'. + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; // Finding multiple fields which discriminate to the same type is fine - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; + } + else { + discriminable[i] = false; } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(/*searchElement*/ true); + // make sure exactly 1 matches before returning it + return match === -1 || discriminable.indexOf(/*searchElement*/ true, match + 1) !== -1 ? defaultValue : target.types[match]; } /** * A type is 'weak' if it is an object type with at least one optional property @@ -44732,7 +47560,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -44764,7 +47592,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -44790,8 +47618,11 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -44800,7 +47631,7 @@ var ts; function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -44879,6 +47710,9 @@ var ts; // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 // levels, but unequal at some level beyond that. + // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially + // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives + // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`). 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 & 524288 /* Object */) { @@ -44895,8 +47729,30 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608 /* IndexedAccess */) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + /** + * Gets the leftmost object type in a chain of indexed accesses, eg, in A[P][Q], returns A + */ + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608 /* IndexedAccess */) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -45004,20 +47860,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - // If they're both type predicates their return types will both be `boolean`, so no need to compare those. - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : + source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type) : + 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -45056,7 +47914,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, @@ -45064,7 +47922,7 @@ var ts; return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -45148,7 +48006,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -45163,8 +48021,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -45229,6 +48087,41 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, function (t) { return t !== optionalType; }) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function createPooledOptionalTypeResult(isOptional, type) { + pooledOptionalTypeResult.isOptional = isOptional; + pooledOptionalTypeResult.type = type; + return pooledOptionalTypeResult; + } + function checkOptionalExpression(parent, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + var isOptional = false; + var type = checkExpression(expression); + if (ts.isOptionalChain(parent)) { + if (parent.questionDotToken) { + // If we have a questionDotToken then we are an OptionalExpression and should remove `null` and + // `undefined` from the type and add the optionalType to the result, if needed. + isOptional = isNullableType(type); + return createPooledOptionalTypeResult(isOptional, isOptional ? getNonNullableType(type) : type); + } + // If we do not have a questionDotToken, then we are an OptionalChain and we remove the optionalType and + // indicate whether we need to add optionalType back into the result. + var nonOptionalType = removeOptionalTypeMarker(type); + if (nonOptionalType !== type) { + isOptional = true; + type = nonOptionalType; + } + } + type = checkNonNullType(type, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + return createPooledOptionalTypeResult(isOptional, type); + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -45258,8 +48151,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45411,7 +48304,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -45448,7 +48341,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -45478,17 +48371,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 208 /* BinaryExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* 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 152 /* Parameter */: + case 155 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -45498,23 +48391,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -45528,7 +48421,7 @@ var ts; wideningKind === 1 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182 /* MappedType */: + case 185 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -45570,8 +48463,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 /* This */ || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -45640,6 +48532,12 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } @@ -45649,10 +48547,10 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & 32 /* Mapped */ || - type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -45718,10 +48616,10 @@ 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, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), 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.readonly, source.target.associatedNames); @@ -45807,8 +48705,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256 /* MaxValue */; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -45831,50 +48728,57 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - 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) { - for (var _i = 0, _a = source.types; _i < _a.length; _i++) { - var t = _a[_i]; - inferFromTypes(t, t); - } - return; - } - // Find each source constituent type that has an identically matching target constituent - // type, and for each such type infer from the type to itself. When inferring from a - // type to itself we effectively find all type parameter occurrences within that type - // and infer themselves as their type arguments. We have special handling for numeric - // and string literals because the number and string types are not represented as unions - // of all their possible values. - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } - } - // Next, to improve the quality of inferences, reduce the source and target types by - // removing the identically matched constituents. For example, when inferring from - // 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'. - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + // When source and target are the same union or intersection type, just relate each constituent + // type to itself. + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } + return; } - else if (target.flags & 1048576 /* Union */ && !(target.flags & 1024 /* EnumLiteral */) || target.flags & 2097152 /* Intersection */) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); + if (target.flags & 1048576 /* Union */) { + // First, infer between identically matching source and target constituents and remove the + // matching types. + var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + // Next, infer between closely matching source and target constituents and remove + // the matching types. Types closely match when they are instantiations of the same + // object type or instantiations of the same type alias. + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { + return; + } + target = getUnionType(targets); + if (sources.length === 0) { + // All source constituents have been matched and there is nothing further to infer from. + // However, simply making no inferences is undesirable because it could ultimately mean + // inferring a type parameter constraint. Instead, make a lower priority inference from + // the full source to whatever remains in the target. For example, when inferring from + // string to 'string | T', make a lower priority inference of string for T. + var savePriority = priority; + priority |= 1 /* NakedTypeVariable */; + inferFromTypes(source, target); + priority = savePriority; return; } + source = getUnionType(sources); + } + else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + // We reduce intersection types only when they contain naked type parameters. For example, when + // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and + // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the + // string[] on the source side and infer string for T. + // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" + // in such scenarios. + if (!(source.flags & 1048576 /* Union */)) { + // Infer between identically matching source and target constituents and remove the matching types. + var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); + } } else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { target = getActualTypeVariable(target); @@ -45919,7 +48823,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -45941,9 +48845,10 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; @@ -45979,8 +48884,8 @@ var ts; else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -46010,15 +48915,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1 /* Circularity */); + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -46058,31 +48984,34 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; + var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we - // track whether inferences were made from that particular type to some target. - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + // track whether inferences were made from that particular type to some target with + // equal priority (i.e. of equal quality) to what we would infer for a naked type + // parameter. + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - // If the target has a single naked type variable and inference completed (meaning we - // explored the types fully), create a union of the source types from which no inferences - // have been made so far and infer from that union to the naked type variable. - if (typeVariableCount === 1 && inferenceComplete) { + // If the target has a single naked type variable and no inference circularities were + // encountered above (meaning we explored the types fully), create a union of the source + // types from which no inferences have been made so far and infer from that union to the + // naked type variable. + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -46094,8 +49023,8 @@ var ts; // We infer from types that are not naked type variables first so that inferences we // make from nested naked type variables and given slightly higher priority by virtue // of being first in the candidates array. - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -46111,8 +49040,8 @@ var ts; if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1 /* NakedTypeVariable */; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -46186,7 +49115,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1 /* Circularity */; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -46198,6 +49127,11 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + // If source and target are references to the same generic type, infer from type arguments + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } 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 // from S to T and from X to Y. @@ -46227,10 +49161,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -46270,7 +49204,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 === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 160 /* MethodDeclaration */ || kind === 159 /* MethodSignature */ || kind === 161 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46296,46 +49230,12 @@ var ts; } } } - function isMatchableType(type) { - // We exclude non-anonymous object types because some frameworks (e.g. Ember) rely on the ability to - // infer between types that don't witness their type variables. Such types would otherwise be eliminated - // because they appear identical. - return !(type.flags & 524288 /* Object */) || !!(ts.getObjectFlags(type) & 16 /* Anonymous */); + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */) && target.flags & 1048576 /* Union */) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; - } - /** - * Return a new union or intersection type computed by removing a given set of types - * from a given union or intersection type. - */ - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -46474,7 +49374,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46486,7 +49386,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; @@ -46495,7 +49395,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 === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 /* TypeQuery */ ? true : n.kind === 75 /* Identifier */ || n.kind === 152 /* 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 @@ -46505,16 +49405,16 @@ var ts; // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46525,24 +49425,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73 /* Identifier */: - return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + case 75 /* Identifier */: + return target.kind === 75 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 /* VariableDeclaration */ || target.kind === 190 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 101 /* ThisKeyword */: - return target.kind === 101 /* ThisKeyword */; - case 99 /* SuperKeyword */: - return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 103 /* ThisKeyword */: + return target.kind === 103 /* ThisKeyword */; + case 101 /* SuperKeyword */: + return target.kind === 101 /* SuperKeyword */; + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -46550,8 +49450,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 /* PropertyAccessExpression */ ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -46575,7 +49475,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73 /* Identifier */) { + if (expr.kind === 75 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -46606,7 +49506,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -46634,14 +49534,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 193 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -46683,8 +49583,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -46789,15 +49689,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 208 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 231 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -46814,21 +49714,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -46836,7 +49736,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -46854,37 +49754,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 230 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 231 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 241 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 241 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 190 /* BindingElement */ && node.parent.kind === 208 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -46894,13 +49789,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 199 /* ParenthesizedExpression */ || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -46922,8 +49817,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { - if (clause.expression.kind === 10 /* StringLiteral */) { + if (clause.kind === 275 /* CaseClause */) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -47006,8 +49901,7 @@ var ts; return mapType(typeWithPrimitives, function (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; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47059,8 +49953,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47083,33 +49977,78 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 193 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 195 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 60 /* EqualsToken */ && + parent.parent.kind === 208 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 /* VariableDeclaration */ || declaration.kind === 155 /* Parameter */ || + declaration.kind === 158 /* PropertyDeclaration */ || declaration.kind === 157 /* PropertySignature */) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99 /* SuperKeyword */) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + // We require the dotted function name in an assertion expression to be comprised of identifiers + // that reference function, method, class or value module symbols; or variable, property or + // parameter symbols with declarations that have explicit type annotations. Such references are + // resolvable with no possibility of triggering circularities in control flow analysis. + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216 /* InWithStatement */)) { + switch (node.kind) { + case 75 /* Identifier */: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 103 /* ThisKeyword */: + return getExplicitThisType(node); + case 193 /* PropertyAccessExpression */: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199 /* ParenthesizedExpression */: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + // A call expression parented by an expression statement is a potential assertion. Other call + // expressions are potential type predicate function calls. In order to avoid triggering + // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call + // target expression of an assertion. + var funcType = node.parent.kind === 225 /* ExpressionStatement */ ? getTypeOfDottedName(node.expression, /*diagnostic*/ undefined) : + node.expression.kind !== 101 /* SuperKeyword */ ? checkOptionalExpression(node, node.expression).type : + undefined; + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -47117,6 +50056,68 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 /* PreFinally */ && flow.lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048 /* Shared */) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + } + noCacheCheck = false; + } + if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 4096 /* PreFinally */)) { + flow = flow.antecedent; + } + else if (flags & 512 /* Call */) { + var signature = getEffectsSignature(flow.node); + if (signature && getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 4 /* BranchLabel */) { + // A branching point is reachable if any branch is reachable. + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8 /* LoopLabel */) { + // A loop is reachable if the control flow path that leads to the top is reachable. + flow = flow.antecedents[0]; + } + else if (flags & 128 /* SwitchClause */) { + // The control flow path representing an unmatched value in a switch statement with + // no default clause is unreachable if the switch statement is exhaustive. + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192 /* AfterFinally */) { + // Cache is unreliable once we start locking nodes + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, /*skipCacheCheck*/ false); + flow.locked = false; + return result; + } + else { + return !(flags & 1 /* Unreachable */); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -47128,6 +50129,7 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; @@ -47136,7 +50138,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47158,16 +50160,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192 /* Cached */) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -47179,13 +50172,13 @@ var ts; } } var type = void 0; - if (flags & 4096 /* AfterFinally */) { + if (flags & 8192 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048 /* PreFinally */) { + else if (flags & 4096 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; @@ -47197,14 +50190,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192 /* Cached */; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512 /* Call */) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96 /* Condition */) { @@ -47231,11 +50222,11 @@ var ts; } else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && - reference.kind !== 101 /* ThisKeyword */) { + reference.kind !== 193 /* PropertyAccessExpression */ && + reference.kind !== 194 /* ElementAccessExpression */ && + reference.kind !== 103 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -47247,7 +50238,7 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // Record visited node and the associated type in the cache. sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; @@ -47257,11 +50248,34 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384 /* Cached */) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */ ? + getInitialType(node) : + getAssignedType(node), reference); + // We cache the assigned type when getFlowTypeOfReference was recursively invoked in the + // resolution of the assigned type and we're not within loop analysis. + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384 /* Cached */; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -47270,11 +50284,11 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } @@ -47283,27 +50297,60 @@ var ts; // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } // A matching dotted name might also be an expando property on a function *expression*, // 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 === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 200 /* FunctionExpression */ || init.kind === 201 /* 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 === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 208 /* BinaryExpression */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56 /* BarBarToken */) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, /*assumeTrue*/ true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : + predicate.kind === 3 /* AssertsIdentifier */ ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 195 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47311,7 +50358,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47346,7 +50393,7 @@ var ts; // *only* place a silent never type is ever generated. var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -47364,12 +50411,15 @@ 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 === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { type = declaredType; } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } return createFlowType(type, isIncomplete(flowType)); } function getTypeAtFlowBranchLabel(flow) { @@ -47378,7 +50428,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + if (antecedent.flags & 4096 /* PreFinally */ && antecedent.lock.locked) { // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. @@ -47438,25 +50488,32 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + // The first antecedent of a loop junction is always the non-looping control + // flow path that leads to the top. + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - // If we see a value appear in the cache it is a sign that control flow analysis - // was restarted and completed by checkExpressionCached. We can simply pick up - // the resulting type and bail out. - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + // All but the first antecedent are the looping control flow paths that lead + // back to the loop junction. We track these on the flow loop stack. + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + // If we see a value appear in the cache it is a sign that control flow analysis + // was restarted and completed by checkExpressionCached. We can simply pick up + // the resulting type and bail out. + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control @@ -47530,19 +50587,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -47561,9 +50618,9 @@ var ts; return declaredType; } break; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94 /* InKeyword */: + case 96 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -47578,11 +50635,11 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && (operator === 35 /* EqualsEqualsEqualsToken */) && assumeTrue) { + if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { return valueType; } @@ -47595,7 +50652,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? @@ -47607,7 +50664,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* EqualsEqualsToken */ ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -47620,7 +50677,7 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // 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 @@ -47630,7 +50687,7 @@ var ts; } return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (type.flags & 1 /* Any */ && literal.text === "function") { @@ -47857,22 +50914,24 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { return type; } - if (ts.isIdentifierTypePredicate(predicate)) { + if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { var predicateArgument = callExpression.arguments[predicate.parameterIndex]; - if (predicateArgument) { + if (predicateArgument && predicate.type) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } @@ -47883,7 +50942,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { + if (ts.isAccessExpression(invokedExpression) && predicate.type) { var possibleReference = ts.skipParentheses(invokedExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -47898,27 +50957,44 @@ var ts; // Narrow the given type based on the given expression having the assumed boolean value. The returned type // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { + // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` + if (ts.isOptionalChainRoot(expr.parent) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 195 /* CallExpression */: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: - if (expr.operator === 52 /* ExclamationToken */) { + case 206 /* PrefixUnaryExpression */: + if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; @@ -47926,7 +51002,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 === 73 /* Identifier */) { + if (location.kind === 75 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -47947,9 +51023,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 249 /* ModuleBlock */ || + node.kind === 288 /* SourceFile */ || + node.kind === 158 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -47968,10 +51044,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 === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155 /* Parameter */) { symbol.isAssigned = true; } } @@ -47986,7 +51062,7 @@ 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 === 152 /* Parameter */ && + declaration.kind === 155 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -47994,10 +51070,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 193 /* PropertyAccessExpression */ || + parent.kind === 195 /* CallExpression */ && parent.expression === node || + parent.kind === 194 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 190 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48012,8 +51088,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -48031,7 +51110,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* 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 */)) { @@ -48052,7 +51131,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 === 241 /* ClassDeclaration */ + if (declaration.kind === 244 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48064,14 +51143,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 213 /* 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 !== 285 /* SourceFile */) { + while (container.kind !== 288 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 158 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48120,7 +51199,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 === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 155 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48129,8 +51208,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 === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 /* FunctionExpression */ || + flowContainer.kind === 201 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48138,11 +51217,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 4194304 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261 /* ExportSpecifier */) || + node.parent.kind === 217 /* NonNullExpression */ || + declaration.kind === 241 /* VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -48176,7 +51255,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 278 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48199,7 +51278,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, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48217,8 +51296,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 === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 229 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48236,7 +51315,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 199 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48244,9 +51323,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 206 /* PrefixUnaryExpression */ || current.parent.kind === 207 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -48257,7 +51336,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 158 /* PropertyDeclaration */ || container.kind === 161 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48325,37 +51404,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 161 /* 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 === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* 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 244 /* EnumDeclaration */: + case 247 /* 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 158 /* Constructor */: + case 161 /* 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 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* 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 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48394,10 +51473,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48405,12 +51482,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 200 /* FunctionExpression */ || container.kind === 243 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48439,9 +51514,22 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 200 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48451,16 +51539,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 160 /* MethodDeclaration */ && + container.parent.kind === 192 /* 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 === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && + container.parent.kind === 279 /* PropertyAssignment */ && + container.parent.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48468,7 +51556,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 197 /* FunctionExpression */ && + else if (container.kind === 200 /* 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") && @@ -48493,7 +51581,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 298 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48507,15 +51595,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 /* 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 === 198 /* ArrowFunction */) { + while (container && container.kind === 201 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48528,14 +51616,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153 /* ComputedPropertyName */; }); + if (current && current.kind === 153 /* 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 === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -48543,7 +51631,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 161 /* 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) { @@ -48612,7 +51700,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 === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 160 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -48626,7 +51714,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 192 /* 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; @@ -48647,7 +51735,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 /* 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; @@ -48662,7 +51750,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 === 158 /* Constructor */; + return container.kind === 161 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -48670,21 +51758,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 === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */ || + container.kind === 158 /* PropertyDeclaration */ || + container.kind === 157 /* PropertySignature */ || + container.kind === 161 /* Constructor */; } } } @@ -48692,14 +51780,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 160 /* MethodDeclaration */ || + func.kind === 162 /* GetAccessor */ || + func.kind === 163 /* SetAccessor */) && func.parent.kind === 192 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 200 /* FunctionExpression */ && func.parent.kind === 279 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -48707,7 +51795,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -48734,7 +51822,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 279 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -48748,9 +51836,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 === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 193 /* PropertyAccessExpression */ || target.kind === 194 /* 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)) { @@ -48814,9 +51902,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 155 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -48906,6 +51994,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -48937,7 +52034,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 197 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -48946,7 +52043,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: if (node !== right) { return undefined; } @@ -48955,7 +52052,8 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -48964,7 +52062,7 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -48992,19 +52090,22 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -49026,12 +52127,13 @@ var ts; } if (kind === 2 /* ModuleExports */) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -49075,7 +52177,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49164,32 +52266,35 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 73 /* Identifier */: - case 142 /* UndefinedKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 75 /* Identifier */: + case 145 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 199 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 274 /* 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 === 276 /* 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 === 279 /* 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 === 268 /* 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 === 271 /* 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, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, /*noReductions*/ true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -49256,7 +52361,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49265,58 +52370,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 190 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 201 /* ArrowFunction */: + case 234 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: - if (parent.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (parent.expression.kind === 95 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: + case 196 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 191 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 220 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 210 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 199 /* 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, contextFlags); } - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49471,7 +52576,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 200 /* FunctionExpression */ || node.kind === 201 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49485,14 +52590,12 @@ 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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1 /* Signature */) : - getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* Signature */); if (!type) { return undefined; } @@ -49501,8 +52604,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -49532,8 +52635,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 190 /* BindingElement */ && !!node.initializer) || + (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -49545,7 +52648,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 212 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -49570,12 +52673,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 212 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212 /* 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] = []". @@ -49617,9 +52720,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return isNumericComputedName(name); - case 73 /* Identifier */: + case 75 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -49707,7 +52810,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 188 /* ObjectBindingPattern */ || contextualType.pattern.kind === 192 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -49722,13 +52825,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 === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 279 /* PropertyAssignment */ || + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -49751,8 +52854,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 === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -49777,7 +52880,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 281 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -49803,7 +52906,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 162 /* GetAccessor */ || memberDecl.kind === 163 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -49863,7 +52966,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -49911,7 +53020,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 === 73 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -49956,7 +53065,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 273 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -49979,7 +53088,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 /* 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); @@ -50053,7 +53162,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -50127,7 +53236,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -50151,7 +53260,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -50303,13 +53412,13 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted reactSym.isReferenced = 67108863 /* All */; - // If react symbol is alias, mark it as referenced - if (reactSym.flags & 2097152 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 2097152 /* Alias */) { markAliasSymbolAsReferenced(reactSym); } } @@ -50398,7 +53507,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 152 /* QualifiedName */ ? node.right : node.kind === 187 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* 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)); @@ -50496,12 +53605,11 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); + } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (strictNullChecks && type.flags & 2 /* Unknown */) { @@ -50533,14 +53641,13 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + var _a = checkOptionalExpression(node, left), isOptional = _a.isOptional, leftType = _a.type; var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -50554,6 +53661,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0 /* String */) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -50581,9 +53689,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 103 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -50592,14 +53700,14 @@ var ts; } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return propagateOptionalTypeMarker(getFlowTypeOfAccessExpression(node, prop, propType, right), isOptional); } function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { // 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. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 194 /* ElementAccessExpression */ && node.kind !== 193 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -50609,11 +53717,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 && node.expression.kind === 101 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -50634,7 +53742,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -50644,9 +53752,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && - !(valueDeclaration.flags & 4194304 /* Ambient */) && + else if (valueDeclaration.kind === 244 /* ClassDeclaration */ && + node.parent.kind !== 168 /* TypeReference */ && + !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -50657,22 +53765,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 279 /* PropertyAssignment */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 281 /* SpreadAssignment */: + case 153 /* ComputedPropertyName */: + case 220 /* TemplateSpan */: + case 274 /* JsxExpression */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 266 /* JsxOpeningElement */: + case 215 /* ExpressionWithTypeArguments */: + case 277 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -50712,7 +53820,7 @@ var ts; 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)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -50750,7 +53858,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415 /* Value */); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -50845,16 +53953,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 101 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 152 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 187 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 /* PropertyAccessExpression */ && node.expression.kind === 101 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -50871,13 +53979,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 242 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73 /* Identifier */) { + else if (initializer.kind === 75 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -50894,13 +54002,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73 /* Identifier */) { + if (e.kind === 75 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 230 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -50914,28 +54022,14 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + var _a = checkOptionalExpression(node, node.expression), isOptional = _a.isOptional, exprType = _a.type; var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* 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); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -50944,7 +54038,7 @@ var ts; 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); + return propagateOptionalTypeMarker(checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node), isOptional); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === errorType) { @@ -50990,13 +54084,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 156 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51015,7 +54109,7 @@ var ts; // interface B extends A { (x: 'foo'): string } // const b: B; // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -51023,8 +54117,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -51056,11 +54150,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? createOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 212 /* SpreadElement */ || arg.kind === 219 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51074,9 +54168,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 210 /* 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. @@ -51091,7 +54185,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 156 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51106,7 +54200,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 196 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51199,7 +54293,7 @@ var ts; // 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 !== 153 /* Decorator */) { + if (node.kind !== 156 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51229,7 +54323,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -51242,7 +54336,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51266,7 +54360,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 219 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51341,12 +54435,12 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 196 /* 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. @@ -51356,7 +54450,7 @@ var ts; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -51364,7 +54458,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -51374,7 +54468,7 @@ var ts; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -51384,7 +54478,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -51405,15 +54499,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 193 /* PropertyAccessExpression */ || callee.kind === 194 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(219 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51423,17 +54517,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 156 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51448,7 +54542,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, /*isSpread*/ i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -51463,30 +54557,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* 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 152 /* Parameter */: + case 155 /* 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 === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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 !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 158 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51500,17 +54594,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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 152 /* Parameter */: + case 155 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -51548,8 +54642,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -51618,8 +54712,8 @@ var ts; // Overloads exist var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -51634,22 +54728,22 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 156 /* 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 !== 99 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -51698,7 +54792,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 195 /* 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 @@ -51751,7 +54845,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -51769,7 +54863,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -51903,7 +54997,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { + var _loop_15 = function (i) { var symbols = ts.mapDefined(candidates, function (_a) { var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; return hasRestParameter ? @@ -51914,7 +55008,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); var hasRestParameter = restParameterSymbols.length !== 0; @@ -51992,7 +55086,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -52007,12 +55101,12 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var _b = checkOptionalExpression(node, node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined), isOptional = _b.isOptional, funcType = _b.type; if (funcType === silentNeverType) { return silentNeverSignature; } @@ -52078,7 +55172,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -52141,7 +55235,7 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time @@ -52149,7 +55243,7 @@ var ts; // operation is Any. It is an error to have a Void this type. var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -52234,8 +55328,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var constituent = types_16[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52326,23 +55420,23 @@ var ts; invocationError(node.tag, apparentType, 0 /* Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52379,16 +55473,16 @@ var ts; invocationErrorRecovery(apparentType, 0 /* Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, 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(121 /* AnyKeyword */)); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* 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(124 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -52419,7 +55513,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -52435,16 +55529,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 156 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52495,57 +55589,52 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); - } - return false; - } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 193 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -52560,15 +55649,15 @@ var ts; // returns a function type. We defer checking and return nonInferrableType. return nonInferrableType; } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 196 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 161 /* Constructor */ && + declaration.kind !== 165 /* ConstructSignature */ && + declaration.kind !== 170 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -52588,18 +55677,28 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 /* CallExpression */ && node.parent.kind === 225 /* ExpressionStatement */ && + returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -52616,7 +55715,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -52637,7 +55736,7 @@ var ts; // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -52676,7 +55775,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -52685,19 +55784,20 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 243 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 241 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 4194304 /* Ambient */); + return !!decl && !!(decl.flags & 8388608 /* Ambient */); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 131072 /* MakeTemplateObject */); } @@ -52712,20 +55812,20 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || + op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -52761,10 +55861,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96 /* NewKeyword */) { + if (node.keywordToken === 98 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93 /* ImportKeyword */) { + if (node.keywordToken === 95 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -52775,7 +55875,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 === 158 /* Constructor */) { + else if (container.kind === 161 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -52785,11 +55885,11 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 /* ESNext */ || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -52831,7 +55931,7 @@ var ts; // otherwise would return the type 'undefined'). var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -52863,7 +55963,7 @@ var ts; if (signature.hasRestParameter) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; @@ -52961,7 +56061,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 === 73 /* Identifier */) { + if (element.name.kind === 75 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -52975,8 +56075,8 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73 /* Identifier */) { - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + if (decl.name.kind !== 75 /* Identifier */) { + // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -53030,7 +56130,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 222 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -53102,7 +56202,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -53213,17 +56313,18 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200 /* TypeOfExpression */) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203 /* 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 & 131072 /* Never */); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -53236,13 +56337,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128 /* HasImplicitReturn */)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */ function checkAndAggregateReturnExpressionTypes(func, checkMode) { @@ -53282,11 +56377,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 160 /* MethodDeclaration */: + return func.parent.kind === 192 /* ObjectLiteralExpression */; default: return false; } @@ -53312,10 +56407,10 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 159 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 222 /* Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; if (type && type.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -53345,7 +56440,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -53365,7 +56460,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 200 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53419,7 +56514,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53432,7 +56527,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 222 /* Block */) { checkSourceElement(node.body); } else { @@ -53513,11 +56608,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && - expr.expression.kind === 101 /* ThisKeyword */) { + (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) && + expr.expression.kind === 103 /* 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 === 158 /* Constructor */)) { + if (!(func && func.kind === 161 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -53530,31 +56625,35 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 255 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 75 /* Identifier */ && node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32 /* OptionalChain */) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 193 /* PropertyAccessExpression */ && expr.kind !== 194 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -53576,14 +56675,14 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 16384 /* AwaitContext */)) { + if (!(node.flags & 32768 /* AwaitContext */)) { // use of 'await' in non-async function var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -53596,7 +56695,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) { + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -53606,14 +56709,14 @@ var ts; switch (node.operand.kind) { case 8 /* NumericLiteral */: switch (node.operator) { - case 39 /* MinusToken */: + case 40 /* MinusToken */: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38 /* PlusToken */: + case 39 /* PlusToken */: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9 /* BigIntLiteral */: - if (node.operator === 39 /* MinusToken */) { + if (node.operator === 40 /* MinusToken */) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -53621,32 +56724,32 @@ var ts; } } switch (node.operator) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38 /* PlusToken */) { + if (node.operator === 39 /* 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)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 45 /* PlusPlusToken */: + case 46 /* 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -53660,7 +56763,7 @@ var ts; 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -53681,8 +56784,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -53771,7 +56874,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */ || property.kind === 280 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -53784,9 +56887,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 281 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -53829,8 +56932,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 214 /* OmittedExpression */) { + if (element.kind !== 212 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -53848,7 +56951,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 208 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -53864,7 +56967,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 280 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -53880,24 +56983,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 208 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 192 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 191 /* 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 === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 281 /* 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)) { + var optionalError = target.parent.kind === 281 /* SpreadAssignment */ ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -53913,53 +57019,53 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 145 /* UndefinedKeyword */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 203 /* TypeOfExpression */: + case 217 /* NonNullExpression */: + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 52 /* ExclamationToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 53 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 204 /* VoidExpression */: // Explicit opt-out + case 198 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 216 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -53971,15 +57077,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60 /* QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); + if (operator === 62 /* EqualsToken */ && (left.kind === 192 /* ObjectLiteralExpression */ || left.kind === 191 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103 /* ThisKeyword */); } var leftType; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -53987,28 +57105,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40 /* AsteriskToken */: - case 41 /* AsteriskAsteriskToken */: - case 63 /* AsteriskEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 43 /* PercentToken */: - case 66 /* PercentEqualsToken */: - case 39 /* MinusToken */: - case 62 /* MinusEqualsToken */: - case 46 /* LessThanLessThanToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: + case 41 /* AsteriskToken */: + case 42 /* AsteriskAsteriskToken */: + case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 44 /* PercentToken */: + case 68 /* PercentEqualsToken */: + case 40 /* MinusToken */: + case 64 /* MinusEqualsToken */: + case 47 /* LessThanLessThanToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54035,17 +57153,17 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); } resultType_1 = bigintType; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54053,8 +57171,8 @@ var ts; } return resultType_1; } - case 38 /* PlusToken */: - case 61 /* PlusEqualsToken */: + case 39 /* PlusToken */: + case 63 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54087,24 +57205,24 @@ var ts; } if (!resultType) { // Types that have a reasonably good chance of being a valid operand type. - // If both types have an awaited type of one of these, we’ll assume the user + // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61 /* PlusEqualsToken */) { + if (operator === 63 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -54113,25 +57231,29 @@ var ts; }); } return booleanType; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 60 /* EqualsToken */: + case 60 /* QuestionQuestionToken */: + return getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + leftType; + case 62 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -54158,6 +57280,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54165,7 +57290,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -54175,7 +57300,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 75 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -54190,15 +57315,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - return 55 /* BarBarToken */; - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - return 36 /* ExclamationEqualsEqualsToken */; - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: - return 54 /* AmpersandAmpersandToken */; + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + return 56 /* BarBarToken */; + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + return 37 /* ExclamationEqualsEqualsToken */; + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: + return 55 /* AmpersandAmpersandToken */; default: return undefined; } @@ -54211,7 +57336,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non-compound operation to be assignable to the type of VarExpr. - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); @@ -54245,17 +57370,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); + } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54263,12 +57394,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: typeName = "false"; break; - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -54277,6 +57408,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54295,7 +57437,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -54344,12 +57486,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2 /* Next */, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -54371,7 +57508,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 /* 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; @@ -54410,12 +57547,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 198 /* TypeAssertionExpression */ || node.kind === 216 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54437,10 +57574,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54492,7 +57629,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54503,7 +57640,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54515,8 +57652,8 @@ var ts; var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8 /* SkipGenericFunctions */) { @@ -54646,11 +57783,11 @@ 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 === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + var _a = checkOptionalExpression(expr, expr.expression), isOptional = _a.isOptional, funcType = _a.type; var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -54696,17 +57833,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 261 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 8388608 /* Ambient */)); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304 /* Ambient */) { + if (constEnumDeclaration.flags & 8388608 /* Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -54719,14 +57857,25 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { - case 73 /* Identifier */: + var kind = node.kind; + if (cancellationToken) { + // 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 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 75 /* Identifier */: return checkIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return checkThisExpression(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkSuperExpression(node); - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -54737,82 +57886,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: return trueType; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: - if (node.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (node.expression.kind === 95 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 196 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 219 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -54849,7 +57998,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -54860,10 +58009,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 === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 161 /* Constructor */ || func.kind === 165 /* ConstructSignature */ || func.kind === 170 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -54887,7 +58036,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -54896,9 +58045,11 @@ var ts; error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, - /*headMessage*/ undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, + /*headMessage*/ undefined, leadingError); + } } } else if (parameterName) { @@ -54919,13 +58070,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 201 /* ArrowFunction */: + case 164 /* CallSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 169 /* FunctionType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -54939,11 +58090,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 75 /* 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 === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 189 /* ArrayBindingPattern */ || name.kind === 188 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -54952,13 +58103,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* 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 === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 169 /* FunctionType */ || node.kind === 243 /* FunctionDeclaration */ || node.kind === 170 /* ConstructorType */ || + node.kind === 164 /* CallSignature */ || node.kind === 161 /* Constructor */ || + node.kind === 165 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -54988,10 +58139,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55021,28 +58172,21 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 166 /* IndexSignature */ && node.kind !== 298 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } } function checkClassForDuplicateDeclarations(node) { - var Declaration; - (function (Declaration) { - Declaration[Declaration["Getter"] = 1] = "Getter"; - Declaration[Declaration["Setter"] = 2] = "Setter"; - Declaration[Declaration["Method"] = 4] = "Method"; - Declaration[Declaration["Property"] = 3] = "Property"; - })(Declaration || (Declaration = {})); var instanceNames = ts.createUnderscoreEscapedMap(); var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 161 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* Property */); + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { + addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } } @@ -55053,17 +58197,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: - addName(names, name, memberName, 1 /* Getter */); + case 162 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: - addName(names, name, memberName, 2 /* Setter */); + case 163 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* Property */); + case 158 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: - addName(names, name, memberName, 4 /* Method */); + case 160 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */); break; } } @@ -55072,8 +58216,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4 /* Method */) { - if (meaning !== 4 /* Method */) { + if (prev & 8 /* Method */) { + if (meaning !== 8 /* Method */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -55125,7 +58269,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 157 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55133,7 +58277,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 73 /* Identifier */: + case 75 /* Identifier */: memberName = ts.idText(name); break; default: @@ -55150,7 +58294,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* 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 @@ -55170,7 +58314,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -55178,7 +58322,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -55205,7 +58349,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 === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 160 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55230,7 +58374,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55258,9 +58402,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55285,9 +58429,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { - if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { - if (!(node.flags & 256 /* HasExplicitReturn */)) { + if (node.kind === 162 /* GetAccessor */) { + if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { + if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -55295,13 +58439,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* 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 === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55319,7 +58463,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55367,19 +58511,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { @@ -55415,16 +58556,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 176 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 175 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55445,7 +58586,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 /* 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)); } @@ -55496,7 +58637,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 /* 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); @@ -55507,16 +58648,16 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 4194304 /* Ambient */); + return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && - n.flags & 4194304 /* Ambient */) { + if (n.parent.kind !== 245 /* InterfaceDeclaration */ && + n.parent.kind !== 244 /* ClassDeclaration */ && + n.parent.kind !== 213 /* ClassExpression */ && + n.flags & 8388608 /* 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 flags |= 1 /* Export */; @@ -55606,7 +58747,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 === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* 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 @@ -55641,11 +58782,12 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent.kind === 245 /* InterfaceDeclaration */ || node.parent.kind === 172 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -55656,7 +58798,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if ((node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 243 /* FunctionDeclaration */ || node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */ || node.kind === 161 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -55697,6 +58842,15 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { + // A non-ambient class cannot be an implementation for a non-constructor function/class merge + // TODO: The below just replicates our older error from when classes and functions were + // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" + // might be warranted. :shrug: + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { @@ -55708,8 +58862,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -55718,13 +58872,6 @@ var ts; } } } - var DeclarationSpaces; - (function (DeclarationSpaces) { - DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; - DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; - DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; - DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; - })(DeclarationSpaces || (DeclarationSpaces = {})); function checkExportsOnMergedDeclarations(node) { if (!produceDiagnostics) { return; @@ -55785,40 +58932,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 258 /* 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 */; } 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 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 243 /* FunctionDeclaration */: + case 257 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -55852,7 +59001,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { @@ -55887,9 +59036,6 @@ var ts; */ function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3 /* AnyOrUnknown */)) { - addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -56048,10 +59194,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 75 /* 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 { @@ -56071,7 +59217,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -56090,24 +59236,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 155 /* 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 155 /* PropertyDeclaration */: + case 158 /* 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 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56128,7 +59274,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 75 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56153,29 +59299,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var typeNode = types_18[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* 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); @@ -56221,14 +59367,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* 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 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56237,23 +59383,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 160 /* 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 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 155 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56316,7 +59462,7 @@ var ts; 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 === 149 /* 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 === 152 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56349,9 +59495,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56364,7 +59510,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 === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56380,7 +59526,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -56393,7 +59539,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 159 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56419,7 +59565,7 @@ var ts; } function registerForUnusedIdentifiersCheck(node) { // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`. - if (produceDiagnostics && !(node.flags & 4194304 /* Ambient */)) { + if (produceDiagnostics && !(node.flags & 8388608 /* Ambient */)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -56435,42 +59581,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 288 /* SourceFile */: + case 248 /* ModuleDeclaration */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 180 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56490,11 +59636,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 160 /* MethodDeclaration */: + case 158 /* PropertyDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + if (member.kind === 163 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56503,7 +59649,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 158 /* Constructor */: + case 161 /* 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 */)) { @@ -56511,8 +59657,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 166 /* IndexSignature */: + case 221 /* SemicolonClassElement */: // Can't be private break; default: @@ -56539,7 +59685,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -56574,7 +59720,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304 /* Ambient */) + if (nodeWithLocals.flags & 8388608 /* Ambient */) return; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); @@ -56609,7 +59755,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -56624,7 +59770,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -56642,7 +59788,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 === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 242 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -56663,7 +59809,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -56675,24 +59821,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 254 /* ImportClause */ || node.kind === 257 /* ImportSpecifier */ || node.kind === 255 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 254 /* ImportClause */ ? decl : decl.kind === 255 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 222 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -56709,7 +59855,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -56722,21 +59868,21 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 158 /* PropertyDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 160 /* MethodDeclaration */ || + node.kind === 159 /* MethodSignature */ || + node.kind === 162 /* GetAccessor */ || + node.kind === 163 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // ambient context - no codegen impact return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -56746,7 +59892,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 73 /* Identifier */; + var isDeclaration_1 = node.kind !== 75 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -56761,7 +59907,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 73 /* Identifier */; + var isDeclaration_2 = node.kind !== 75 /* 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); } @@ -56787,7 +59933,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 /* 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)); } @@ -56802,7 +59948,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* 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)); } @@ -56837,7 +59983,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 === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 241 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -56849,17 +59995,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 224 /* 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 === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 222 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 249 /* ModuleBlock */ || + container.kind === 248 /* ModuleDeclaration */ || + container.kind === 288 /* 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 @@ -56889,18 +60035,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 190 /* BindingElement */) { + if (node.parent.kind === 188 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -56914,26 +60060,26 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 /* 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 === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 /* 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)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -56970,7 +60116,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -56996,10 +60142,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -57008,7 +60154,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 158 /* PropertyDeclaration */ || nextDeclaration.kind === 157 /* PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -57018,8 +60164,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 155 /* Parameter */ && right.kind === 241 /* VariableDeclaration */) || + (left.kind === 241 /* VariableDeclaration */ && right.kind === 155 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57056,13 +60202,56 @@ var ts; function checkIfStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 223 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + // While it technically should be invalid for any known-truthy value + // to be tested, we de-scope to functions unrefenced in the block as a + // heuristic to identify the most common bugs. There are too many + // false positives for values sourced from type definitions without + // strictNullChecks otherwise. + var callSignatures = getSignaturesOfType(type, 0 /* Call */); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -57085,12 +60274,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 242 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57124,14 +60313,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* 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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* 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. @@ -57139,7 +60328,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -57163,7 +60352,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* 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); @@ -57177,7 +60366,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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* 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)) { @@ -57185,7 +60374,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved @@ -57538,7 +60727,7 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use @@ -57550,7 +60739,7 @@ var ts; // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -57629,7 +60818,7 @@ var ts; // - `Generator` or `AsyncGenerator` var globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `IterableIterator` and `AsyncIterableIterator` are defined by the // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. @@ -57640,7 +60829,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(/*reportErrors*/ false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -57676,11 +60865,11 @@ var ts; // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` // or `IteratorReturnResult` types, then just grab its type argument. if (isReferenceToType(type, getGlobalIteratorYieldResultType(/*reportErrors*/ false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, /*returnType*/ undefined, /*nextType*/ undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(/*reportErrors*/ false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(/*yieldType*/ undefined, returnType_1, /*nextType*/ undefined); } // Choose any constituents that can produce the requested iteration type. @@ -57744,11 +60933,13 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + // The value of `next(value)` is *not* awaited by async generators + nextType = methodParameterType; } else if (methodName === "return") { + // The value of `return(value)` *is* awaited by async generators + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -57841,12 +61032,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160 /* SetAccessor */) { + if (func.kind === 163 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 161 /* 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); } @@ -57864,7 +61055,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -57872,7 +61063,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384 /* AwaitContext */) { + if (node.flags & 32768 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -57893,7 +61084,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 === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 276 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -57905,7 +61096,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 275 /* 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. @@ -57934,7 +61125,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58041,8 +61232,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 === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 208 /* BinaryExpression */ || + name.kind === 153 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58119,7 +61310,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 168 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58179,11 +61370,10 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - // relax check if later interface augmentation has no constraint - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + // relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with + // a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill) + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } // If the type parameter node has a default and it is not identical to the default // for the type parameter at this position, we report an error. @@ -58220,7 +61410,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassNameCollisionWithObject(node.name); } } @@ -58233,11 +61423,12 @@ var ts; checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } @@ -58275,12 +61466,9 @@ var ts; } 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 - // that the base type is a class or interface type (and not, for example, an anonymous object type). - // (Javascript constructor functions have this property trivially true since their return type is ignored.) + // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -58323,7 +61511,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -58342,7 +61530,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -58368,7 +61556,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 244 /* ClassDeclaration */ || d.kind === 245 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58387,7 +61575,7 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304 /* Prototype */) { @@ -58396,53 +61584,104 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overridden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 210 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + // In order to resolve whether the inherited method was overridden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { + // Searches other base types for a declaration that would satisfy the inherited abstract member. + // (The class may have more than one base type via declaration merging with an interface with the + // same name.) + for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { + var otherBaseType = _b[_a]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } + if (derivedClassDecl.kind === 213 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } - else { - // derived overrides base. - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { - // either base or derived property is private - not override, skip it + } + else { + // derived overrides base. + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + // either base or derived property is private - not override, skip it + continue; + } + var errorMessage = void 0; + var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + if (basePropertyFlags && derivedPropertyFlags) { + // property/accessor is overridden with property/accessor + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 /* InterfaceDeclaration */ + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { + // when the base property is abstract or from an interface, base/derived flags don't need to match + // same when the derived property is from an assignment continue; } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; + if (basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + else if (basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 /* PropertyDeclaration */ && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432 /* Transient */) + && !(baseDeclarationFlags & 128 /* Abstract */) + && !(derivedDeclarationFlags & 128 /* Abstract */) + && !derived.declarations.some(function (d) { return d.flags & 8388608 /* Ambient */; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } } + // correct case + continue; + } + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived)) { + // method is overridden with method -- correct case + continue; } - else if (base.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + else if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -58479,12 +61718,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2 /* Ambient */) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -58499,7 +61741,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -58523,7 +61765,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -58586,7 +61828,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -58618,7 +61860,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304 /* Ambient */) { + else if (member.parent.flags & 8388608 /* Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -58628,66 +61870,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38 /* PlusToken */: return value_2; - case 39 /* MinusToken */: return -value_2; - case 53 /* TildeToken */: return ~value_2; + case 39 /* PlusToken */: return value_2; + case 40 /* MinusToken */: return -value_2; + case 54 /* TildeToken */: return ~value_2; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - 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 === 38 /* PlusToken */) { + case 51 /* BarToken */: return left | right; + case 50 /* AmpersandToken */: return left & right; + case 48 /* GreaterThanGreaterThanToken */: return left >> right; + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* LessThanLessThanToken */: return left << right; + case 52 /* CaretToken */: return left ^ right; + case 41 /* AsteriskToken */: return left * right; + case 43 /* SlashToken */: return left / right; + case 39 /* PlusToken */: return left + right; + case 40 /* MinusToken */: return left - right; + case 44 /* PercentToken */: return left % right; + case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { return left + right; } break; case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 73 /* Identifier */: + case 75 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* 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 === 190 /* PropertyAccessExpression */) { + if (ex.kind === 193 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -58712,10 +61953,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10 /* StringLiteral */; + return node.kind === 75 /* Identifier */ || + node.kind === 193 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 194 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -58749,7 +61990,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 !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 247 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -58772,9 +62013,9 @@ 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 === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304 /* Ambient */)) { + if ((declaration.kind === 244 /* ClassDeclaration */ || + (declaration.kind === 243 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } } @@ -58797,7 +62038,7 @@ var ts; if (produceDiagnostics) { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304 /* Ambient */; + var inAmbientContext = node.flags & 8388608 /* Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -58836,7 +62077,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, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 244 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -58886,23 +62127,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* 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 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 241 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -58913,12 +62154,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -58939,17 +62180,36 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); + return node; + } + } + function getFirstNonModuleExportsIdentifier(node) { + switch (node.kind) { + case 75 /* Identifier */: + return node; + case 152 /* QualifiedName */: + do { + node = node.left; + } while (node.kind !== 75 /* Identifier */); + return node; + case 193 /* PropertyAccessExpression */: + do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } + node = node.expression; + } while (node.kind !== 75 /* Identifier */); return node; } } @@ -58963,9 +62223,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -58987,27 +62247,29 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - // For external modules symbol represent local symbol for an alias. + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864 /* Assignment */; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + // For external modules symbol represents local symbol for an alias. // This local symbol will merge any other local declarations (excluding other aliases) // and symbol.flags will contains combined representation for all merged declaration. // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). - var excludedMeanings = (symbol.flags & (67220415 /* Value */ | 1048576 /* ExportValue */) ? 67220415 /* Value */ : 0) | - (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | + symbol = getMergedSymbol(symbol.exportSymbol || symbol); + var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | + (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 261 /* 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 === 258 /* ExportSpecifier */ - && !(target.flags & 67220415 /* Value */) - && !(node.flags & 4194304 /* Ambient */)) { + && node.kind === 261 /* ExportSpecifier */ + && !(target.flags & 111551 /* Value */) + && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -59032,7 +62294,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59056,23 +62318,23 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 263 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415 /* Value */) { + if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832 /* Type */) { + if (target.flags & 788968 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608 /* Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -59092,10 +62354,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 /* ModuleBlock */ && + !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59112,7 +62374,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 288 /* SourceFile */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 248 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59126,13 +62388,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -59141,8 +62407,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 === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59155,8 +62421,18 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73 /* Identifier */) { - markExportAsReferenced(node); + if (node.expression.kind === 75 /* Identifier */) { + var id = node.expression; + var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + if (sym) { + markAliasReferenced(sym, id); + // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) + var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // However if it is a value, we need to check it's being used correctly + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); } @@ -59165,10 +62441,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -59194,9 +62470,9 @@ var ts; } } // Checks for export * conflicts - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -59225,14 +62501,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -59254,158 +62522,162 @@ 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 /* FirstStatement */ && kind <= 240 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 181 /* ParenthesizedType */: + case 175 /* OptionalType */: + case 176 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 182 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return checkImportType(node); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 306 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 298 /* JSDocTypeLiteral */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: + case 302 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 292 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 223 /* EmptyStatement */: + case 240 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -59500,23 +62772,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 264 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -59545,7 +62817,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } // Grammar checking @@ -59631,7 +62903,7 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608 /* InWithStatement */) { + if (location.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } @@ -59646,35 +62918,35 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // 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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -59716,17 +62988,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 /* Identifier */ && + return name.kind === 75 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 154 /* TypeParameter */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -59734,16 +63006,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 168 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 193 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 215 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -59771,13 +63043,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 152 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 252 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 258 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -59803,7 +63075,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 187 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -59813,7 +63085,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 193 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -59821,17 +63093,17 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 258 /* 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); + /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } 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, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 252 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -59849,11 +63121,11 @@ 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 === 212 /* ExpressionWithTypeArguments */) { - meaning = 67897832 /* Type */; + if (entityName.parent.kind === 215 /* ExpressionWithTypeArguments */) { + meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415 /* Value */; + meaning |= 111551 /* Value */; } } else { @@ -59865,10 +63137,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306 /* JSDocParameterTag */) { + if (entityName.parent.kind === 310 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 310 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 154 /* TypeParameter */ && entityName.parent.parent.kind === 314 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -59878,19 +63150,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 73 /* Identifier */) { + if (entityName.kind === 75 /* 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); + return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 193 /* PropertyAccessExpression */ || entityName.kind === 152 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 193 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -59900,22 +63172,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 168 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 167 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -59929,12 +63201,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 190 /* BindingElement */ && + grandParent.kind === 188 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -59944,11 +63216,11 @@ var ts; } } switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -59960,14 +63232,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 182 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkExpression(node).symbol; - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 161 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -59978,7 +63250,7 @@ var ts; // 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 === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 /* ImportDeclaration */ || node.parent.kind === 259 /* 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); @@ -59995,22 +63267,22 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81 /* DefaultKeyword */: - case 91 /* FunctionKeyword */: - case 37 /* EqualsGreaterThanToken */: - case 77 /* ClassKeyword */: + case 83 /* DefaultKeyword */: + case 93 /* FunctionKeyword */: + case 38 /* EqualsGreaterThanToken */: + case 79 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 280 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; } @@ -60018,10 +63290,10 @@ var ts; function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -60077,27 +63349,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 192 /* ObjectLiteralExpression */ || expr.kind === 191 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 231 /* 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 === 205 /* BinaryExpression */) { + if (expr.parent.kind === 208 /* 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 === 276 /* PropertyAssignment */) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60136,17 +63408,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } // Return the list of properties of the given type, augmented with properties from Function @@ -60198,7 +63469,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60219,13 +63490,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415 /* Value */); + return s && !!(s.flags & 111551 /* Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -60254,7 +63525,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 288 /* 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. @@ -60274,7 +63545,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -60282,7 +63553,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60291,7 +63562,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -60313,7 +63584,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 === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 222 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60354,26 +63625,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258 /* ExportAssignment */: + return node.expression && node.expression.kind === 75 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60387,7 +63657,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 67220415 /* Value */) && + return !!(target.flags & 111551 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -60401,7 +63671,7 @@ var ts; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && - target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -60455,7 +63725,7 @@ var ts; if (!symbol || !(symbol.flags & 16 /* Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 /* Value */ && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -60474,15 +63744,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 282 /* EnumMember */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 282 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -60509,9 +63779,9 @@ var ts; return ts.TypeReferenceSerializationKind.Unknown; } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 67220415 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 67897832 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -60567,7 +63837,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -60586,7 +63856,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -60594,7 +63864,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -60616,7 +63886,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -60637,7 +63907,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -60718,12 +63988,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 === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 163 /* SetAccessor */ ? 162 /* GetAccessor */ : 163 /* 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 === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -60736,10 +64006,19 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 215 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 277 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -60750,9 +64029,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* Type */ | 1920 /* Namespace */; + if ((node.kind === 75 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 193 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -60802,7 +64081,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -60830,12 +64109,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 /* 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, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 288 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -60968,16 +64247,16 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1 /* FirstEmitHelper */; helper <= 131072 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -61024,14 +64303,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 /* 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 === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* 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); @@ -61048,23 +64327,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 !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (modifier.kind !== 137 /* ReadonlyKeyword */) { + if (node.kind === 157 /* PropertySignature */ || node.kind === 159 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); + case 80 /* ConstKeyword */: + if (node.kind !== 247 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80 /* ConstKeyword */)); } break; - case 116 /* PublicKeyword */: - case 115 /* ProtectedKeyword */: - case 114 /* PrivateKeyword */: + case 118 /* PublicKeyword */: + case 117 /* ProtectedKeyword */: + case 116 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -61078,11 +64357,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* 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 === 114 /* PrivateKeyword */) { + if (modifier.kind === 116 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -61091,7 +64370,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -61101,10 +64380,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61113,18 +64392,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */ && node.kind !== 166 /* IndexSignature */ && node.kind !== 155 /* 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 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -61137,52 +64416,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 === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 83 /* DefaultKeyword */: + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* 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 126 /* DeclareKeyword */: + case 129 /* 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 === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 249 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 119 /* AbstractKeyword */: + case 121 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 244 /* ClassDeclaration */) { + if (node.kind !== 160 /* MethodDeclaration */ && + node.kind !== 158 /* PropertyDeclaration */ && + node.kind !== 162 /* GetAccessor */ && + node.kind !== 163 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 244 /* 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 */) { @@ -61194,14 +64473,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 122 /* AsyncKeyword */: + case 125 /* 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 */) { + else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61209,7 +64488,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61224,13 +64503,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 253 /* ImportDeclaration */ || node.kind === 252 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 /* 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 === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 155 /* 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 */) { @@ -61251,38 +64530,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 248 /* ModuleDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 155 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 125 /* AsyncKeyword */); + case 244 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AbstractKeyword */); + case 245 /* InterfaceDeclaration */: + case 224 /* VariableStatement */: + case 246 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); + case 247 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 80 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -61294,10 +64573,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61326,7 +64605,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -61360,7 +64639,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -61412,7 +64691,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 /* StringKeyword */ && parameter.type.kind !== 136 /* NumberKeyword */) { + if (parameter.type.kind !== 142 /* StringKeyword */ && parameter.type.kind !== 139 /* 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(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -61444,11 +64723,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211 /* OmittedExpression */) { + if (arg.kind === 214 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61478,7 +64763,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 === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -61491,7 +64776,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -61507,14 +64792,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -61525,21 +64810,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 153 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 208 /* 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 === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); - if (node.flags & 4194304 /* Ambient */) { + ts.Debug.assert(node.kind === 243 /* FunctionDeclaration */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 160 /* MethodDeclaration */); + if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -61554,17 +64839,10 @@ var ts; return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var Flags; - (function (Flags) { - Flags[Flags["Property"] = 1] = "Property"; - Flags[Flags["GetAccessor"] = 2] = "GetAccessor"; - Flags[Flags["SetAccessor"] = 4] = "SetAccessor"; - Flags[Flags["GetOrSetAccessor"] = 6] = "GetOrSetAccessor"; - })(Flags || (Flags = {})); var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 281 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -61575,20 +64853,21 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 /* 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); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 125 /* AsyncKeyword */ || prop.kind !== 160 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -61603,24 +64882,25 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 279 /* 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 157 /* MethodDeclaration */: - currentKind = 1 /* Property */; + currentKind = 4 /* PropertyAssignment */; + break; + case 160 /* MethodDeclaration */: + currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: - currentKind = 2 /* GetAccessor */; + case 162 /* GetAccessor */: + currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: - currentKind = 4 /* SetAccessor */; + case 163 /* SetAccessor */: + currentKind = 2 /* SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -61634,11 +64914,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + if ((currentKind & 12 /* PropertyAssignmentOrMethod */) && (existingKind & 12 /* PropertyAssignmentOrMethod */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6 /* GetOrSetAccessor */) && (existingKind & 6 /* GetOrSetAccessor */)) { - if (existingKind !== 6 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { + if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -61656,7 +64936,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 === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 273 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -61666,7 +64946,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 274 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -61680,14 +64960,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + if (forInOrOfStatement.kind === 231 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -61698,7 +64978,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 242 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -61713,20 +64993,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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); @@ -61736,42 +65016,38 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304 /* Ambient */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 8388608 /* Ambient */)) { + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { + if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 /* GetAccessor */ ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 162 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160 /* SetAccessor */) { + if (accessor.kind === 163 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; @@ -61781,23 +65057,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 === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143 /* UniqueKeyword */) { - if (node.type.kind !== 140 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140 /* SymbolKeyword */)); + if (node.operator === 146 /* UniqueKeyword */) { + if (node.type.kind !== 143 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* 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)) { @@ -61807,13 +65083,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 158 /* 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 154 /* PropertySignature */: + case 157 /* 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); } @@ -61822,9 +65098,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); + else if (node.operator === 137 /* ReadonlyKeyword */) { + if (node.type.kind !== 173 /* ArrayType */ && node.type.kind !== 174 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143 /* SymbolKeyword */)); } } } @@ -61837,10 +65113,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 160 /* MethodDeclaration */) { + if (node.parent.kind === 192 /* 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 === 122 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -61863,17 +65139,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* 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 === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 160 /* 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 === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* 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 === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* 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); } } @@ -61884,11 +65160,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 237 /* 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 === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 232 /* 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); @@ -61896,8 +65172,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 236 /* SwitchStatement */: + if (node.kind === 233 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -61912,13 +65188,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* 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 === 230 /* BreakStatement */ + var message = node.kind === 233 /* 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); @@ -61941,13 +65217,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -61960,7 +65236,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 /* TrueKeyword */ || initializer.kind === 88 /* FalseKeyword */ || + initializer.kind === 105 /* TrueKeyword */ || initializer.kind === 90 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -61977,8 +65253,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { - if (node.flags & 4194304 /* Ambient */) { + if (node.parent.parent.kind !== 230 /* ForInStatement */ && node.parent.parent.kind !== 231 /* ForOfStatement */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -61990,11 +65266,11 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -62007,7 +65283,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -62024,8 +65300,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73 /* Identifier */) { - if (name.originalKeywordKind === 112 /* LetKeyword */) { + if (name.kind === 75 /* Identifier */) { + if (name.originalKeywordKind === 114 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -62052,15 +65328,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62078,12 +65354,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96 /* NewKeyword */: + case 98 /* 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 93 /* ImportKeyword */: + case 95 /* 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"); } @@ -62141,7 +65417,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* 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; } @@ -62149,7 +65425,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* 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; } @@ -62157,11 +65433,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { + node.flags & 8388608 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } @@ -62178,13 +65454,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 246 /* TypeAliasDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 259 /* ExportDeclaration */ || + node.kind === 258 /* ExportAssignment */ || + node.kind === 251 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62193,7 +65469,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 === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 224 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62202,17 +65478,13 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304 /* Ambient */) { - // An accessors is already reported about the ambient context - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } + if (node.flags & 8388608 /* Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } // We are either parented by another statement, or some sort of block. @@ -62220,7 +65492,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 === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 222 /* Block */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62242,20 +65514,39 @@ 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, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 186 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 282 /* 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 === 39 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62310,11 +65601,19 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 243 /* FunctionDeclaration */ && declaration.kind !== 160 /* MethodDeclaration */) || + !!declaration.body; + } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62322,21 +65621,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 254 /* ImportClause */: // For default import + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: // For rename import `x as y` return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 257 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62346,7 +65644,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62417,6 +65714,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62464,7 +65762,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73 /* Identifier */); + var node = createSynthesizedNode(75 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -62545,23 +65843,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(99 /* SuperKeyword */); + return createSynthesizedNode(101 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101 /* ThisKeyword */); + return createSynthesizedNode(103 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97 /* NullKeyword */); + return createSynthesizedNode(99 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103 /* TrueKeyword */); + return createSynthesizedNode(105 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88 /* FalseKeyword */); + return createSynthesizedNode(90 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -62572,44 +65870,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(86 /* ExportKeyword */)); + result.push(createModifier(88 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(126 /* DeclareKeyword */)); + result.push(createModifier(129 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(81 /* DefaultKeyword */)); + result.push(createModifier(83 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(78 /* ConstKeyword */)); + result.push(createModifier(80 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(116 /* PublicKeyword */)); + result.push(createModifier(118 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(114 /* PrivateKeyword */)); + result.push(createModifier(116 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(115 /* ProtectedKeyword */)); + result.push(createModifier(117 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(119 /* AbstractKeyword */)); + result.push(createModifier(121 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(117 /* StaticKeyword */)); + result.push(createModifier(119 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(134 /* ReadonlyKeyword */)); + result.push(createModifier(137 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(122 /* AsyncKeyword */)); + result.push(createModifier(125 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(152 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -62628,7 +65926,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(153 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -62641,7 +65939,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(154 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -62657,7 +65955,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(155 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -62681,7 +65979,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(156 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -62694,7 +65992,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(157 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -62714,12 +66012,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(158 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -62729,8 +66027,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -62738,7 +66036,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(159 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -62755,7 +66053,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(160 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -62768,6 +66066,38 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), + /*typeArguments*/ undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + /* @internal */ + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + /* @internal */ + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -62783,7 +66113,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(161 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -62803,7 +66133,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(162 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62826,7 +66156,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(163 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62847,7 +66177,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -62855,7 +66185,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -62863,7 +66193,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(166 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -62903,21 +66233,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167 /* TypePredicate */); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(168 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -62931,7 +66271,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(169 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -62939,7 +66279,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(170 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -62947,7 +66287,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(171 /* TypeQuery */); node.exprName = exprName; return node; } @@ -62959,7 +66299,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(172 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -62971,7 +66311,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(173 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -62983,7 +66323,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(174 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -62995,7 +66335,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(175 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -63007,7 +66347,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(176 /* RestType */); node.type = type; return node; } @@ -63019,7 +66359,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(177 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63027,7 +66367,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(178 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63046,7 +66386,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(179 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63064,7 +66404,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(180 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63076,7 +66416,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(187 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63094,7 +66434,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(181 /* ParenthesizedType */); node.type = type; return node; } @@ -63106,12 +66446,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(182 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; + var node = createSynthesizedNode(183 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -63121,7 +66461,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(184 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63135,7 +66475,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(185 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63153,7 +66493,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(186 /* LiteralType */); node.literal = literal; return node; } @@ -63166,7 +66506,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(188 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63178,7 +66518,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(189 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63190,7 +66530,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(190 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63209,7 +66549,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(191 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63223,7 +66563,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(192 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63237,7 +66577,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63245,6 +66585,7 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessChain using updatePropertyAccess. Use updatePropertyAccessChain instead."); // Because we are updating existed propertyAccess we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -63253,22 +66594,62 @@ var ts; : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072 /* NoIndentation */); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(194 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessChain using updateElementAccess. Use updateElementAccessChain instead."); return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194 /* ElementAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(195 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63276,6 +66657,7 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update a CallChain using updateCall. Use updateCallChain instead."); return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -63283,8 +66665,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195 /* CallExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(196 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63300,7 +66702,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(197 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63323,7 +66725,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(198 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63337,7 +66739,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(199 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63349,7 +66751,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(200 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63373,12 +66775,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(201 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -63395,7 +66797,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(202 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63407,7 +66809,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(203 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63419,7 +66821,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(204 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63431,7 +66833,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(205 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63443,7 +66845,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(206 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63456,7 +66858,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(207 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63469,7 +66871,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(208 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63486,11 +66888,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(209 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(58 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -63506,7 +66908,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(210 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -63519,34 +66921,93 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15 /* TemplateHead */); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + } + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15 /* TemplateHead */: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16 /* TemplateMiddle */: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17 /* TemplateTail */: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23 /* CloseBracketToken */) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15 /* TemplateHead */, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16 /* TemplateMiddle */); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16 /* TemplateMiddle */, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17 /* TemplateTail */); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17 /* TemplateTail */, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14 /* NoSubstitutionTemplateLiteral */, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -63558,7 +67019,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(212 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -63570,7 +67031,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(213 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63591,11 +67052,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(214 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(215 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -63609,7 +67070,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(216 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -63623,7 +67084,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(217 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63635,7 +67096,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(218 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -63649,7 +67110,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(220 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -63663,12 +67124,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(221 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(222 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -63682,7 +67143,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(224 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -63697,11 +67158,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(223 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(225 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -63717,7 +67178,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(226 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -63733,7 +67194,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(227 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -63747,7 +67208,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(228 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63761,7 +67222,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(229 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -63779,7 +67240,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(230 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -63795,7 +67256,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(231 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -63813,7 +67274,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(232 /* ContinueStatement */); node.label = asName(label); return node; } @@ -63825,7 +67286,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(233 /* BreakStatement */); node.label = asName(label); return node; } @@ -63837,7 +67298,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(234 /* ReturnStatement */); node.expression = expression; return node; } @@ -63849,7 +67310,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(235 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63863,7 +67324,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(236 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -63877,7 +67338,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(237 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -63891,7 +67352,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(238 /* ThrowStatement */); node.expression = expression; return node; } @@ -63903,7 +67364,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(239 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -63919,11 +67380,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(240 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(241 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -63940,7 +67401,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(242 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -63953,7 +67414,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(243 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63979,7 +67440,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(244 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64001,7 +67462,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(245 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64023,7 +67484,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(246 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64043,7 +67504,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(247 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64062,8 +67523,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); + var node = createSynthesizedNode(248 /* ModuleDeclaration */); + node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -64081,7 +67542,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(249 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64093,7 +67554,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(250 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64105,7 +67566,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(251 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64117,7 +67578,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(252 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64135,7 +67596,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(253 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64153,7 +67614,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(254 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64167,7 +67628,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(255 /* NamespaceImport */); node.name = name; return node; } @@ -64179,7 +67640,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(256 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64191,7 +67652,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(257 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64205,11 +67666,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(258 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -64222,7 +67683,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(259 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64239,8 +67700,13 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + /* @internal */ + function createEmptyExports() { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(260 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64252,7 +67718,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(261 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64267,7 +67733,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(263 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64281,14 +67747,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(292 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(313 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64296,7 +67762,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(311 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64304,14 +67770,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(312 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(310 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64321,7 +67787,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297 /* JSDocComment */); + var node = createSynthesizedNode(301 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64335,7 +67801,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(264 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64351,7 +67817,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(265 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64367,7 +67833,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(266 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64383,7 +67849,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(267 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64395,7 +67861,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(268 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64417,11 +67883,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(269 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(270 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64433,7 +67899,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(271 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -64447,7 +67913,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(272 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -64459,7 +67925,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(273 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -64471,7 +67937,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(274 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -64485,7 +67951,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(275 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -64499,7 +67965,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(276 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -64511,7 +67977,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(277 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -64524,7 +67990,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(278 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -64539,7 +68005,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(279 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -64554,7 +68020,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(280 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -64568,7 +68034,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(281 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64581,7 +68047,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(282 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -64602,7 +68068,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(288 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -64686,7 +68152,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314 /* NotEmittedStatement */); + var node = createSynthesizedNode(318 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -64698,7 +68164,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(322 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64710,7 +68176,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(321 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64725,7 +68191,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(315 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(319 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -64741,7 +68207,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316 /* CommaListExpression */) { + if (node.kind === 320 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -64751,7 +68217,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316 /* CommaListExpression */); + var node = createSynthesizedNode(320 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -64762,9 +68228,25 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + /* @internal */ + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323 /* SyntheticReferenceExpression */); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + /* @internal */ + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(289 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -64795,7 +68277,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(290 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -64877,8 +68359,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal" /* Internal */: - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } // falls through case "text" /* Text */: (texts || (texts = [])).push(createUnparsedNode(section, node)); @@ -64927,10 +68412,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 283 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 284 /* UnparsedPrepend */; + case "internal" /* Internal */: return 286 /* UnparsedInternalText */; + case "text" /* Text */: return 285 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -64948,14 +68433,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(287 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(291 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -65001,8 +68486,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65045,43 +68530,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28 /* LessThanToken */, right); + return createBinary(left, 29 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60 /* EqualsToken */, right); + return createBinary(left, 62 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 36 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 37 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38 /* PlusToken */, right); + return createBinary(left, 39 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39 /* MinusToken */, right); + return createBinary(left, 40 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44 /* PlusPlusToken */); + return createPostfix(operand, 45 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54 /* AmpersandAmpersandToken */, right); + return createBinary(left, 55 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55 /* BarBarToken */, right); + return createBinary(left, 56 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60 /* QuestionQuestionToken */, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52 /* ExclamationToken */, operand); + return createPrefix(53 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -65101,7 +68590,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -65145,7 +68637,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 === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65210,7 +68702,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -65496,9 +68987,9 @@ var ts; ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -65599,29 +69090,34 @@ var ts; } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; // Helpers - function getHelperName(name) { + /** + * Gets an identifier for the name of an *unscoped* emit helper. + */ + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); @@ -65629,24 +69125,26 @@ var ts; ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; @@ -65668,7 +69166,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); @@ -65679,7 +69177,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -65691,20 +69189,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cacheIdentifiers; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -65719,7 +69217,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99 /* SuperKeyword */) { + else if (callee.kind === 101 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -65731,7 +69229,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 193 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65744,7 +69242,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65801,14 +69299,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66086,8 +69584,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -66115,9 +69613,9 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } @@ -66134,7 +69632,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 === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 199 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66168,10 +69666,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(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 /* ArrowFunction */ && binaryOperatorPrecedence > 3) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66183,7 +69681,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 211 /* YieldExpression */) { return false; } return true; @@ -66220,7 +69718,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 38 /* PlusToken */) { + if (binaryOperator === 39 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -66255,10 +69753,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 === 40 /* AsteriskToken */ - || binaryOperator === 50 /* BarToken */ - || binaryOperator === 49 /* AmpersandToken */ - || binaryOperator === 51 /* CaretToken */; + return binaryOperator === 41 /* AsteriskToken */ + || binaryOperator === 51 /* BarToken */ + || binaryOperator === 50 /* AmpersandToken */ + || binaryOperator === 52 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -66271,22 +69769,20 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(209 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -66321,8 +69817,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: needsParens = true; } } @@ -66338,9 +69834,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66363,7 +69859,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66401,7 +69897,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66412,29 +69908,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 200 /* FunctionExpression */ || kind === 201 /* 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 === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 192 /* ObjectLiteralExpression */ || leftmostExpressionKind === 200 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 179 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -66442,9 +69938,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 171 /* TypeQuery */: + case 183 /* TypeOperator */: + case 180 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -66470,28 +69966,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 315 /* PartiallyEmittedExpression */: + case 216 /* AsExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 217 /* NonNullExpression */: + case 319 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -66500,15 +69996,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 192 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 316 /* CommaListExpression */; + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 320 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -66521,13 +70017,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 217 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -66552,7 +70048,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 217 /* NonNullExpression */) { node = node.expression; } return node; @@ -66560,11 +70056,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 315 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -66582,7 +70078,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -66607,6 +70103,60 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + // use named imports + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + // Alias the imports if the names are used somewhere in the file. + // NOTE: We don't need to care about global import collisions as this is a module. + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + // use a namespace import + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -66621,8 +70171,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -66647,10 +70197,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 253 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 259 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -66769,7 +70319,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -66781,11 +70331,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -66817,12 +70367,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 155 /* Parameter */: + case 190 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 212 /* SpreadElement */: + case 281 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -66834,7 +70384,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 190 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -66846,7 +70396,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -66858,7 +70408,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -66881,13 +70431,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -66927,11 +70477,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67054,11 +70604,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -67092,278 +70640,287 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */) || kind === 182 /* ThisType */) { return node; } switch (kind) { // Names - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 155 /* 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 153 /* Decorator */: + case 156 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 157 /* 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 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 159 /* 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 157 /* MethodDeclaration */: + case 160 /* 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 158 /* Constructor */: + case 161 /* 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 159 /* GetAccessor */: + case 162 /* 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 160 /* SetAccessor */: + case 163 /* 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 161 /* CallSignature */: + case 164 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 166 /* 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 164 /* TypePredicate */: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 167 /* TypePredicate */: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 174 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 176 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 177 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 179 /* 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 177 /* InferType */: + case 180 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 187 /* 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 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 185 /* 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 183 /* LiteralType */: + case 186 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 190 /* 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 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 200 /* 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 198 /* ArrowFunction */: + case 201 /* 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 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 209 /* 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 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 213 /* 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 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 222 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 226 /* 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 224 /* DoStatement */: + case 227 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 229 /* 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 227 /* ForInStatement */: + case 230 /* 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 228 /* ForOfStatement */: + case 231 /* 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 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 243 /* 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 241 /* ClassDeclaration */: + case 244 /* 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 242 /* InterfaceDeclaration */: + case 245 /* 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 243 /* TypeAliasDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 247 /* 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 245 /* ModuleDeclaration */: + case 248 /* 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 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 252 /* 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 250 /* ImportDeclaration */: + case 253 /* 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 251 /* ImportClause */: + case 254 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 259 /* 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 257 /* NamedExports */: + case 260 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -67405,58 +70962,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 167 /* TypePredicate */ && kind <= 186 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 314 /* NotEmittedStatement */: + case 221 /* SemicolonClassElement */: + case 223 /* EmptyStatement */: + case 214 /* OmittedExpression */: + case 240 /* DebuggerStatement */: + case 318 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 155 /* 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 153 /* Decorator */: + case 156 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 157 /* 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 155 /* PropertyDeclaration */: + case 158 /* 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 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67465,12 +71022,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 161 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67478,7 +71035,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67486,50 +71043,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 196 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -67537,123 +71094,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 201 /* 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 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 213 /* 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 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 216 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 222 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 229 /* 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 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67662,7 +71219,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67670,140 +71227,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 247 /* 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 245 /* ModuleDeclaration */: + case 248 /* 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 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* 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 250 /* ImportDeclaration */: + case 253 /* 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 251 /* ImportClause */: + case 254 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 259 /* 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 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -67876,7 +71433,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 !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 215 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -67949,19 +71506,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ 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); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68164,12 +71722,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ 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 @@ -68181,6 +71738,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -68549,7 +72107,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -68591,25 +72149,31 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 252 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -68639,13 +72203,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -68653,7 +72217,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -68673,7 +72237,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -68695,12 +72259,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -68775,7 +72335,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -68805,42 +72365,28 @@ var ts; } ts.helperString = helperString; /** - * Gets all property declarations with initializers on either the static or instance side of a class. + * Gets all the static or all the instance property declarations of a class * * @param node The class node. * @param isStatic A value indicating whether to get properties from the static or instance side of the class. */ - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.getInitializedProperties = getInitializedProperties; + ts.getProperties = getProperties; /** - * Gets a value indicating whether a class element is a static property declaration with an initializer. - * - * @param member The class element node. - */ - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); - } - ts.isStaticInitializedProperty = isStaticInitializedProperty; - /** - * Gets a value indicating whether a class element is an instance property declaration with an initializer. - * - * @param member The class element node. - */ - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); - } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; - /** - * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. + * Is a class element either a static or an instance property declaration with an initializer? * * @param member The class element node. * @param isStatic A value indicating whether the member should be a static or instance member. */ - function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ - && member.initializer !== undefined; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; + } + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -69288,6 +72834,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -69312,7 +72859,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), + return ts.createCall(ts.getUnscopedHelperName("__rest"), /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) @@ -69365,8 +72912,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -69392,14 +72939,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* 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 === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -69450,16 +72997,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 249 /* ModuleBlock */: + case 222 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -69471,7 +73018,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 === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 244 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -69514,10 +73061,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -69538,13 +73085,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -69564,11 +73111,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 259 /* ExportDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 254 /* ImportClause */ || + (node.kind === 252 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 263 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -69592,19 +73139,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -69614,7 +73161,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 86 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 88 /* ExportKeyword */) { return undefined; } return node; @@ -69631,67 +73178,71 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 124 /* BooleanKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 133 /* NeverKeyword */: - case 107 /* VoidKeyword */: - case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 137 /* ReadonlyKeyword */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 172 /* TypeLiteral */: + case 167 /* TypePredicate */: + case 154 /* TypeParameter */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 127 /* BooleanKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 136 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 143 /* SymbolKeyword */: + case 170 /* ConstructorType */: + case 169 /* FunctionType */: + case 171 /* TypeQuery */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 181 /* ParenthesizedType */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 166 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 156 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 158 /* 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 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 245 /* 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 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69701,7 +73252,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69711,35 +73262,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -69749,35 +73300,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -69815,7 +73366,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -69844,7 +73395,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1 /* Export */))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); @@ -70081,7 +73632,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -70187,12 +73738,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70345,7 +73896,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 158 /* 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() @@ -70446,13 +73997,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(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -70468,10 +74019,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 158 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -70481,7 +74032,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -70492,12 +74043,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; } return false; @@ -70514,15 +74065,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -70559,7 +74110,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 162 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -70604,69 +74155,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: - case 124 /* BooleanKeyword */: + case 167 /* TypePredicate */: + case 127 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return ts.createIdentifier("String"); - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: - if (node.operator === 134 /* ReadonlyKeyword */) { + case 183 /* TypeOperator */: + if (node.operator === 137 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 171 /* TypeQuery */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 172 /* TypeLiteral */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 182 /* ThisType */: + case 187 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70677,15 +74228,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* 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); @@ -70765,12 +74316,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73 /* Identifier */) { + if (node.left.kind === 75 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -70786,7 +74337,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* 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); @@ -70794,7 +74345,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -70878,7 +74429,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 110 /* ImplementsKeyword */) { + if (node.token === 112 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -70928,7 +74479,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -71341,12 +74892,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 === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 288 /* 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 === 244 /* EnumDeclaration */) { + if (node.kind === 247 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -71471,7 +75022,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 249 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -71517,13 +75068,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 !== 246 /* ModuleBlock */) { + if (body.kind !== 249 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -71564,7 +75115,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 255 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -71777,7 +75328,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -71785,7 +75336,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(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -71795,17 +75346,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(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(75 /* Identifier */); + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(248 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 248 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 247 /* EnumDeclaration */; } /** * Hook for node emit. @@ -71864,11 +75415,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -71906,9 +75457,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 !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 288 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 248 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 247 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -71930,9 +75481,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } return substitute; @@ -71958,18 +75510,19 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), + return ts.createCall(ts.getUnscopedHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue @@ -71977,13 +75530,14 @@ var ts; } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression @@ -71991,6 +75545,7 @@ var ts; } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -72033,7 +75588,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -72044,11 +75601,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72060,20 +75617,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72083,7 +75640,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -72116,7 +75673,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var statements = [ ts.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -72132,9 +75689,9 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -72152,9 +75709,9 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { @@ -72166,7 +75723,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -72207,8 +75764,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -72221,7 +75778,7 @@ var ts; /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, /*isStatic*/ false); + var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false); // Only generate synthetic constructor when there are property initializers to move. if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); @@ -72253,7 +75810,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -72265,7 +75822,7 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -72282,7 +75839,7 @@ var ts; * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -72319,19 +75876,29 @@ var ts; */ function transformInitializedProperty(property, receiver) { // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72351,7 +75918,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -72435,6 +76002,7 @@ var ts; var hasSuperElementAccess; /** A set of node IDs for generated super accessors (variable statements). */ var substitutedSuperAccessors = []; + var topLevel; // Save the previous transformation hooks. var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; @@ -72446,38 +76014,57 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32 /* ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 243 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -72485,27 +76072,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 222 /* Block */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 235 /* WithStatement */: + case 237 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -72706,7 +76293,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 === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 201 /* 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 @@ -72729,7 +76316,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -72756,7 +76343,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -72797,17 +76384,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -72855,23 +76442,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -72883,19 +76470,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -72955,23 +76542,24 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; - return ts.createCall(ts.getHelperName("__awaiter"), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -73005,9 +76593,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; /** Keeps track of property names accessed on super (`super.x`) within async functions. */ var capturedSuperProperties; /** Whether the async function contains an element access on super (`super[x]`). */ @@ -73019,6 +76609,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -73030,68 +76622,85 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122 /* AsyncKeyword */) { + if (node.kind === 125 /* AsyncKeyword */) { return undefined; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 238 /* VariableDeclaration */: + case 224 /* VariableStatement */: + return visitVariableStatement(node); + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: - return visitConstructorDeclaration(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - return visitGetAccessorDeclaration(node); - case 160 /* SetAccessor */: - return visitSetAccessorDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + return doOutsideOfTopLevel(visitConstructorDeclaration, node); + case 160 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 162 /* GetAccessor */: + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 163 /* SetAccessor */: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 243 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -73124,7 +76733,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 231 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73136,7 +76745,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 === 278 /* SpreadAssignment */) { + if (e.kind === 281 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73145,7 +76754,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 279 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73179,7 +76788,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 192 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -73224,23 +76833,44 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a VariableDeclaration node with a binding pattern. * * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false); + } + function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. if (ts.isBindingPattern(node.name) && node.name.transformFlags & 8192 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */); + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -73455,10 +77085,10 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); @@ -73524,17 +77154,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -73582,23 +77212,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -73610,19 +77240,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73638,65 +77268,69 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), + return ts.createCall(ts.getUnscopedHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), /*typeArguments*/ undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__asyncGenerator"), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } })(ts || (ts = {})); @@ -73716,7 +77350,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -73735,6 +77369,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -73747,10 +77382,143 @@ var ts; return node; } switch (node.kind) { + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + var updated = visitOptionalExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208 /* BinaryExpression */: + if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a.b` -> { expression: `(_a = a).b`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a[b]` -> { expression: `(_a = a)[b]`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193 /* PropertyAccessExpression */: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194 /* ElementAccessExpression */: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193 /* PropertyAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194 /* ElementAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195 /* CallExpression */: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, + /*typeArguments*/ undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createNull()), ts.createToken(55 /* AmpersandAmpersandToken */), ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -73785,13 +77553,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73801,13 +77569,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -73882,7 +77650,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 274 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -73976,7 +77744,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 264 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74282,7 +78050,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74290,9 +78058,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74495,13 +78263,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 234 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 222 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -74514,72 +78282,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 73 /* Identifier */: + case 75 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -74590,28 +78358,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitSpreadElement(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -74702,14 +78470,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 === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 233 /* 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 === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -74720,7 +78488,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -74978,7 +78746,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -75116,11 +78884,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 234 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 226 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75128,7 +78896,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 222 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75283,10 +79051,10 @@ var ts; return false; } // `declarationName` is the name of the local declaration for the parameter. - var declarationName = parameter.name.kind === 73 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var declarationName = parameter.name.kind === 75 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 73 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; @@ -75310,7 +79078,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73 /* Identifier */) { + if (parameter.name.kind !== 75 /* Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); @@ -75326,7 +79094,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 201 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -75347,25 +79115,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 161 /* 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 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 */), 95 /* 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 */), 97 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -75394,20 +79162,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -75433,12 +79201,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), - /*location*/ member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. @@ -75595,7 +79373,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 === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 243 /* FunctionDeclaration */ || node.kind === 200 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -75639,7 +79417,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 201 /* 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 @@ -75707,9 +79485,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 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -75728,9 +79506,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 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -75765,7 +79543,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 60 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -75939,14 +79717,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76134,7 +79912,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 153 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76189,7 +79967,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -76255,11 +80033,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 229 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 231 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 227 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 228 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76284,11 +80062,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 242 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -76439,7 +80217,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -76501,7 +80279,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(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -76539,7 +80317,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -76550,7 +80328,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, 60 /* EqualsToken */, source); + return ts.createBinary(target, 62 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -76563,7 +80341,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -76577,7 +80355,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(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -76598,10 +80376,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -76687,20 +80465,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -76776,7 +80554,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a @@ -76807,7 +80585,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -76860,7 +80638,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 /* SuperKeyword */ || + if (expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -76984,10 +80762,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 4096 /* ContainsRestOrSpread */ || - node.expression.kind === 99 /* SuperKeyword */ || + node.expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -77005,7 +80783,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -77017,10 +80795,10 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -77044,7 +80822,7 @@ var ts; // [output] // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), /*typeArguments*/ undefined, []); } return ts.visitEachChild(node, visitor, context); @@ -77208,13 +80986,16 @@ var ts; // Find original source text, since we need to emit the raw strings of the tagged template. // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + 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 // and LineTerminatorSequences are normalized to for both TV and TRV. @@ -77305,13 +81086,11 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 98 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return ts.createFileLevelUniqueName("_newTarget"); } @@ -77343,7 +81122,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } /** @@ -77353,14 +81132,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableSubstitution(103 /* ThisKeyword */); + context.enableEmitNotification(161 /* Constructor */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(201 /* ArrowFunction */); + context.enableEmitNotification(200 /* FunctionExpression */); + context.enableEmitNotification(243 /* FunctionDeclaration */); } } /** @@ -77401,10 +81180,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 241 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -77417,9 +81196,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -77486,19 +81265,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -77508,7 +81287,7 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), + return ts.createCall(ts.getUnscopedHelperName("__extends"), /*typeArguments*/ undefined, [ name, ts.createFileLevelUniqueName("_super") @@ -77516,7 +81295,7 @@ var ts; } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw @@ -77524,12 +81303,14 @@ var ts; } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -77551,15 +81332,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(266 /* JsxOpeningElement */); + context.enableEmitNotification(267 /* JsxClosingElement */); + context.enableEmitNotification(265 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(279 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -77578,9 +81359,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -77637,7 +81418,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */) { + if (token !== undefined && token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -77912,13 +81693,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -77931,24 +81712,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -77969,21 +81750,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -77996,9 +81777,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78197,23 +81978,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 /* FirstCompoundAssignment */ - && kind <= 72 /* LastCompoundAssignment */; + return kind >= 63 /* FirstCompoundAssignment */ + && kind <= 74 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61 /* PlusEqualsToken */: return 38 /* PlusToken */; - case 62 /* MinusEqualsToken */: return 39 /* MinusToken */; - case 63 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; - case 64 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; - case 65 /* SlashEqualsToken */: return 42 /* SlashToken */; - case 66 /* PercentEqualsToken */: return 43 /* PercentToken */; - case 67 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; - case 68 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; - case 70 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; - case 71 /* BarEqualsToken */: return 50 /* BarToken */; - case 72 /* CaretEqualsToken */: return 51 /* CaretToken */; + case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; + case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; + case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; + case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; + case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; + case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; + case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; + case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; + case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; + case 73 /* BarEqualsToken */: return 51 /* BarToken */; + case 74 /* CaretEqualsToken */: return 52 /* CaretToken */; } } /** @@ -78226,7 +82007,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78238,7 +82019,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -78325,7 +82106,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 === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -78464,13 +82245,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -78479,7 +82260,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -78614,35 +82395,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79072,7 +82853,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 276 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79085,7 +82866,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79258,11 +83039,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -79397,7 +83177,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -80223,7 +84003,7 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), + return ts.createCall(ts.getUnscopedHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } // The __generator helper is used by down-level transformations to emulate the runtime @@ -80287,6 +84067,7 @@ var ts; // For examples of how these are used, see the comments in ./transformers/generators.ts ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -80313,12 +84094,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(288 /* 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. @@ -80416,14 +84197,14 @@ var ts; // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), // Add the module body function argument: // // function (require, exports, module1, module2) ... @@ -80433,10 +84214,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ]))) ]), @@ -80471,11 +84252,11 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) @@ -80503,10 +84284,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), @@ -80646,23 +84427,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 317 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -80689,24 +84470,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -80821,7 +84602,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -80835,7 +84616,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; if (languageVersion >= 2 /* ES2015 */) { @@ -80869,11 +84650,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; } @@ -81184,7 +84965,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81239,10 +85020,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -81424,8 +85205,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -81441,7 +85222,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -81503,12 +85284,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -81529,7 +85310,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -81597,15 +85378,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 === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* 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 === 204 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 207 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -81645,7 +85426,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]); } // emit helper for dynamic import @@ -81657,12 +85438,14 @@ var ts; // emit helper for `import * as Name from "foo"` ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -81679,16 +85462,18 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(218 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. + var contextObjectMap = []; // The context object associated with a source file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -81727,7 +85512,7 @@ var ts; // existing identifiers. exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -81905,7 +85690,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 259 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -81930,7 +85715,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 259 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -81999,28 +85784,28 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; + var group_2 = dependencyGroups_1[_i]; // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82070,15 +85855,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82254,7 +86039,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 === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 288 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -82318,7 +86103,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 === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -82380,10 +86165,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82563,43 +86348,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node); - case 317 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -82846,7 +86631,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 288 /* SourceFile */; } else { return false; @@ -82862,8 +86647,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -82879,12 +86664,13 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -82892,6 +86678,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -82927,7 +86714,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -82961,13 +86748,15 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); + case 218 /* MetaProperty */: + return substituteMetaProperty(node); } return node; } @@ -83052,22 +86841,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 === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* 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 === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 207 /* 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 === 204 /* PostfixUnaryExpression */) { - expression = node.operator === 44 /* PlusPlusToken */ + if (node.kind === 207 /* PostfixUnaryExpression */) { + expression = node.operator === 45 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -83076,6 +86865,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } /** * Gets the exports of a name. * @@ -83088,7 +86883,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83127,24 +86922,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); - context.enableSubstitution(73 /* Identifier */); - var currentSourceFile; + context.enableEmitNotification(288 /* SourceFile */); + context.enableSubstitution(75 /* Identifier */); + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864 /* NeverApplyImportHelper */); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -83156,10 +86947,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83180,9 +86971,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -83199,19 +86990,18 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -83267,7 +87057,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83296,7 +87086,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83322,7 +87112,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -83343,7 +87133,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 === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* 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 : @@ -83352,8 +87142,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 === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 158 /* PropertyDeclaration */ || node.kind === 193 /* PropertyAccessExpression */ || node.kind === 157 /* PropertySignature */ || + (node.kind === 155 /* 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 ? @@ -83362,7 +87152,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 === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 244 /* ClassDeclaration */ || node.kind === 155 /* 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 : @@ -83387,7 +87177,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* 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 */)) { @@ -83426,26 +87216,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* 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 161 /* CallSignature */: + case 164 /* 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 163 /* IndexSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83453,7 +87243,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83467,7 +87257,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 243 /* 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 : @@ -83492,30 +87282,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 161 /* 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 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 165 /* ConstructSignature */: + case 170 /* 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 161 /* CallSignature */: + case 164 /* 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 163 /* IndexSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83523,7 +87313,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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* 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 : @@ -83536,13 +87326,20 @@ 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 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 243 /* FunctionDeclaration */: + case 169 /* 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 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -83551,39 +87348,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 185 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* 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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* 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 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 169 /* FunctionType */: + case 243 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -83598,9 +87395,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 244 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 /* 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; } @@ -83635,11 +87432,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; // No declaration diagnostics for js for now - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -83649,7 +87443,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 155 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -83710,9 +87504,9 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -83795,20 +87589,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -83821,18 +87624,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { 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(126 /* 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 statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : 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 === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -83869,12 +87672,19 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -83916,6 +87726,15 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { + var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, host.getSourceFiles(), + /*preferences*/ undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration + // via a non-relative name, emit a type reference directive to that non-relative name, rather than + // a relative path to the declaration file + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { @@ -83952,11 +87771,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 189 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -83964,20 +87783,20 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 214 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { oldDiag = getSymbolAccessibilityDiagnostic; 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(56 /* 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(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -84002,19 +87821,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 155 /* 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(121 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* 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(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -84022,12 +87841,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 155 /* Parameter */ + || node.kind === 158 /* PropertyDeclaration */ + || node.kind === 157 /* 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)); @@ -84038,26 +87857,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(124 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return false; } return false; @@ -84084,6 +87903,33 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, /*modifierMask*/ undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -84111,7 +87957,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 /* ModuleDeclaration */ && parent.kind !== 187 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84131,7 +87977,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 263 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84158,7 +88004,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 === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 255 /* 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; @@ -84207,11 +88053,11 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -84221,13 +88067,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -84250,6 +88089,11 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + // Setup diagnostic-related flags before first potential `cleanup` call, otherwise + // We'd see a TDZ violation at runtime + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 /* TypeLiteral */ || input.kind === 185 /* MappedType */) && input.parent.kind !== 246 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -84258,76 +88102,77 @@ var ts; return cleanup(ts.createProperty(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* 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 212 /* ExpressionWithTypeArguments */: { + case 215 /* 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 165 /* TypeReference */: { + case 168 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 161 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(161 /* 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 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(159 /* 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 159 /* GetAccessor */: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 162 /* GetAccessor */: { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); } - case 160 /* SetAccessor */: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 163 /* SetAccessor */: { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); } - case 155 /* PropertyDeclaration */: + case 158 /* 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 154 /* PropertySignature */: + case 157 /* 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 156 /* MethodSignature */: { + case 159 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 164 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 166 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -84335,13 +88180,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 151 /* TypeParameter */: { + case 154 /* 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 176 /* ConditionalType */: { + case 179 /* 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); @@ -84353,13 +88198,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 169 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 170 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 187 /* 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)); @@ -84369,13 +88214,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -84388,7 +88233,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 160 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -84398,7 +88243,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 259 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -84407,13 +88252,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 258 /* 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 === 73 /* Identifier */) { + if (input.expression.kind === 75 /* Identifier */) { return input; } else { @@ -84423,7 +88268,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(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -84448,10 +88293,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -84472,14 +88317,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 246 /* 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), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 245 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 243 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -84494,7 +88339,7 @@ var ts; fakespace_1.symbol = props[0].parent; var declarations = ts.mapDefined(props, function (p) { if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { - return undefined; + return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker); @@ -84527,17 +88372,17 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 248 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 249 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304 /* Ambient */) { + if (input.flags & 8388608 /* Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -84546,7 +88391,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -84573,7 +88418,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 244 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -84584,7 +88429,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73 /* Identifier */) { + if (param.name.kind === 75 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -84614,7 +88459,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 !== 97 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); @@ -84624,16 +88469,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(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87 /* ExtendsKeyword */) { + if (clause.token === 89 /* 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 === 97 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -84644,10 +88489,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 247 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -84666,7 +88511,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 248 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -84687,7 +88532,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 214 /* OmittedExpression */) { return; } if (e.name) { @@ -84737,55 +88582,36 @@ var ts; function ensureModifierFlags(node) { 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 === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 288 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask, additions); } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); } - var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3 /* MultiLineCommentTrivia */) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; + return accessorType; } 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 === 87 /* ExtendsKeyword */ && t.expression.kind === 97 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 /* ExtendsKeyword */ && t.expression.kind === 99 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { return true; } return false; @@ -84810,7 +88636,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 162 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -84819,52 +88645,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 224 /* VariableStatement */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 165 /* ConstructSignature */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 241 /* VariableDeclaration */: + case 154 /* TypeParameter */: + case 215 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 179 /* ConditionalType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 187 /* ImportType */: return true; } return false; @@ -84993,7 +88819,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(319 /* Count */); + var enabledSyntaxKindFeatures = new Array(324 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -85200,7 +89026,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement( @@ -85278,15 +89104,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -85296,22 +89122,21 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - /*@internal*/ - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -85334,7 +89159,7 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; @@ -85342,14 +89167,14 @@ var ts; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 289 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -85359,9 +89184,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -85402,11 +89225,13 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : @@ -85417,43 +89242,73 @@ var ts; outputFileName : undefined; } + function createAddOutput() { + var outputs; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } /*@internal*/ function getAllProjectOutputs(configFile, ignoreCase) { - var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) - continue; - if (configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; /*@internal*/ function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { @@ -85467,8 +89322,13 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + continue; + if (ts.getEmitDeclarations(configFile.options)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); @@ -85476,7 +89336,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -85490,7 +89350,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -85586,17 +89446,16 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !declarationFilePath) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; // Setup and perform the transformation to retrieve declarations from the input files - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -85628,7 +89487,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -85636,12 +89495,8 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { - // Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule. - // But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow. - // Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the - // tslint directive can be all be removed. - var sourceFile = declarationTransform.transformed[0]; // tslint:disable-line + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288 /* SourceFile */) { + var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } @@ -85651,7 +89506,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -85663,8 +89518,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -85705,7 +89560,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 288 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -85812,10 +89667,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(288 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -85827,7 +89683,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(225 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -85866,7 +89722,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -85920,6 +89776,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers)); @@ -85972,6 +89829,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -86000,9 +89859,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 288 /* SourceFile */: return printFile(node); + case 289 /* Bundle */: return printBundle(node); + case 290 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86171,8 +90030,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -86184,7 +90042,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86200,6 +90058,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { @@ -86209,21 +90069,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(4 /* Unspecified */, node); + var substitute = pipelineEmit(4 /* Unspecified */, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(2 /* IdentifierName */, node); + return pipelineEmit(2 /* IdentifierName */, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1 /* Expression */, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(1 /* Expression */, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -86238,12 +90109,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 288 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -86257,10 +90128,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -86280,279 +90154,279 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 290 /* UnparsedSource */: + case 284 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 283 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 287 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 156 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 293 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 294 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + case 299 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 222 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 223 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 267 /* JsxClosingElement */: + case 270 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 304 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 299 /* JSDocSignature */: + case 303 /* JSDocSignature */: return emitJSDocSignature(node); - case 298 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 303 /* JSDocClassTag */: - case 300 /* JSDocTag */: + case 307 /* JSDocClassTag */: + case 304 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 297 /* JSDocComment */: + case 301 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -86570,83 +90444,83 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Reserved words - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 103 /* TrueKeyword */: - case 101 /* ThisKeyword */: - case 93 /* ImportKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 105 /* TrueKeyword */: + case 103 /* ThisKeyword */: + case 95 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return emitCommaList(node); } } @@ -86659,8 +90533,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -86674,8 +90551,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -86686,7 +90563,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 289 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -86695,12 +90572,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -86786,7 +90663,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -86819,7 +90696,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -86855,7 +90732,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 298 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -86917,7 +90794,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 162 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -86958,11 +90835,17 @@ var ts; // Types // function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -87094,18 +90977,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); - pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* QuestionToken */) { writePunctuation("?"); } } @@ -87185,66 +91067,57 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, - /*stopAfterLineBreak*/ false, - /*stopAtComments*/ true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { - var dotToken = ts.createToken(24 /* DotToken */); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(96 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(98 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -87284,22 +91157,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(84 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(107 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(126 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -87324,9 +91197,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* 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 */))); + return operand.kind === 206 /* PrefixUnaryExpression */ + && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) + || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -87339,7 +91212,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); @@ -87367,7 +91240,7 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(118 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(120 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -87444,7 +91317,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87452,8 +91325,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + emitTokenWithComment(86 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -87463,14 +91336,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(85 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -87479,14 +91352,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -87498,25 +91371,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -87524,7 +91397,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { emit(node); } else { @@ -87533,12 +91406,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(76 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -87566,12 +91439,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(100 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87579,7 +91452,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87589,17 +91462,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -87608,13 +91481,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(82 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -87639,7 +91512,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -87811,7 +91684,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512 /* GlobalAugmentation */) { + if (~node.flags & 1024 /* GlobalAugmentation */) { writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); writeSpace(); } @@ -87819,7 +91692,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 248 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -87840,17 +91713,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -87859,12 +91732,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -87879,9 +91752,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -87892,42 +91765,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(81 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(83 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -87947,7 +91820,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -88025,7 +91898,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88036,13 +91909,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(75 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(77 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -88054,12 +91927,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -88070,7 +91943,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -88140,7 +92013,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88174,7 +92047,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88193,7 +92066,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -88327,8 +92200,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_20 = types; _d < types_20.length; _d++) { + var directive = types_20[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -88508,7 +92381,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -88546,8 +92419,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmbeddedStatement */, node); } else { emit(node); @@ -88954,6 +92826,9 @@ var ts; return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -88971,7 +92846,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89036,81 +92911,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 237 /* LabeledStatement */: + case 235 /* WithStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89119,12 +92994,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -89182,7 +93057,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { return false; } } @@ -89304,25 +93179,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 258 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -89365,11 +93240,12 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 318 /* 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 */; @@ -89393,7 +93269,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -89423,6 +93299,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -89636,6 +93513,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -89650,7 +93528,7 @@ var ts; 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 !== 314 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -89663,12 +93541,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -90031,6 +93910,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -90386,7 +94268,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -90575,8 +94457,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -90589,6 +94471,8 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + /* @internal */ + ts.inferredTypesContainingFile = "__inferred type names__.ts"; /** * Determines if program structure is upto date or needs to be recreated */ @@ -90663,7 +94547,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -90693,15 +94577,17 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -90737,7 +94623,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).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; @@ -90754,7 +94640,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 @@ -90783,8 +94669,13 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks + // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -90792,20 +94683,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } } } @@ -90818,7 +94725,7 @@ var ts; 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(); - var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -90854,8 +94761,8 @@ var ts; // not part of the new program. if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || // old file wasnt redirect but new file is @@ -90871,12 +94778,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -90913,7 +94821,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -90940,9 +94850,14 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + // source file is allowed to be emitted and its not source of project reference redirect + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -91146,6 +95061,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; @@ -91236,7 +95157,7 @@ var ts; // moduleAugmentations has changed oldProgram.structureIsReused = 1 /* SafeModules */; } - if ((oldSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) { // dynamicImport has changed oldProgram.structureIsReused = 1 /* SafeModules */; } @@ -91273,28 +95194,26 @@ var ts; 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 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) { - oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + 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) { + oldProgram.structureIsReused = 1 /* SafeModules */; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } 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, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutions_1 = 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) { + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -91308,11 +95227,19 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping 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 (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined); + } + } // Set the file as found during node modules search if it was found that way in old progra, if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); @@ -91330,9 +95257,10 @@ var ts; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -91341,7 +95269,7 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -91397,15 +95325,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -91413,7 +95341,7 @@ var ts; // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); } @@ -91437,7 +95365,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -91512,15 +95441,16 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || - sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || + sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -91579,22 +95509,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 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 241 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -91602,41 +95532,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 110 /* ImplementsKeyword */) { + if (heritageClause.token === 112 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -91649,51 +95579,52 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* 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 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 224 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 158 /* 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 !== 117 /* StaticKeyword */) { + if (modifier.kind !== 119 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152 /* Parameter */: + case 155 /* 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 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 197 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -91710,24 +95641,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 126 /* DeclareKeyword */: - case 119 /* AbstractKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 129 /* DeclareKeyword */: + case 121 /* 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 117 /* StaticKeyword */: - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 119 /* StaticKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: } } } @@ -91802,8 +95733,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 /* Identifier */ - ? b.kind === 73 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 75 /* Identifier */ + ? b.kind === 75 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -91833,7 +95764,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -91884,7 +95815,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -91965,24 +95896,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -92005,15 +95930,26 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); + var file_2 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected - if (file_1 && options.forceConsistentCasingInFileNames) { + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -92022,34 +95958,35 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } // See if we need to reprocess the imports due to prior skipped imports - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -92067,14 +96004,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92105,7 +96035,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92128,8 +96058,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92144,8 +96084,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts or any of the non ts files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + // Ignore dts + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -92184,6 +96124,35 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + // Dont know which source file it means so return true? + var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); @@ -92218,9 +96187,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -92236,10 +96213,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -92251,7 +96234,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -92261,8 +96244,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -92270,14 +96252,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -92295,20 +96277,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -92348,14 +96330,22 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152 /* JSDoc */)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -92374,12 +96364,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -92436,9 +96429,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -92473,17 +96463,18 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -92599,8 +96590,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -92665,8 +96656,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -92693,7 +96717,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -92768,7 +96792,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -92827,6 +96851,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; /* @internal */ @@ -92872,9 +96902,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } /* @internal */ /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. @@ -92924,9 +96951,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93172,11 +97199,19 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, + /*emitOnlyDtsFiles*/ true, cancellationToken, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); + var firstDts_1 = emitOutput_1.outputFiles && + programOfThisState.getCompilerOptions().declarationMap ? + emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : + emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + if (firstDts_1) { + ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + latestSignature = computeHash(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -93279,6 +97314,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; /** * For script files that contains only ambient external modules, although they are not actually external module files, * they can only be consumed via importing elements from them. Regular script files cannot consume them. Therefore, @@ -93382,6 +97418,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -93395,8 +97436,7 @@ var ts; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them - // With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -93419,7 +97459,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -93465,7 +97506,7 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -93474,7 +97515,7 @@ var ts; function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -93493,7 +97534,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } /** * Releases program and other related not needed properties @@ -93519,7 +97560,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -93551,7 +97593,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } // Remove the changed file from the change set @@ -93597,13 +97638,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -93622,7 +97668,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -93647,7 +97693,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -93665,14 +97711,39 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } /** * Iterate on referencing modules that export entities from affected file */ function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { + return; + } + if (!isChangedSignagure(state, affectedFile.path)) return; + // Since isolated modules dont change js files, files affected by change in signature is itself + // But we need to cleanup semantic diagnostics and queue dts emit for affected files + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); @@ -93741,7 +97812,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -93751,6 +97822,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -93762,8 +97836,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + /** + * Returns the result with affected file + */ + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -93793,7 +97874,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -93888,7 +97969,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -93986,22 +98067,24 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94014,10 +98097,10 @@ var ts; affected = program; } } - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94073,7 +98156,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94105,7 +98188,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94117,8 +98200,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94154,7 +98243,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true }; return { @@ -94280,15 +98369,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -94453,8 +98554,8 @@ var ts; !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]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && @@ -94534,7 +98635,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -94745,6 +98846,10 @@ var ts; // Mark the file as needing re-evaluation of module resolution instead of using it blindly. resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + // When its a file with inferred types resolution, invalidate type reference directive resolution + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -94930,8 +99035,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -94947,20 +99053,26 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // Returns an import for each symlink and for the realpath. + /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) { var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); if (ambient) return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -94976,7 +99088,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0 /* Relative */) { return relativePath; @@ -95012,38 +99124,12 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. - // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** * Looks for existing imports that use symlinks to this module. @@ -95051,10 +99137,12 @@ var ts; */ function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -95071,7 +99159,31 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + // Sort by paths closest to importing file Name directory + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -95102,16 +99214,18 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -95120,24 +99234,27 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } // Simplify the full file path to something that can be resolved by Node. // If the module could be imported by a directory name, use that directory's name - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) @@ -95332,6 +99449,15 @@ var ts; ? newLine + newLine : newLine; } + /** + * Get locale specific time based on whether we are in test mode + */ + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -95339,7 +99465,7 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -95348,7 +99474,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -95541,7 +99667,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -95555,7 +99681,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -95589,7 +99717,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -95638,7 +99766,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -95731,7 +99859,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -95759,10 +99887,22 @@ 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, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -95988,13 +100128,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -96178,12 +100324,22 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -96339,11 +100495,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -96352,8 +100511,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -96373,12 +100531,35 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + // Clear all to ResolvedConfigFilePaths cache to start fresh + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + // Config file cache + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + // Remove watches for the program no longer in the solution + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -96386,6 +100567,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -96402,7 +100584,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -96457,7 +100639,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -96629,7 +100811,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -96797,6 +100979,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -96853,8 +101037,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97025,10 +101212,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97087,7 +101276,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -97252,16 +101441,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -97404,8 +101599,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -97437,6 +101632,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -97447,7 +101643,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -97455,7 +101651,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -97473,23 +101669,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -97522,13 +101728,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -97574,6 +101783,15 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ + var PackageJsonDependencyGroup; + (function (PackageJsonDependencyGroup) { + PackageJsonDependencyGroup[PackageJsonDependencyGroup["Dependencies"] = 1] = "Dependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["DevDependencies"] = 2] = "DevDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["PeerDependencies"] = 4] = "PeerDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["OptionalDependencies"] = 8] = "OptionalDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["All"] = 15] = "All"; + })(PackageJsonDependencyGroup = ts.PackageJsonDependencyGroup || (ts.PackageJsonDependencyGroup = {})); + /* @internal */ ts.emptyOptions = {}; var HighlightSpanKind; (function (HighlightSpanKind) { @@ -97588,6 +101806,12 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = ts.SemicolonPreference || (ts.SemicolonPreference = {})); function getDefaultFormatCodeSettings(newLineCharacter) { return { indentSize: 4, @@ -97609,6 +101833,7 @@ var ts; insertSpaceBeforeFunctionParenthesis: false, placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, + semicolons: SemicolonPreference.Ignore, }; } ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; @@ -97838,37 +102063,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 278 /* CatchClause */: + case 271 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 154 /* TypeParameter */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 172 /* TypeLiteral */: return 2 /* Type */; - case 311 /* JSDocTypedefTag */: + case 315 /* 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 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 282 /* EnumMember */: + case 244 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -97878,26 +102103,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 247 /* EnumDeclaration */: + case 256 /* NamedImports */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 258 /* ExportAssignment */ || node.parent.kind === 263 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -97929,11 +102154,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 152 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 252 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -97945,27 +102170,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 152 /* QualifiedName */) { + while (root.parent && root.parent.kind === 152 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 168 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 193 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 193 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 215 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 277 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 244 /* ClassDeclaration */ && root.parent.parent.token === 112 /* ImplementsKeyword */) || + (decl.kind === 245 /* InterfaceDeclaration */ && root.parent.parent.token === 89 /* ExtendsKeyword */); } return false; } @@ -97974,17 +102199,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return true; - case 184 /* ImportType */: + case 187 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -98011,7 +102236,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 237 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -98027,11 +102252,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 73 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 73 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -98043,40 +102268,40 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 248 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 73 /* Identifier */ && + return node.kind === 75 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 282 /* EnumMember */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 248 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 186 /* LiteralType */: + return node.parent.parent.kind === 184 /* IndexedAccessType */; default: return false; } @@ -98100,17 +102325,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return node; } } @@ -98118,48 +102343,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 245 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 246 /* TypeAliasDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 247 /* EnumDeclaration */: return "enum" /* enumElement */; + case 241 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 162 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 163 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 279 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 166 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 165 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 164 /* CallSignature */: return "call" /* callSignatureElement */; + case 161 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 154 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 282 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 155 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -98186,7 +102416,7 @@ var ts; return "" /* unknown */; } } - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -98202,12 +102432,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 155 /* Parameter */; default: return false; } @@ -98272,42 +102502,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 172 /* TypeLiteral */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 250 /* CaseBlock */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 196 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 195 /* CallExpression */: + case 199 /* ParenthesizedExpression */: + case 181 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 201 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -98317,65 +102547,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 191 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 194 /* ElementAccessExpression */: + case 153 /* ComputedPropertyName */: + case 174 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 110 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 203 /* TypeOfExpression */: + case 202 /* DeleteExpression */: + case 204 /* VoidExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -98507,7 +102737,7 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - return ts.firstDefined(n.getChildren(), function (child) { + return ts.firstDefined(n.getChildren(sourceFile), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -98554,7 +102784,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 288 /* 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. @@ -98620,21 +102850,21 @@ var ts; return true; } //
Hello |
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 267 /* JsxClosingElement */) { return true; } return false; @@ -98656,7 +102886,7 @@ var ts; 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)) { + if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -98683,6 +102913,12 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; + function removeOptionality(type, isOptionalExpression, isOptionalChain) { + return isOptionalExpression ? type.getNonNullableType() : + isOptionalChain ? type.getNonOptionalType() : + type; + } + ts.removeOptionality = removeOptionality; function isPossiblyTypeArgumentPosition(token, sourceFile, checker) { var info = getPossibleTypeArgumentsInfo(token, sourceFile); return info !== undefined && (ts.isPartOfTypeNode(info.called) || @@ -98692,6 +102928,9 @@ var ts; ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; function getPossibleGenericSignatures(called, typeArgumentCount, checker) { var type = checker.getTypeAtLocation(called); + if (ts.isOptionalChain(called.parent)) { + type = removeOptionality(type, !!called.parent.questionDotToken, /*isOptionalChain*/ true); + } var signatures = ts.isNewExpression(called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); return signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= typeArgumentCount; }); } @@ -98708,9 +102947,12 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); + if (token && token.kind === 28 /* QuestionDotToken */) { + token = findPrecedingToken(token.getFullStart(), sourceFile); + } if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { @@ -98718,13 +102960,13 @@ var ts; } remainingLessThanTokens--; break; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: remainingLessThanTokens++; break; case 19 /* CloseBraceToken */: @@ -98752,20 +102994,22 @@ var ts; case 27 /* CommaToken */: nTypeArguments++; break; - case 37 /* EqualsGreaterThanToken */: - case 73 /* Identifier */: + case 38 /* EqualsGreaterThanToken */: + // falls through + case 75 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 105 /* TypeOfKeyword */: - case 87 /* ExtendsKeyword */: - case 130 /* KeyOfKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + // falls through + case 107 /* TypeOfKeyword */: + case 89 /* ExtendsKeyword */: + case 133 /* KeyOfKeyword */: case 24 /* DotToken */: - case 50 /* BarToken */: - case 56 /* QuestionToken */: - case 57 /* ColonToken */: + case 51 /* BarToken */: + case 57 /* QuestionToken */: + case 58 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -98814,16 +103058,16 @@ var ts; result.push("abstract" /* abstractModifier */); if (flags & 1 /* Export */) result.push("export" /* exportedModifier */); - if (node.flags & 4194304 /* Ambient */) + if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 168 /* TypeReference */ || node.kind === 195 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 244 /* ClassDeclaration */ || node.kind === 245 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -98843,7 +103087,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 72 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 74 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -98853,9 +103097,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: return true; } return false; @@ -98868,18 +103112,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 191 /* ArrayLiteralExpression */ || + node.kind === 192 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 208 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 60 /* EqualsToken */) { + node.parent.operatorToken.kind === 62 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 231 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -98887,7 +103131,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 279 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -98931,23 +103175,23 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 121 /* AnyKeyword */, - 147 /* BigIntKeyword */, - 124 /* BooleanKeyword */, - 88 /* FalseKeyword */, - 130 /* KeyOfKeyword */, - 133 /* NeverKeyword */, - 97 /* NullKeyword */, - 136 /* NumberKeyword */, - 137 /* ObjectKeyword */, - 134 /* ReadonlyKeyword */, - 139 /* StringKeyword */, - 140 /* SymbolKeyword */, - 103 /* TrueKeyword */, - 107 /* VoidKeyword */, - 142 /* UndefinedKeyword */, - 143 /* UniqueKeyword */, - 144 /* UnknownKeyword */, + 124 /* AnyKeyword */, + 150 /* BigIntKeyword */, + 127 /* BooleanKeyword */, + 90 /* FalseKeyword */, + 133 /* KeyOfKeyword */, + 136 /* NeverKeyword */, + 99 /* NullKeyword */, + 139 /* NumberKeyword */, + 140 /* ObjectKeyword */, + 137 /* ReadonlyKeyword */, + 142 /* StringKeyword */, + 143 /* SymbolKeyword */, + 105 /* TrueKeyword */, + 109 /* VoidKeyword */, + 145 /* UndefinedKeyword */, + 146 /* UniqueKeyword */, + 147 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -98983,7 +103227,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 153 /* 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); @@ -99059,7 +103303,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 73 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 75 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -99148,7 +103392,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 155 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -99189,6 +103433,8 @@ var ts; getColumn: function () { return 0; }, getLine: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingWhitespace: function () { return false; }, + hasTrailingComment: function () { return false; }, rawWrite: ts.notImplemented, getIndent: function () { return indent; }, increaseIndent: function () { indent++; }, @@ -99610,15 +103856,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 208 /* 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 272 /* CaseClause */: + case 275 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -99646,10 +103892,10 @@ var ts; ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: return true; default: return false; @@ -99660,8 +103906,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: return true; default: return false; @@ -99682,7 +103928,6 @@ var ts; 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, @@ -99700,28 +103945,90 @@ var ts; return typeIsAccessible ? res : undefined; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; - function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; - } - ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; + function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { + return kind === 164 /* CallSignature */ + || kind === 165 /* ConstructSignature */ + || kind === 166 /* IndexSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */; + } + ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; + function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { + return kind === 243 /* FunctionDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; + } + ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; + function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { + return kind === 248 /* ModuleDeclaration */; + } + ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; + function syntaxRequiresTrailingSemicolonOrASI(kind) { + return kind === 224 /* VariableStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 227 /* DoStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 233 /* BreakStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 158 /* PropertyDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 258 /* ExportAssignment */; + } + ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; + ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); + function isASICandidate(node, sourceFile) { + var lastToken = node.getLastToken(sourceFile); + if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + return false; + } + if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { + if (lastToken && lastToken.kind === 27 /* CommaToken */) { + return false; + } + } + else if (syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isModuleBlock(lastChild)) { + return false; + } + } + else if (syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isFunctionBlock(lastChild)) { + return false; + } + } + else if (!syntaxRequiresTrailingSemicolonOrASI(node.kind)) { + return false; + } + // See comment in parser’s `parseDoStatement` + if (node.kind === 227 /* DoStatement */) { + return true; + } + var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); + var nextToken = ts.findNextToken(node, topNode, sourceFile); + if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + return true; + } + var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(nextToken.getStart(sourceFile)).line; + return startLine !== endLine; + } + ts.isASICandidate = isASICandidate; function probablyUsesSemicolons(sourceFile) { var withSemicolon = 0; var withoutSemicolon = 0; var nStatementsToObserve = 5; ts.forEachChild(sourceFile, function visit(node) { - if (syntaxUsuallyHasTrailingSemicolon(node.kind)) { + if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { withSemicolon++; @@ -99744,9 +104051,154 @@ var ts; return withSemicolon / withoutSemicolon > 1 / nStatementsToObserve; } ts.probablyUsesSemicolons = probablyUsesSemicolons; + function tryGetDirectories(host, directoryName) { + return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || []; + } + ts.tryGetDirectories = tryGetDirectories; + function tryReadDirectory(host, path, extensions, exclude, include) { + return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include) || ts.emptyArray; + } + ts.tryReadDirectory = tryReadDirectory; + function tryFileExists(host, path) { + return tryIOAndConsumeErrors(host, host.fileExists, path); + } + ts.tryFileExists = tryFileExists; + function tryDirectoryExists(host, path) { + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; + } + ts.tryDirectoryExists = tryDirectoryExists; + function tryAndIgnoreErrors(cb) { + try { + return cb(); + } + catch (_a) { + return undefined; + } + } + ts.tryAndIgnoreErrors = tryAndIgnoreErrors; + 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); }); + } + ts.tryIOAndConsumeErrors = tryIOAndConsumeErrors; + function findPackageJsons(startDirectory, host, stopDirectory) { + var paths = []; + ts.forEachAncestorDirectory(startDirectory, function (ancestor) { + if (ancestor === stopDirectory) { + return true; + } + var currentConfigPath = ts.combinePaths(ancestor, "package.json"); + if (tryFileExists(host, currentConfigPath)) { + paths.push(currentConfigPath); + } + }); + return paths; + } + ts.findPackageJsons = findPackageJsons; + function findPackageJson(directory, host) { + var packageJson; + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (ancestor === "node_modules") + return true; + packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); + if (packageJson) { + return true; // break out + } + }); + return packageJson; + } + ts.findPackageJson = findPackageJson; + function getPackageJsonsVisibleToFile(fileName, host) { + if (!host.fileExists) { + return []; + } + var packageJsons = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(fileName), function (ancestor) { + var packageJsonFileName = ts.combinePaths(ancestor, "package.json"); + if (host.fileExists(packageJsonFileName)) { + var info = createPackageJsonInfo(packageJsonFileName, host); + if (info) { + packageJsons.push(info); + } + } + }); + return packageJsons; + } + ts.getPackageJsonsVisibleToFile = getPackageJsonsVisibleToFile; + function createPackageJsonInfo(fileName, host) { + if (!host.readFile) { + return undefined; + } + var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]; + var stringContent = host.readFile(fileName); + var content = stringContent && tryParseJson(stringContent); + if (!content) { + return undefined; + } + var info = {}; + for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) { + var key = dependencyKeys_1[_i]; + var dependencies = content[key]; + if (!dependencies) { + continue; + } + var dependencyMap = ts.createMap(); + for (var packageName in dependencies) { + dependencyMap.set(packageName, dependencies[packageName]); + } + info[key] = dependencyMap; + } + var dependencyGroups = [ + [1 /* Dependencies */, info.dependencies], + [2 /* DevDependencies */, info.devDependencies], + [8 /* OptionalDependencies */, info.optionalDependencies], + [4 /* PeerDependencies */, info.peerDependencies], + ]; + return __assign(__assign({}, info), { fileName: fileName, + get: get, + has: function (dependencyName, inGroups) { + return !!get(dependencyName, inGroups); + } }); + function get(dependencyName, inGroups) { + if (inGroups === void 0) { inGroups = 15 /* All */; } + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; + if (deps && (inGroups & group_1)) { + var dep = deps.get(dependencyName); + if (dep !== undefined) { + return dep; + } + } + } + } + } + ts.createPackageJsonInfo = createPackageJsonInfo; + function tryParseJson(text) { + try { + return JSON.parse(text); + } + catch (_a) { + return undefined; + } + } + function consumesNodeCoreModules(sourceFile) { + return ts.some(sourceFile.imports, function (_a) { + var text = _a.text; + return ts.JsTyping.nodeCoreModules.has(text); + }); + } + ts.consumesNodeCoreModules = consumesNodeCoreModules; + function isInsideNodeModules(fileOrDirectory) { + return ts.contains(ts.getPathComponents(fileOrDirectory), "node_modules"); + } + ts.isInsideNodeModules = isInsideNodeModules; })(ts || (ts = {})); var ts; (function (ts) { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { @@ -99824,36 +104276,36 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; - case 28 /* LessThanToken */: - if (lastNonTriviaToken === 73 /* Identifier */) { + case 29 /* LessThanToken */: + if (lastNonTriviaToken === 75 /* 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 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 121 /* AnyKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: + case 124 /* AnyKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* 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 = 73 /* Identifier */; + token = 75 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -99892,14 +104344,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 73 /* Identifier */; + token = 75 /* 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 = 73 /* Identifier */; + token = 75 /* Identifier */; } } } @@ -99913,19 +104365,19 @@ 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([ - 73 /* Identifier */, + 75 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 101 /* ThisKeyword */, - 44 /* PlusPlusToken */, - 45 /* MinusMinusToken */, + 103 /* ThisKeyword */, + 45 /* PlusPlusToken */, + 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 103 /* TrueKeyword */, - 88 /* FalseKeyword */, + 105 /* TrueKeyword */, + 90 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -100037,10 +104489,10 @@ var ts; return true; } switch (keyword2) { - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 125 /* ConstructorKeyword */: - case 117 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 128 /* ConstructorKeyword */: + case 119 /* 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. @@ -100073,43 +104525,44 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - 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 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* 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 71 /* BarEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 60 /* EqualsToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 50 /* AmpersandToken */: + case 52 /* CaretToken */: + case 51 /* BarToken */: + case 55 /* AmpersandAmpersandToken */: + case 56 /* BarBarToken */: + case 73 /* BarEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: + case 60 /* QuestionQuestionToken */: return true; default: return false; @@ -100117,12 +104570,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: return true; default: return false; @@ -100135,7 +104588,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 72 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 74 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -100154,7 +104607,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 73 /* Identifier */: + case 75 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -100179,10 +104632,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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -100375,6 +104828,11 @@ var ts; return; } } + else if (kind === 2 /* SingleLineCommentTrivia */) { + if (tryClassifyTripleSlashComment(start, width)) { + return; + } + } // Simple comment. Just add as is. pushCommentRange(start, width); } @@ -100395,18 +104853,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 306 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 307 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -100435,6 +104893,70 @@ var ts; } } } + function tryClassifyTripleSlashComment(start, width) { + var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; + var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + var text = sourceFile.text.substr(start, width); + var match = tripleSlashXMLCommentRegEx.exec(text); + if (!match) { + return false; + } + // Limiting classification to exactly the elements and attributes + // defined in `ts.commentPragmas` would be excessive, but we can avoid + // some obvious false positives (e.g. in XML-like doc comments) by + // checking the element name. + // eslint-disable-next-line no-in-operator + if (!match[3] || !(match[3] in ts.commentPragmas)) { + return false; + } + var pos = start; + pushCommentRange(pos, match[1].length); // /// + pos += match[1].length; + pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pos += match[2].length; + pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pos += match[3].length; + var attrText = match[4]; + var attrPos = pos; + while (true) { + var attrMatch = attributeRegex.exec(attrText); + if (!attrMatch) { + break; + } + var newAttrPos = pos + attrMatch.index; + if (newAttrPos > attrPos) { + pushCommentRange(attrPos, newAttrPos - attrPos); + attrPos = newAttrPos; + } + pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[1].length; + if (attrMatch[2].length) { + pushCommentRange(attrPos, attrMatch[2].length); // whitespace + attrPos += attrMatch[2].length; + } + pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = + attrPos += attrMatch[3].length; + if (attrMatch[4].length) { + pushCommentRange(attrPos, attrMatch[4].length); // whitespace + attrPos += attrMatch[4].length; + } + pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[5].length; + } + pos += match[4].length; + if (pos > attrPos) { + pushCommentRange(attrPos, pos - attrPos); + } + if (match[5]) { + pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pos += match[5].length; + } + var end = start + width; + if (pos < end) { + pushCommentRange(pos, end - pos); + } + return true; + } function processJSDocTemplateTag(tag) { for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; @@ -100493,22 +105015,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -100525,7 +105047,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* GreaterThanToken */) { + if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* 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)) { @@ -100535,19 +105057,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 60 /* EqualsToken */) { + if (tokenKind === 62 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 241 /* VariableDeclaration */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 155 /* Parameter */ || + parent.kind === 271 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 208 /* BinaryExpression */ || + parent.kind === 206 /* PrefixUnaryExpression */ || + parent.kind === 207 /* PostfixUnaryExpression */ || + parent.kind === 209 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -100561,7 +105083,7 @@ var ts; } else if (tokenKind === 10 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 271 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -100574,35 +105096,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 73 /* Identifier */) { + else if (tokenKind === 75 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 155 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -100725,11 +105247,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -100737,9 +105259,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 187 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 177 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -100749,7 +105271,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -100766,7 +105288,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -100779,8 +105301,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* 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 @@ -100789,9 +105311,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 263 /* 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*/"); @@ -100835,11 +105357,8 @@ var ts; 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; + 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 }; @@ -100896,7 +105415,7 @@ var ts; return ts.containsPath(rootDirectory, scriptDirectory, basePath, ignoreCase) ? scriptDirectory.substr(rootDirectory.length) : undefined; }); // TODO: GH#18217 // 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); }).concat([scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); + return ts.deduplicate(__spreadArrays(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), [scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); @@ -100929,10 +105448,10 @@ 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)) + if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { /** * Multiple file entries might map to the same truncated name once we remove extensions @@ -100955,7 +105474,7 @@ var ts; }); } // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); + var directories = ts.tryGetDirectories(host, baseDirectory); if (directories) { for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var directory = directories_1[_b]; @@ -100966,7 +105485,7 @@ var ts; } } // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); + var packageJsonPath = ts.findPackageJson(baseDirectory, host); if (packageJsonPath) { var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; @@ -101044,7 +105563,7 @@ var ts; if (!foundGlobal) { ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); - if (tryDirectoryExists(host, nodeModules)) { + if (ts.tryDirectoryExists(host, nodeModules)) { getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); @@ -101094,16 +105613,16 @@ 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 = ts.mapDefined(tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); }); - var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var directories = ts.mapDefined(ts.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); + return __spreadArrays(matches, directories); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); @@ -101151,22 +105670,22 @@ var ts; if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + var typeRoots = ts.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); } // Also get all @types typings installed in visible node_modules directories - for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + for (var _a = 0, _b = ts.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) { - if (!tryDirectoryExists(host, directory)) + if (!ts.tryDirectoryExists(host, directory)) return; - for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.tryGetDirectories(host, directory); _i < _a.length; _i++) { var typeDirectoryName = _a[_i]; var packageName = ts.unmangleScopedPackageName(typeDirectoryName); if (options.types && !ts.contains(options.types, packageName)) @@ -101187,34 +105706,11 @@ var ts; } } } - function findPackageJsons(directory, host) { - var paths = []; - ts.forEachAncestorDirectory(directory, function (ancestor) { - var currentConfigPath = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (!currentConfigPath) { - return true; // break out - } - paths.push(currentConfigPath); - }); - return paths; - } - function findPackageJson(directory, host) { - var packageJson; - ts.forEachAncestorDirectory(directory, function (ancestor) { - if (ancestor === "node_modules") - return true; - packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (packageJson) { - return true; // break out - } - }); - return packageJson; - } function enumerateNodeModulesVisibleToScript(host, scriptPath) { if (!host.readFile || !host.fileExists) return ts.emptyArray; var result = []; - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.findPackageJsons(scriptPath, host); _i < _a.length; _i++) { var packageJson = _a[_i]; var contents = ts.readJson(packageJson, host); // Cast to assert that readFile is defined // Provide completions for all non @types dependencies @@ -101263,33 +105759,6 @@ var ts; */ var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*" 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, 30 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -101462,14 +105990,25 @@ var ts; function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { var insertText; var replacementSpan; - if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; + var insertQuestionDot = origin && originIsNullableMember(origin); + var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; + if (origin && originIsThisType(origin)) { + insertText = needsConvertPropertyAccess + ? "this" + (insertQuestionDot ? "?." : "") + "[" + ts.quote(name, preferences) + "]" + : "this" + (insertQuestionDot ? "?." : ".") + 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 ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); + else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { + insertText = useBraces ? needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]" : name; + if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { + insertText = "?." + insertText; + } + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + if (!dot) { + return undefined; + } // 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); @@ -101482,6 +106021,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -101576,9 +106122,9 @@ var ts; } return entries; } - function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { + function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host) { var compilerOptions = program.getCompilerOptions(); - var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { return { type: "none" }; } @@ -101618,7 +106164,7 @@ var ts; 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); + var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); switch (symbolCompletion.type) { case "request": { var request = symbolCompletion.request; @@ -101674,8 +106220,8 @@ var ts; var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } - function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { - var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host) { + var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); return completion.type === "symbol" ? completion.symbol : undefined; } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; @@ -101708,34 +106254,34 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return checker.getContextualType(parent); - case 75 /* CaseKeyword */: + case 77 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 264 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.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); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -101745,9 +106291,9 @@ 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 === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 288 /* SourceFile */; }); } - function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 @@ -101796,11 +106342,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 312 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 316 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -101836,6 +106382,7 @@ var ts; var node = currentToken; var propertyAccessToConvert; var isRightOfDot = false; + var isRightOfQuestionDot = false; var isRightOfOpenTag = false; var isStartingCloseTag = false; var isJsxInitializer = false; @@ -101847,10 +106394,11 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */) { - isRightOfDot = true; + if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -101862,14 +106410,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 187 /* ImportType */: + case 218 /* MetaProperty */: node = parent; break; default: @@ -101882,56 +106430,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 === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 193 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + case 31 /* GreaterThanToken */: + if (currentToken.parent.kind === 264 /* JsxElement */ || currentToken.parent.kind === 266 /* JsxOpeningElement */) { location = currentToken; } break; - case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + case 43 /* SlashToken */: + if (currentToken.parent.kind === 265 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: - if (contextToken.kind === 42 /* SlashToken */) { + case 267 /* JsxClosingElement */: + if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: - if (contextToken.kind === 28 /* LessThanToken */) { + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: + case 266 /* JsxOpeningElement */: + if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: switch (previousToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: isJsxInitializer = true; break; - case 73 /* Identifier */: + case 75 /* 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, 60 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 62 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -101946,7 +106494,8 @@ var ts; var symbols = []; var symbolToOriginInfoMap = []; var symbolToSortTextMap = []; - if (isRightOfDot) { + var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { @@ -101996,11 +106545,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 311 /* JSDocTypedefTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 315 /* JSDocTypedefTag */: return true; default: return false; @@ -102044,24 +106593,40 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 288 /* SourceFile */ && d.kind !== 248 /* ModuleDeclaration */ && d.kind !== 247 /* EnumDeclaration */; })) { + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + insertQuestionDot = isRightOfDot && !isRightOfQuestionDot; + type = type.getNonNullableType(); + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 96 /* NewKeyword */ || node.keywordToken === 93 /* ImportKeyword */)) { - var completion = (node.keywordToken === 96 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 98 /* NewKeyword */ || node.keywordToken === 95 /* ImportKeyword */)) { + var completion = (node.keywordToken === 98 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + var type = typeChecker.getTypeAtLocation(node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + insertQuestionDot = isRightOfDot && !isRightOfQuestionDot; + type = type.getNonNullableType(); + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait, insertQuestionDot) { isNewIdentifierLocation = !!type.getStringIndexType(); + if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { + isNewIdentifierLocation = true; + } + var propertyAccess = node.kind === 187 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -102073,13 +106638,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { - addPropertySymbol(symbol); + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { + addPropertySymbol(symbol, /*insertAwait*/ false, insertQuestionDot); + } + } + } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true, insertQuestionDot); + } } } } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait, insertQuestionDot) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -102093,15 +106669,32 @@ var ts; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) + ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } + : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addSymbolOriginInfo(symbol); symbols.push(symbol); } + function addSymbolOriginInfo(symbol) { + if (preferences.includeCompletionsWithInsertText) { + if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + } + else if (insertQuestionDot) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + } + } + } + function getNullableSymbolOriginInfoKind(kind) { + return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -102134,6 +106727,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -102177,7 +106771,7 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); var isTypeOnly = isTypeOnlyCompletion(); - var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; @@ -102187,19 +106781,38 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 288 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ }; + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; } } } if (shouldOfferImportCompletions()) { - getSymbolsFromOtherSourceFileExports(symbols, previousToken && ts.isIdentifier(previousToken) ? previousToken.text : "", program.getCompilerOptions().target); + var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); + if (!detailsEntryId && importSuggestionsCache) { + importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); + } + autoImportSuggestions.forEach(function (_a) { + var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; + if (detailsEntryId) { + if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { + return; + } + } + else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { + return; + } + var symbolId = ts.getSymbolId(symbol); + symbols.push(symbol); + symbolToOriginInfoMap[symbolId] = origin; + symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; + }); } filterGlobalCompletion(symbols); } @@ -102221,10 +106834,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 210 /* TemplateExpression */: + case 274 /* JsxExpression */: + case 222 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -102254,7 +106867,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 67220415 /* Value */); + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); }); } function isTypeAssertion() { @@ -102269,28 +106882,28 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 107 /* TypeOfKeyword */ && + (contextToken.parent.kind === 171 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + case 58 /* ColonToken */: + return parentKind === 158 /* PropertyDeclaration */ || + parentKind === 157 /* PropertySignature */ || + parentKind === 155 /* Parameter */ || + parentKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; - case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; - case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; - case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + case 62 /* EqualsToken */: + return parentKind === 246 /* TypeAliasDeclaration */; + case 122 /* AsKeyword */: + return parentKind === 216 /* AsExpression */; + case 29 /* LessThanToken */: + return parentKind === 168 /* TypeReference */ || + parentKind === 198 /* TypeAssertionExpression */; + case 89 /* ExtendsKeyword */: + return parentKind === 154 /* TypeParameter */; } } return false; @@ -102299,15 +106912,76 @@ var ts; function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { if (seenModules === void 0) { seenModules = ts.createMap(); } var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 67897832 /* Type */) || + return !!(sym.flags & 788968 /* 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(); + /** + * Gathers symbols that can be imported from other files, deduplicating along the way. Symbols can be “duplicates” + * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but + * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, + * if and only if the the first can be imported (it may be excluded due to package.json filtering in + * `codefix.forEachExternalModuleToImportFrom`). + * + * Example. Imagine a chain of node_modules re-exporting one original symbol: + * + * ```js + * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js + * +-----------------------+ +--------------------------+ +--------------------------+ + * | | | | | | + * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | + * | | | | | | + * +-----------------------+ +--------------------------+ +--------------------------+ + * ``` + * + * Also imagine three buckets, which we’ll reference soon: + * + * ```md + * | | | | | | + * | **Bucket A** | | **Bucket B** | | **Bucket C** | + * | Symbols to | | Aliases to symbols | | Symbols to return | + * | definitely | | in Buckets A or C | | if nothing better | + * | return | | (don’t return these) | | comes along | + * |__________________| |______________________| |___________________| + * ``` + * + * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it + * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not + * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we + * may not be sure whether or not it should go in the list. So, we’ll take the following steps: + * + * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is + * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B + * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. + * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. + * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' + * should never be returned in the final list, so put it in Bucket B. + * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so + * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. + * Put this symbol in Bucket A. + * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t + * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move + * everything from Bucket C to Bucket A. + */ + function getSymbolsFromOtherSourceFileExports(target, host) { + var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); + if (cached) { + log("getSymbolsFromOtherSourceFileExports: Using cached list"); + return cached; + } + var startTime = ts.timestamp(); + log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); var seenResolvedModules = ts.createMap(); - ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + /** Bucket B */ + var aliasesToAlreadyIncludedSymbols = ts.createMap(); + /** Bucket C */ + var aliasesToReturnIfOriginalsAreMissing = ts.createMap(); + /** Bucket A */ + var results = []; + /** Ids present in `results` for faster lookup */ + var resultSymbolIds = ts.createMap(); + ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, function (moduleSymbol) { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; @@ -102317,41 +106991,75 @@ var ts; if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { return; } + // Don't add another completion for `export =` of a symbol that's already global. + // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. if (resolvedModuleSymbol !== moduleSymbol && - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { - symbols.push(resolvedModuleSymbol); - symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { + pushSymbol(resolvedModuleSymbol, moduleSymbol, /*skipFilter*/ true); } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; - // Don't add a completion for a re-export, only for the original. - // 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 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) { - // 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); - })) { + // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. + if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { continue; } - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + var symbolId = ts.getSymbolId(symbol).toString(); + // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. + var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; + // 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). + if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { + // Walk the export chain back one module (step 1 or 2 in diagrammed example). + // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. + var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); + if (!nearestExportSymbol) + continue; + var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); + var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); + if (!symbolHasBeenSeen) { + aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol }); + aliasesToAlreadyIncludedSymbols.set(symbolId, true); + } + else { + // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here + // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. + ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); + } } - var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; - if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) { - symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin; + else { + // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.delete(symbolId); + pushSymbol(symbol, moduleSymbol); } } }); + // By this point, any potential duplicates that were actually duplicates have been + // removed, so the rest need to be added. (Step 4 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { + var alias = _a.alias, moduleSymbol = _a.moduleSymbol; + return pushSymbol(alias, moduleSymbol); + }); + log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); + return results; + function pushSymbol(symbol, moduleSymbol, skipFilter) { + if (skipFilter === void 0) { skipFilter = false; } + var isDefaultExport = symbol.escapedName === "default" /* Default */; + if (isDefaultExport) { + symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + } + ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); + var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; + results.push({ + symbol: symbol, + symbolName: getSymbolName(symbol, origin, target), + origin: origin, + skipFilter: skipFilter, + }); + } + } + function getNearestExportSymbol(fromSymbol) { + return findAlias(typeChecker, fromSymbol, function (alias) { + return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); + }); } /** * True if you could remove some characters in `a` to get `b`. @@ -102398,12 +107106,12 @@ var ts; if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 266 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 267 /* JsxClosingElement */ || contextToken.parent.kind === 265 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 264 /* JsxElement */; } } return false; @@ -102414,40 +107122,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 195 /* CallExpression */ // func( a, | + || containingNodeKind === 161 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 196 /* NewExpression */ // new C(a, | + || containingNodeKind === 191 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 208 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 169 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 195 /* CallExpression */ // func( | + || containingNodeKind === 161 /* Constructor */ // constructor( | + || containingNodeKind === 196 /* NewExpression */ // new C(a| + || containingNodeKind === 199 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 181 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 131 /* ModuleKeyword */: // module | - case 132 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 191 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 166 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 153 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 134 /* ModuleKeyword */: // module | + case 135 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 248 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | - case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 244 /* ClassDeclaration */; // class A{ | + case 62 /* EqualsToken */: + return containingNodeKind === 241 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 208 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 210 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 220 /* TemplateSpan */; // `aa ${10} dd ${| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -102474,7 +107182,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 192 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; @@ -102483,7 +107191,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 188 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -102494,12 +107202,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 === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 231 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 155 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 160 /* MethodDeclaration */ || rootDeclaration.parent.kind === 163 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -102516,6 +107224,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -102541,7 +107250,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 256 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -102564,15 +107273,15 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 41 /* 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)) return 1 /* Success */; - var classElement = contextToken.parent; + var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : 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 === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 75 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -102607,9 +107316,9 @@ var ts; return parent; } break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 73 /* Identifier */: + case 75 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -102659,23 +107368,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 30 /* GreaterThanToken */: // End of a type argument list - case 29 /* LessThanSlashToken */: - case 42 /* SlashToken */: - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { - if (contextToken.kind === 30 /* GreaterThanToken */) { + case 31 /* GreaterThanToken */: // End of a type argument list + case 30 /* LessThanSlashToken */: + case 43 /* SlashToken */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 272 /* JsxAttributes */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 265 /* JsxSelfClosingElement */ || parent.kind === 266 /* JsxOpeningElement */)) { + if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) break; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -102687,7 +107396,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 271 /* JsxAttribute */) || (parent.kind === 273 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -102697,8 +107406,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 274 /* JsxExpression */ && + parent.parent && parent.parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -102706,7 +107415,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 273 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -102726,64 +107435,64 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 241 /* VariableDeclaration */ || + containingNodeKind === 242 /* VariableDeclarationList */ || + containingNodeKind === 224 /* VariableStatement */ || + containingNodeKind === 247 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| - case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [.| + case 58 /* ColonToken */: + return containingNodeKind === 190 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 278 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | - case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 247 /* EnumDeclaration */; // enum a { | + case 29 /* LessThanToken */: + return containingNodeKind === 244 /* ClassDeclaration */ || // class A< | + containingNodeKind === 213 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 245 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 246 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 119 /* StaticKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + return containingNodeKind === 155 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 189 /* ArrayBindingPattern */); // var [...z| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 155 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 122 /* AsKeyword */: + return containingNodeKind === 257 /* ImportSpecifier */ || + containingNodeKind === 261 /* ExportSpecifier */ || + containingNodeKind === 255 /* NamespaceImport */; + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 111 /* InterfaceKeyword */: - case 91 /* FunctionKeyword */: - case 106 /* VarKeyword */: - case 93 /* ImportKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 118 /* YieldKeyword */: - case 141 /* TypeKeyword */: // type htm| + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 113 /* InterfaceKeyword */: + case 93 /* FunctionKeyword */: + case 108 /* VarKeyword */: + case 95 /* ImportKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 120 /* YieldKeyword */: + case 144 /* TypeKeyword */: // type htm| return true; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -102804,22 +107513,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 119 /* AbstractKeyword */: - case 77 /* ClassKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 91 /* FunctionKeyword */: - case 111 /* InterfaceKeyword */: - case 112 /* LetKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 117 /* StaticKeyword */: - case 106 /* VarKeyword */: - case 118 /* YieldKeyword */: + case 121 /* AbstractKeyword */: + case 79 /* ClassKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 93 /* FunctionKeyword */: + case 113 /* InterfaceKeyword */: + case 114 /* LetKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 119 /* StaticKeyword */: + case 108 /* VarKeyword */: + case 120 /* YieldKeyword */: return true; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -102829,7 +107538,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 161 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -102848,16 +107557,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); 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 !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 279 /* PropertyAssignment */ && + m.kind !== 280 /* ShorthandPropertyAssignment */ && + m.kind !== 190 /* BindingElement */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */ && + m.kind !== 281 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -102865,9 +107576,12 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 73 /* Identifier */) { + if (m.propertyName.kind === 75 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -102880,7 +107594,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -102892,10 +107639,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 !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 158 /* PropertyDeclaration */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -102929,17 +107676,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 271 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -102950,7 +107703,7 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.startsWithQuote(name) + || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; @@ -102979,7 +107732,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 76 /* FirstKeyword */; i <= 151 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -103005,9 +107758,9 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 126 /* DeclareKeyword */ - || kind === 131 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 142 /* UndefinedKeyword */; + || kind === 129 /* DeclareKeyword */ + || kind === 134 /* ModuleKeyword */ + || ts.isTypeKeyword(kind) && kind !== 145 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -103017,7 +107770,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 78 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 80 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -103027,55 +107780,55 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 121 /* AnyKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 146 /* GlobalKeyword */: - case 110 /* ImplementsKeyword */: - case 128 /* InferKeyword */: - case 111 /* InterfaceKeyword */: - case 129 /* IsKeyword */: - case 130 /* KeyOfKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 133 /* NeverKeyword */: - case 136 /* NumberKeyword */: - case 137 /* ObjectKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: - case 139 /* StringKeyword */: - case 140 /* SymbolKeyword */: - case 141 /* TypeKeyword */: - case 143 /* UniqueKeyword */: - case 144 /* UnknownKeyword */: + case 121 /* AbstractKeyword */: + case 124 /* AnyKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 149 /* GlobalKeyword */: + case 112 /* ImplementsKeyword */: + case 131 /* InferKeyword */: + case 113 /* InterfaceKeyword */: + case 132 /* IsKeyword */: + case 133 /* KeyOfKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 136 /* NeverKeyword */: + case 139 /* NumberKeyword */: + case 140 /* ObjectKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: + case 142 /* StringKeyword */: + case 143 /* SymbolKeyword */: + case 144 /* TypeKeyword */: + case 146 /* UniqueKeyword */: + case 147 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 134 /* ReadonlyKeyword */; + return kind === 137 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 125 /* ConstructorKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 122 /* AsyncKeyword */: + case 121 /* AbstractKeyword */: + case 128 /* ConstructorKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 125 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 122 /* AsyncKeyword */ - || kind === 123 /* AwaitKeyword */ + return kind === 125 /* AsyncKeyword */ + || kind === 126 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -103113,7 +107866,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 313 /* SyntaxList */: + case 317 /* 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); @@ -103121,7 +107874,7 @@ var ts; return cls; } break; - case 73 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } + case 75 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } if (isFromObjectTypeDeclaration(location)) { return ts.findAncestor(location, ts.isObjectTypeDeclaration); } @@ -103147,7 +107900,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -103167,11 +107920,11 @@ var ts; return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -103180,6 +107933,14 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } + function findAlias(typeChecker, symbol, predicate) { + var currentAlias = symbol; + while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { + if (predicate(currentAlias)) { + return currentAlias; + } + } + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -103232,40 +107993,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 92 /* IfKeyword */: - case 84 /* ElseKeyword */: + case 94 /* IfKeyword */: + case 86 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 98 /* ReturnKeyword */: + case 100 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 104 /* TryKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: - var tryStatement = node.kind === 76 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 106 /* TryKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: + var tryStatement = node.kind === 78 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 75 /* CaseKeyword */: - case 81 /* DefaultKeyword */: + case 77 /* CaseKeyword */: + case 83 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 74 /* BreakKeyword */: - case 79 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 81 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 90 /* ForKeyword */: - case 108 /* WhileKeyword */: - case 83 /* DoKeyword */: + case 92 /* ForKeyword */: + case 110 /* WhileKeyword */: + case 85 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 125 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [125 /* ConstructorKeyword */]); - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [127 /* GetKeyword */, 138 /* SetKeyword */]); - case 123 /* AwaitKeyword */: + case 128 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [128 /* ConstructorKeyword */]); + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [130 /* GetKeyword */, 141 /* SetKeyword */]); + case 126 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 118 /* YieldKeyword */: + case 120 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -103308,7 +108069,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 288 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -103340,16 +108101,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 236 /* SwitchStatement */: + if (statement.kind === 232 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -103365,35 +108126,37 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 222 /* Block */: + case 275 /* CaseClause */: + case 276 /* 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]); + return __spreadArrays(declaration.members, [declaration]); } else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 172 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 28 /* AccessibilityModifier */) { + if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { - return nodes.concat(constructor.parameters); + return __spreadArrays(nodes, constructor.parameters); } } else if (modifierFlag & 128 /* Abstract */) { - return nodes.concat([container]); + return __spreadArrays(nodes, [container]); } return nodes; default: @@ -103413,12 +108176,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 92 /* ForKeyword */, 110 /* WhileKeyword */, 85 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 227 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 110 /* WhileKeyword */)) { break; } } @@ -103426,7 +108189,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */, 79 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */, 81 /* ContinueKeyword */); } }); return keywords; @@ -103435,13 +108198,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -103449,13 +108212,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 100 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 102 /* 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(), 75 /* CaseKeyword */, 81 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 77 /* CaseKeyword */, 83 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */); } }); }); @@ -103463,13 +108226,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 104 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 106 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 76 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 78 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 89 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 91 /* FinallyKeyword */); } return keywords; } @@ -103480,13 +108243,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* 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, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -103498,11 +108261,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* 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, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -103514,13 +108277,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 122 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 125 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 123 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 126 /* AwaitKeyword */); } }); }); @@ -103535,7 +108298,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 118 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 120 /* YieldKeyword */); } }); }); @@ -103554,7 +108317,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 === 84 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 86 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -103589,10 +108352,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], 92 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 94 /* 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], 84 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 86 /* ElseKeyword */)) { break; } } @@ -103808,12 +108571,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 241 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { directImports.push(name); break; } @@ -103822,22 +108585,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 73 /* Identifier */: // for 'const x = require("y"); + case 75 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 255 /* 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 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -103847,7 +108610,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 187 /* ImportType */: directImports.push(direct); break; default: @@ -103864,7 +108627,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 288 /* SourceFile */ || sourceFileLike.kind === 248 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -103919,17 +108682,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 252 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 73 /* Identifier */) { + if (decl.kind === 75 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 187 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -103944,17 +108707,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 259 /* 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 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -104004,7 +108767,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 261 /* 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); @@ -104033,7 +108796,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 === 285 /* SourceFile */) { + if (searchSourceFile.kind === 288 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -104081,7 +108844,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 === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 288 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -104096,15 +108859,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -104118,7 +108881,7 @@ var ts; /** * Given a local reference, we might notice that it's an import/export and recursively search for references of that. * If at an import, look locally for the symbol it imports. - * If an an export, look for all imports of it. + * If at an export, look for all imports of it. * This doesn't handle export specifiers; that is done in `getReferencesAtExportSpecifier`. * @param comingFromExport If we are doing a search for all exports, don't bother looking backwards for the imported symbol, since that's the reason we're here. */ @@ -104128,7 +108891,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 193 /* 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) @@ -104250,10 +109013,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 === 238 /* VariableDeclaration */) { - var p = parent; - return p.name !== node ? undefined : - p.parent.kind === 275 /* CatchClause */ ? undefined : p.parent.parent.kind === 220 /* VariableStatement */ ? p.parent.parent : undefined; + var declaration = ts.isVariableDeclaration(parent) ? parent : ts.isBindingElement(parent) ? ts.walkUpBindingElementsAndPatterns(parent) : undefined; + if (declaration) { + return parent.name !== node ? undefined : + ts.isCatchClause(declaration.parent) ? undefined : ts.isVariableStatement(declaration.parent.parent) ? declaration.parent.parent : undefined; } else { return parent; @@ -104262,13 +109025,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -104301,21 +109064,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 288 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 249 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 248 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 263 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -104364,7 +109127,7 @@ var ts; if (ts.isInJSFile(node)) { var binaryExpression = ts.isBinaryExpression(node.parent) ? node.parent : - ts.isPropertyAccessExpression(node.parent) && + ts.isAccessExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && node.parent.parent.left === node.parent ? node.parent.parent : @@ -104408,7 +109171,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 81 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 83 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -104417,7 +109180,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -104425,27 +109188,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -104489,18 +109252,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* 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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 99 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 101 /* 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); @@ -104580,16 +109343,16 @@ var ts; return { displayParts: displayParts, kind: symbolKind }; } function toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixText) { - return __assign({}, entryToDocumentSpan(entry), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); + return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); } FindAllReferences.toRenameLocation = toRenameLocation; function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); if (entry.kind === 0 /* Span */) { - return __assign({}, documentSpan, { isWriteAccess: false, isDefinition: false }); + return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign({}, documentSpan, { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 83 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -104633,10 +109396,10 @@ var ts; var documentSpan = entryToDocumentSpan(entry); if (entry.kind !== 0 /* Span */) { var node = entry.node; - return __assign({}, documentSpan, implementationKindDisplayParts(node, checker)); + return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign({}, documentSpan, { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -104644,13 +109407,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 213 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -104679,7 +109442,7 @@ var ts; function getTextSpan(node, sourceFile, endNode) { var start = node.getStart(sourceFile); var end = (endNode || node).getEnd(); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { ts.Debug.assert(endNode === undefined); start += 1; end -= 1; @@ -104694,7 +109457,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 === 81 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 83 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -104702,49 +109465,49 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 4194304 /* Ambient */)) + if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 208 /* BinaryExpression */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 83 /* DefaultKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 261 /* ExportSpecifier */: + case 254 /* ImportClause */: // default import + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 245 /* InterfaceDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 271 /* JsxAttribute */: + case 248 /* ModuleDeclaration */: + case 251 /* NamespaceExportDeclaration */: + case 255 /* NamespaceImport */: + case 155 /* Parameter */: + case 280 /* ShorthandPropertyAssignment */: + case 246 /* TypeAliasDeclaration */: + case 154 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 159 /* MethodSignature */: + case 157 /* PropertySignature */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -104904,10 +109667,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 288 /* 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 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -104924,21 +109687,32 @@ var ts; 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, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 88 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } + /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ + function isReadonlyTypeOperator(node) { + return node.kind === 137 /* ReadonlyKeyword */ + && ts.isTypeOperatorNode(node.parent) + && node.parent.operator === 137 /* ReadonlyKeyword */; + } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + // A modifier readonly (like on a property declaration) is not special; + // a readonly type keyword (like `readonly string[]`) is. + if (node.kind === 137 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + return undefined; + } + // Likewise, when we *are* looking for a special keyword, make sure we + // *don’t* include readonly member modifiers. + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 137 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -104954,7 +109728,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -104971,7 +109745,7 @@ var ts; // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 81 /* DefaultKeyword */) { + else if (node && node.kind === 83 /* 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); } @@ -104999,9 +109773,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: return 1 /* Constructor */; - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -105237,7 +110011,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 === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 200 /* FunctionExpression */ || valueDeclaration.kind === 213 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -105247,7 +110021,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, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 244 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -105276,7 +110050,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 288 /* 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; @@ -105297,7 +110071,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -105384,8 +110158,9 @@ 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 73 /* Identifier */: + case 75 /* Identifier */: return node.text.length === searchSymbolName.length; + case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && @@ -105393,17 +110168,19 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 81 /* DefaultKeyword */: + case 83 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; } } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, ts.tokenToString(keywordKind), sourceFile), function (referenceLocation) { - return referenceLocation.kind === keywordKind ? FindAllReferences.nodeEntry(referenceLocation) : undefined; + if (referenceLocation.kind === keywordKind && (!filter || filter(referenceLocation))) { + return FindAllReferences.nodeEntry(referenceLocation); + } }); }); return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; @@ -105457,7 +110234,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 73 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 75 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -105513,8 +110290,8 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 81 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 81 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 83 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 83 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.assertDefined(exportSpecifier.symbol); var exportInfo = ts.Debug.assertDefined(FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker)); @@ -105577,7 +110354,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -105593,7 +110370,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 81 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 83 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -105620,7 +110397,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 101 /* ThisKeyword */) { + if (node.kind === 103 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -105639,18 +110416,18 @@ var ts; if (constructorSymbol) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 128 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 161 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 160 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 103 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -105671,10 +110448,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 161 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 101 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -105698,10 +110475,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 73 /* Identifier */) { + if (refNode.kind !== 75 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 280 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -105721,7 +110498,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 222 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -105749,13 +110526,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 191 /* ArrayLiteralExpression */: return true; default: return false; @@ -105808,13 +110585,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -105823,7 +110600,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 99 /* SuperKeyword */) { + if (node.kind !== 101 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -105835,41 +110612,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 75 /* Identifier */ && node.parent.kind === 155 /* Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 288 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -105877,19 +110654,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* 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 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 288 /* SourceFile */: + return container.kind === 288 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -105966,7 +110743,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -106008,7 +110785,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 190 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -106058,11 +110835,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 8388608 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -106112,12 +110888,12 @@ var ts; /* @internal */ var ts; (function (ts) { - function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, _preferences, sourceMapper) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences, sourceMapper) { var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); 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) { + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, function (changeTracker) { updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); @@ -106365,9 +111141,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 101 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -106375,7 +111151,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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -106528,35 +111304,39 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 73 /* Identifier */) { + if (node.kind !== 75 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 257 /* ImportSpecifier */: + return declaration.parent.kind === 256 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(symbol.declarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { + // There are cases when you extend a function by adding properties to it afterwards, + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); 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 === 125 /* ConstructorKeyword */)) { - var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 128 /* ConstructorKeyword */)) { + var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } } function getCallSignatureDefinition() { return ts.isCallOrNewExpressionTarget(node) || ts.isNameOfFunctionDeclaration(node) - ? getSignatureDefinition(symbol.declarations, /*selectConstructors*/ false) + ? getSignatureDefinition(filteredDeclarations, /*selectConstructors*/ false) : undefined; } function getSignatureDefinition(signatureDeclarations, selectConstructors) { @@ -106564,8 +111344,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -106618,9 +111402,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return true; default: return false; @@ -106738,11 +111522,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return [declaration]; - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -106763,16 +111547,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return withNode(tag.class); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -106949,7 +111733,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 === 73 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 75 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -106959,23 +111743,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 159 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 157 /* PropertySignature */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 246 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -106983,14 +111767,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 288 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 248 /* 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 === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 248 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 208 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -107009,14 +111793,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 199 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 213 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -107078,9 +111862,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -107090,7 +111874,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 153 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -107107,7 +111891,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 === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 153 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -107151,6 +111935,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -107165,6 +111950,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -107175,13 +111965,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -107207,7 +111999,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -107232,28 +112024,56 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isPropertyNameLiteral(entityName)) { + var name = ts.getNameOrArgument(entityName); + var nameText = ts.getElementOrPropertyAccessName(entityName); + entityName = entityName.expression; + if (nameText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -107263,46 +112083,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* 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); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 159 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -107314,90 +112136,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 280 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 281 /* SpreadAssignment */: + var expression = node.expression; + // Use the expression as the name of the SpreadAssignment, otherwise show as . + ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); + break; + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: + case 241 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } + addNodeWithRecursiveChild(node, node.body); + break; + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 261 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 166 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 246 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && ts.getElementOrPropertyAccessName(assignmentTarget) !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else if (ts.isBindableStaticAccessExpression(assignmentTarget)) { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, ts.getNameOrArgument(assignmentTarget)); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -107420,8 +112320,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -107435,7 +112335,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -107444,7 +112344,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -107452,7 +112352,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -107465,12 +112458,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -107486,7 +112479,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 !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 248 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -107516,7 +112509,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 248 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -107524,35 +112517,37 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 248 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text + : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -107560,24 +112555,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 164 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -107587,28 +112585,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 246 /* TypeAliasDeclaration */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -107618,21 +112616,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -107645,18 +112637,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -107687,7 +112679,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 === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -107701,13 +112693,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 153 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 288 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 241 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -107715,14 +112707,14 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(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 === 60 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -107739,7 +112731,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -107760,14 +112756,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -107781,8 +112787,8 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, _preferences) { - var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext }); + function organizeImports(sourceFile, formatContext, host, program, preferences) { + var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); var coalesceAndOrganizeImports = function (importGroup) { return coalesceImports(removeUnusedImports(importGroup, sourceFile, program)); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); @@ -108110,7 +113116,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 93 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 95 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -108227,7 +113233,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -108235,23 +113241,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 227 /* DoStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 278 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 239 /* 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, 89 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -108259,24 +113265,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 250 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -108318,7 +113324,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 201 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -108853,10 +113859,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 126 /* DeclareKeyword */) { + if (token === 129 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 131 /* ModuleKeyword */) { + if (token === 134 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -108874,7 +113880,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 93 /* ImportKeyword */) { + if (token === 95 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -108890,9 +113896,9 @@ var ts; return true; } else { - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -108900,7 +113906,7 @@ var ts; return true; } } - else if (token === 60 /* EqualsToken */) { + else if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -108923,7 +113929,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -108933,13 +113939,13 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 120 /* AsKeyword */) { + if (token === 122 /* AsKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -108957,7 +113963,7 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 86 /* ExportKeyword */) { + if (token === 88 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); if (token === 18 /* OpenBraceToken */) { @@ -108969,7 +113975,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -108979,9 +113985,9 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -108989,11 +113995,11 @@ var ts; } } } - else if (token === 93 /* ImportKeyword */) { + else if (token === 95 /* ImportKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 60 /* EqualsToken */) { + if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -109006,7 +114012,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 135 /* RequireKeyword */) { + if (token === 138 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -109021,7 +114027,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 73 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 75 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -109155,14 +114161,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 === 81 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 83 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 153 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -109209,7 +114215,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { // Exclude the quotes start += 1; width -= 2; @@ -109218,9 +114224,10 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -109251,7 +114258,7 @@ var ts; if (node.getStart(sourceFile) > pos) { break outer; } - if (positionShouldSnapToNode(pos, node, nextNode)) { + if (positionShouldSnapToNode(sourceFile, pos, node)) { // 1. Blocks are effectively redundant with SyntaxLists. // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping // of things that should be considered independently. @@ -109260,7 +114267,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -109323,12 +114330,11 @@ var ts; * count too, unless that position belongs to the next node. In effect, makes * selections able to snap to preceding tokens when the cursor is on the tail * end of them with only whitespace ahead. + * @param sourceFile The source file containing the nodes. * @param pos The position to check. * @param node The candidate node to snap to. - * @param nextNode The next sibling node in the tree. - * @param sourceFile The source file containing the nodes. */ - function positionShouldSnapToNode(pos, node, nextNode) { + function positionShouldSnapToNode(sourceFile, pos, node) { // Can’t use 'ts.positionBelongsToNode()' here because it cleverly accounts // for missing nodes, which can’t really be considered when deciding what // to select. @@ -109337,9 +114343,8 @@ var ts; return true; } var nodeEnd = node.getEnd(); - var nextNodeStart = nextNode && nextNode.getStart(); if (nodeEnd === pos) { - return pos !== nextNodeStart; + return ts.getTouchingPropertyName(sourceFile, pos).pos < node.end; } return false; } @@ -109374,14 +114379,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 134 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 56 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 137 /* ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 154 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -109389,7 +114394,7 @@ var ts; // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; })), closeBraceToken, ]; @@ -109401,7 +114406,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -109414,14 +114419,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } return node.getChildren(); @@ -109488,7 +114493,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(313 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(317 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -109497,14 +114502,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 266 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 267 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -109597,7 +114602,7 @@ var ts; var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -109656,7 +114661,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* 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 }; @@ -109709,10 +114714,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 197 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 210 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -109779,17 +114784,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 199 /* ParenthesizedExpression */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* 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 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -109860,11 +114865,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -109913,7 +114918,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 === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -109978,14 +114983,14 @@ 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(28 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(29 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } 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); - var suffixDisplayParts = suffix.concat(returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); + var prefixDisplayParts = __spreadArrays(callTargetDisplayParts, prefix); + var suffixDisplayParts = __spreadArrays(suffix, returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); var documentation = candidateSignature.getDocumentationComment(checker); var tags = candidateSignature.getJsDocTags(); return { isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; @@ -110009,10 +115014,10 @@ var ts; var parameters = (typeParameters || ts.emptyArray).map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -110024,7 +115029,7 @@ var ts; } }); var parameters = checker.getExpandedParameters(candidateSignature).map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: __spreadArrays(typeParameterParts, [ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -110088,6 +115093,10 @@ var ts; if (!sourceFile) return undefined; var program = host.getProgram(); + // If this is source file of project reference source (instead of redirect) there is no generated position + if (program.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) { + return undefined; + } var options = program.getCompilerOptions(); var outPath = options.outFile || options.out; var declarationPath = outPath ? @@ -110225,7 +115234,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -110235,7 +115244,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 243 /* 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)); @@ -110268,11 +115277,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -110289,12 +115298,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 255 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -110352,13 +115361,13 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ - case 97 /* NullKeyword */: - case 73 /* Identifier */: // identifier includes undefined + // falls through + case 99 /* NullKeyword */: + case 75 /* Identifier */: // identifier includes undefined return true; default: return false; @@ -110381,7 +115390,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -110418,7 +115427,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 101 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 103 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -110469,11 +115478,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 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + return location.kind === 75 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 271 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -110500,13 +115509,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 === 101 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 103 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 101 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(101 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 103 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(103 /* 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 */) { @@ -110516,7 +115525,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 193 /* 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)) { @@ -110536,7 +115545,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 196 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 101 /* 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 @@ -110554,7 +115563,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -110571,14 +115580,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(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* 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(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -110591,29 +115600,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 128 /* ConstructorKeyword */ && location.parent.kind === 161 /* 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 === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 128 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 161 /* 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 === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 161 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 164 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -110623,7 +115632,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 213 /* 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 @@ -110631,7 +115640,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(77 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(79 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -110639,37 +115648,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(111 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(113 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* 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(78 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(80 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(85 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(87 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 248 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 75 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 135 /* NamespaceKeyword */ : 134 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -110688,7 +115697,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 154 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -110696,21 +115705,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + if (declaration.kind === 165 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 164 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 246 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -110722,11 +115731,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 282 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -110752,32 +115761,32 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 251 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(135 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 258 /* ExportAssignment */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 83 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 261 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(93 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(95 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 252 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(135 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(138 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -110786,7 +115795,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -110800,7 +115809,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(101 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(103 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -110811,7 +115820,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -110849,10 +115858,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 === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 288 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 208 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -110895,7 +115904,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(94 /* InKeyword */)); + displayParts.push(ts.keywordPart(96 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -110905,7 +115914,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(56 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -110940,7 +115949,7 @@ var ts; if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(38 /* PlusToken */)); + displayParts.push(ts.operatorPart(39 /* 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")); @@ -110965,16 +115974,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 200 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 241 /* VariableDeclaration */ && declaration.kind !== 243 /* 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 === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 288 /* SourceFile */ || parent.kind === 249 /* ModuleBlock */) { return false; } } @@ -110997,32 +116006,24 @@ var ts; */ function transpileModule(input, transpileOptions) { var diagnostics = []; - var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : ts.getDefaultCompilerOptions(); - options.isolatedModules = true; + var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {}; + // mix in default options + var defaultOptions = ts.getDefaultCompilerOptions(); + for (var key in defaultOptions) { + if (ts.hasProperty(defaultOptions, key) && options[key] === undefined) { + options[key] = defaultOptions[key]; + } + } + for (var _i = 0, transpileOptionValueCompilerOptions_1 = ts.transpileOptionValueCompilerOptions; _i < transpileOptionValueCompilerOptions_1.length; _i++) { + var option = transpileOptionValueCompilerOptions_1[_i]; + options[option.name] = option.transpileOptionValue; + } // transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths. options.suppressOutputPathCheck = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, - // so pass --noLib to avoid reporting a file not found error. - options.noLib = true; - // Clear out other settings that would not be used in transpiling this module - options.lib = undefined; - options.types = undefined; - options.noEmit = undefined; - options.noEmitOnError = undefined; - options.paths = undefined; - options.rootDirs = undefined; - options.declaration = undefined; - options.composite = undefined; - options.declarationDir = undefined; - options.out = undefined; - options.outFile = undefined; - // We are not doing a full typecheck, we are not resolving the whole context, - // so pass --noResolve to avoid reporting missing file errors. - options.noResolve = true; // if jsx is specified then treat file as .tsx - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -111227,7 +116228,9 @@ var ts; var res = cb({ advance: advance, readTokenInfo: readTokenInfo, + readEOFTokenRange: readEOFTokenRange, isOnToken: isOnToken, + isOnEOF: isOnEOF, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, @@ -111267,11 +116270,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 32 /* GreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -111279,12 +116282,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 271 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* 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 === 73 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 75 /* Identifier */; } } return false; @@ -111300,23 +116303,18 @@ var ts; container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 42 /* SlashToken */ || t === 65 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -111333,11 +116331,7 @@ var ts; scanner.scan(); } var currentToken = getNextToken(n, expectedScanAction); - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var token = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); // consume trailing trivia if (trailingTrivia) { trailingTrivia = undefined; @@ -111347,11 +116341,7 @@ var ts; if (!ts.isTrivia(currentToken)) { break; } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var trivia = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); if (!trailingTrivia) { trailingTrivia = []; } @@ -111370,7 +116360,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -111404,11 +116394,19 @@ var ts; } return token; } + function readEOFTokenRange() { + ts.Debug.assert(isOnEOF()); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); } + function isOnEOF() { + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + return current === 1 /* EndOfFileToken */; + } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, // then kind needs to be fixed. This might happen in cases @@ -111440,10 +116438,16 @@ var ts; formatting.anyContext = ts.emptyArray; var RuleAction; (function (RuleAction) { - RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; - RuleAction[RuleAction["Space"] = 2] = "Space"; - RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; - RuleAction[RuleAction["Delete"] = 8] = "Delete"; + RuleAction[RuleAction["StopProcessingSpaceActions"] = 1] = "StopProcessingSpaceActions"; + RuleAction[RuleAction["StopProcessingTokenActions"] = 2] = "StopProcessingTokenActions"; + RuleAction[RuleAction["InsertSpace"] = 4] = "InsertSpace"; + RuleAction[RuleAction["InsertNewLine"] = 8] = "InsertNewLine"; + RuleAction[RuleAction["DeleteSpace"] = 16] = "DeleteSpace"; + RuleAction[RuleAction["DeleteToken"] = 32] = "DeleteToken"; + RuleAction[RuleAction["InsertTrailingSemicolon"] = 64] = "InsertTrailingSemicolon"; + RuleAction[RuleAction["StopAction"] = 3] = "StopAction"; + RuleAction[RuleAction["ModifySpaceAction"] = 28] = "ModifySpaceAction"; + RuleAction[RuleAction["ModifyTokenAction"] = 96] = "ModifyTokenAction"; })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); var RuleFlags; (function (RuleFlags) { @@ -111459,8 +116463,10 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { - allTokens.push(token); + for (var token = 0 /* FirstToken */; token <= 151 /* LastToken */; token++) { + if (token !== 1 /* EndOfFileToken */) { + allTokens.push(token); + } } function anyTokenExcept() { var tokens = []; @@ -111470,259 +116476,262 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; - var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArrays(allTokens, [1 /* EndOfFileToken */])); + var keywords = tokenRangeFromRange(76 /* FirstKeyword */, 151 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 74 /* LastBinaryOperator */); + var binaryKeywordOperators = [96 /* InKeyword */, 97 /* InstanceOfKeyword */, 151 /* OfKeyword */, 122 /* AsKeyword */, 132 /* IsKeyword */]; + var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 75 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostincrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; - var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; + var unaryPreincrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostincrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; + var unaryPredecrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostdecrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [73 /* Identifier */].concat(ts.typeKeywords); + var typeNames = __spreadArrays([75 /* Identifier */], 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([73 /* Identifier */, 3 /* MultiLineCommentTrivia */, 77 /* ClassKeyword */, 86 /* ExportKeyword */, 93 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([75 /* Identifier */, 3 /* MultiLineCommentTrivia */, 79 /* ClassKeyword */, 88 /* ExportKeyword */, 95 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 83 /* DoKeyword */, 104 /* TryKeyword */, 89 /* FinallyKeyword */, 84 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 85 /* DoKeyword */, 106 /* TryKeyword */, 91 /* FinallyKeyword */, 86 /* 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, 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 */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), // in other cases there should be no space between '?' and next token - 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", 93 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 95 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 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 */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 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 */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 84 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 108 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 86 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 110 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 91 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, 73 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 91 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 93 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 75 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 93 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [127 /* GetKeyword */, 138 /* SetKeyword */], 73 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 118 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [118 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 98 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [106 /* VarKeyword */, 102 /* ThrowKeyword */, 96 /* NewKeyword */, 82 /* DeleteKeyword */, 98 /* ReturnKeyword */, 105 /* TypeOfKeyword */, 123 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [112 /* LetKeyword */, 78 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [130 /* GetKeyword */, 141 /* SetKeyword */], 75 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 120 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [120 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 100 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterCertainKeywords", [108 /* VarKeyword */, 104 /* ThrowKeyword */, 98 /* NewKeyword */, 84 /* DeleteKeyword */, 100 /* ReturnKeyword */, 107 /* TypeOfKeyword */, 126 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [114 /* LetKeyword */, 80 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 107 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 109 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 122 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 122 /* AsyncKeyword */, 91 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 125 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 125 /* AsyncKeyword */, 93 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [73 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [75 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 73 /* 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, 60 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 60 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 75 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [131 /* ModuleKeyword */, 135 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [134 /* ModuleKeyword */, 138 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 119 /* AbstractKeyword */, - 77 /* ClassKeyword */, - 126 /* DeclareKeyword */, - 81 /* DefaultKeyword */, - 85 /* EnumKeyword */, - 86 /* ExportKeyword */, - 87 /* ExtendsKeyword */, - 127 /* GetKeyword */, - 110 /* ImplementsKeyword */, - 93 /* ImportKeyword */, - 111 /* InterfaceKeyword */, - 131 /* ModuleKeyword */, - 132 /* NamespaceKeyword */, - 114 /* PrivateKeyword */, - 116 /* PublicKeyword */, - 115 /* ProtectedKeyword */, - 134 /* ReadonlyKeyword */, - 138 /* SetKeyword */, - 117 /* StaticKeyword */, - 141 /* TypeKeyword */, - 145 /* FromKeyword */, - 130 /* KeyOfKeyword */, - 128 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [87 /* ExtendsKeyword */, 110 /* ImplementsKeyword */, 145 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + 121 /* AbstractKeyword */, + 79 /* ClassKeyword */, + 129 /* DeclareKeyword */, + 83 /* DefaultKeyword */, + 87 /* EnumKeyword */, + 88 /* ExportKeyword */, + 89 /* ExtendsKeyword */, + 130 /* GetKeyword */, + 112 /* ImplementsKeyword */, + 95 /* ImportKeyword */, + 113 /* InterfaceKeyword */, + 134 /* ModuleKeyword */, + 135 /* NamespaceKeyword */, + 116 /* PrivateKeyword */, + 118 /* PublicKeyword */, + 117 /* ProtectedKeyword */, + 137 /* ReadonlyKeyword */, + 141 /* SetKeyword */, + 119 /* StaticKeyword */, + 144 /* TypeKeyword */, + 148 /* FromKeyword */, + 133 /* KeyOfKeyword */, + 131 /* InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [89 /* ExtendsKeyword */, 112 /* ImplementsKeyword */, 148 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 73 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 75 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), // generics and type assertions - 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 */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 73 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 75 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 119 /* AbstractKeyword */, - 73 /* Identifier */, - 86 /* ExportKeyword */, - 81 /* DefaultKeyword */, - 77 /* ClassKeyword */, - 117 /* StaticKeyword */, - 116 /* PublicKeyword */, - 114 /* PrivateKeyword */, - 115 /* ProtectedKeyword */, - 127 /* GetKeyword */, - 138 /* SetKeyword */, + 121 /* AbstractKeyword */, + 75 /* Identifier */, + 88 /* ExportKeyword */, + 83 /* DefaultKeyword */, + 79 /* ClassKeyword */, + 119 /* StaticKeyword */, + 118 /* PublicKeyword */, + 116 /* PrivateKeyword */, + 117 /* ProtectedKeyword */, + 130 /* GetKeyword */, + 141 /* SetKeyword */, 22 /* OpenBracketToken */, - 40 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 96 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 28 /* LessThanToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + 41 /* AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 98 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 125 /* 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 */), + rule("SpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 4 /* InsertSpace */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - 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 */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty brackets - 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 */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 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 */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing template string braces - 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 */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space after { and before } in JSX expression - 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 */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), // 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, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 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, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - 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 */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 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 */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(122 /* AsyncKeyword */, 75 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(125 /* AsyncKeyword */, 77 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 90 /* ForKeyword */, 123 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 92 /* ForKeyword */, 126 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 83 /* DoKeyword */, 84 /* ElseKeyword */, 75 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 85 /* DoKeyword */, 86 /* ElseKeyword */, 77 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [106 /* TryKeyword */, 91 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; - return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); + return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } formatting.getAllRules = getAllRules; /** @@ -111760,6 +116769,9 @@ var ts; /// /// Contexts /// + function optionEquals(optionName, optionValue) { + return function (context) { return context.options && context.options[optionName] === optionValue; }; + } function isOptionEnabled(optionName) { return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; }; } @@ -111776,45 +116788,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 229 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 179 /* ConditionalType */: + case 216 /* AsExpression */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 167 /* TypePredicate */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 190 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 252 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 241 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 155 /* Parameter */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: - return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 154 /* TypeParameter */: + return context.currentTokenSpan.kind === 96 /* InKeyword */ || context.nextTokenSpan.kind === 96 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 231 /* ForOfStatement */: + return context.currentTokenSpan.kind === 151 /* OfKeyword */ || context.nextTokenSpan.kind === 151 /* OfKeyword */; } return false; } @@ -111826,22 +116843,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 158 /* PropertyDeclaration */ || + contextKind === 157 /* PropertySignature */ || + contextKind === 155 /* Parameter */ || + contextKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 209 /* ConditionalExpression */ || + context.contextNode.kind === 179 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 188 /* ObjectBindingPattern */ || + context.contextNode.kind === 185 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -111867,31 +116884,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 192 /* ObjectLiteralExpression */: + case 249 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 164 /* CallSignature */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 201 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 245 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -111900,40 +116920,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 243 /* FunctionDeclaration */ || context.contextNode.kind === 200 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 172 /* TypeLiteral */: + case 248 /* ModuleDeclaration */: + case 259 /* ExportDeclaration */: + case 260 /* NamedExports */: + case 253 /* ImportDeclaration */: + case 256 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 278 /* CatchClause */: + case 249 /* ModuleBlock */: + case 236 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 222 /* 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 !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 201 /* ArrowFunction */ && blockParent.kind !== 200 /* FunctionExpression */) { return true; } } @@ -111942,31 +116962,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 235 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 278 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 192 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 195 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 196 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -111978,28 +116999,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 201 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 187 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 264 /* JsxElement */ && context.contextNode.kind !== 268 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 274 /* JsxExpression */ || context.contextNode.kind === 273 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 271 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 271 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 265 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -112014,45 +117035,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 242 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 248 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 172 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 165 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { + if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 198 /* TypeAssertionExpression */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -112063,16 +117084,78 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 198 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 109 /* VoidKeyword */ && context.currentTokenParent.kind === 204 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 211 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 217 /* NonNullExpression */; + } + function isSemicolonDeletionContext(context) { + var nextTokenKind = context.nextTokenSpan.kind; + var nextTokenStart = context.nextTokenSpan.pos; + if (ts.isTrivia(nextTokenKind)) { + var nextRealToken = context.nextTokenParent === context.currentTokenParent + ? ts.findNextToken(context.currentTokenParent, ts.findAncestor(context.currentTokenParent, function (a) { return !a.parent; }), context.sourceFile) + : context.nextTokenParent.getFirstToken(context.sourceFile); + if (!nextRealToken) { + return true; + } + nextTokenKind = nextRealToken.kind; + nextTokenStart = nextRealToken.getStart(context.sourceFile); + } + var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; + var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; + if (startLine === endLine) { + return nextTokenKind === 19 /* CloseBraceToken */ + || nextTokenKind === 1 /* EndOfFileToken */; + } + if (nextTokenKind === 221 /* SemicolonClassElement */ || + nextTokenKind === 26 /* SemicolonToken */) { + return false; + } + if (context.contextNode.kind === 245 /* InterfaceDeclaration */ || + context.contextNode.kind === 246 /* TypeAliasDeclaration */) { + // Can’t remove semicolon after `foo`; it would parse as a method declaration: + // + // interface I { + // foo; + // (): void + // } + return !ts.isPropertySignature(context.currentTokenParent) + || !!context.currentTokenParent.type + || nextTokenKind !== 20 /* OpenParenToken */; + } + if (ts.isPropertyDeclaration(context.currentTokenParent)) { + return !context.currentTokenParent.initializer; + } + return context.currentTokenParent.kind !== 229 /* ForStatement */ + && context.currentTokenParent.kind !== 223 /* EmptyStatement */ + && context.currentTokenParent.kind !== 221 /* SemicolonClassElement */ + && nextTokenKind !== 22 /* OpenBracketToken */ + && nextTokenKind !== 20 /* OpenParenToken */ + && nextTokenKind !== 39 /* PlusToken */ + && nextTokenKind !== 40 /* MinusToken */ + && nextTokenKind !== 43 /* SlashToken */ + && nextTokenKind !== 13 /* RegularExpressionLiteral */ + && nextTokenKind !== 27 /* CommaToken */ + && nextTokenKind !== 210 /* TemplateExpression */ + && nextTokenKind !== 15 /* TemplateHead */ + && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* DotToken */; + } + function isSemicolonInsertionContext(context) { + var contextAncestor = ts.findAncestor(context.currentTokenParent, function (ancestor) { + if (ancestor.end !== context.currentTokenSpan.end) { + return "quit"; + } + return ts.syntaxMayBeASICandidate(ancestor.kind); + }); + return !!contextAncestor && ts.isASICandidate(contextAncestor, context.sourceFile); } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -112082,7 +117165,7 @@ var ts; var formatting; (function (formatting) { function getFormatContext(options) { - return { options: options, getRule: getRulesMap() }; + return { options: options, getRules: getRulesMap() }; } formatting.getFormatContext = getFormatContext; var rulesMapCache; @@ -112092,11 +117175,45 @@ var ts; } return rulesMapCache; } + /** + * For a given rule action, gets a mask of other rule actions that + * cannot be applied at the same position. + */ + function getRuleActionExclusion(ruleAction) { + var mask = 0; + if (ruleAction & 1 /* StopProcessingSpaceActions */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 2 /* StopProcessingTokenActions */) { + mask |= 96 /* ModifyTokenAction */; + } + if (ruleAction & 28 /* ModifySpaceAction */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 96 /* ModifyTokenAction */) { + mask |= 96 /* ModifyTokenAction */; + } + return mask; + } function createRulesMap(rules) { var map = buildMap(rules); return function (context) { var bucket = map[getRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind)]; - return bucket && ts.find(bucket, function (rule) { return ts.every(rule.context, function (c) { return c(context); }); }); + if (bucket) { + var rules_1 = []; + var ruleActionMask = 0; + for (var _i = 0, bucket_1 = bucket; _i < bucket_1.length; _i++) { + var rule = bucket_1[_i]; + var acceptRuleActions = ~getRuleActionExclusion(ruleActionMask); + if (rule.action & acceptRuleActions && ts.every(rule.context, function (c) { return c(context); })) { + rules_1.push(rule); + ruleActionMask |= rule.action; + } + } + if (rules_1.length) { + return rules_1; + } + } }; } function buildMap(rules) { @@ -112104,8 +117221,8 @@ var ts; var map = new Array(mapRowLength * mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(map.length); - for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) { - var rule = rules_1[_i]; + for (var _i = 0, rules_2 = rules; _i < rules_2.length; _i++) { + var rule = rules_2[_i]; var specificRule = rule.leftTokenRange.isSpecific && rule.rightTokenRange.isSpecific; for (var _a = 0, _b = rule.leftTokenRange.tokens; _a < _b.length; _a++) { var left = _b[_a]; @@ -112123,16 +117240,16 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 151 /* LastKeyword */ && column <= 151 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 151 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = maskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; + RulesPosition[RulesPosition["StopRulesAny"] = maskBitSize * 1] = "StopRulesAny"; RulesPosition[RulesPosition["ContextRulesSpecific"] = maskBitSize * 2] = "ContextRulesSpecific"; RulesPosition[RulesPosition["ContextRulesAny"] = maskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = maskBitSize * 4] = "NoContextRulesSpecific"; @@ -112154,11 +117271,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action & 3 /* StopAction */ ? + specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -112183,6 +117300,16 @@ var ts; (function (ts) { var formatting; (function (formatting) { + function createTextRangeWithKind(pos, end, kind) { + var textRangeWithKind = { pos: pos, end: end, kind: kind }; + if (ts.Debug.isDebugging) { + Object.defineProperty(textRangeWithKind, "__debugKind", { + get: function () { return ts.Debug.formatSyntaxKind(kind); }, + }); + } + return textRangeWithKind; + } + formatting.createTextRangeWithKind = createTextRangeWithKind; var Constants; (function (Constants) { Constants[Constants["Unknown"] = -1] = "Unknown"; @@ -112306,17 +117433,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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 249 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 288 /* SourceFile */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -112451,7 +117578,7 @@ var ts; return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) { - var options = _a.options, getRule = _a.getRule; + var options = _a.options, getRules = _a.getRules; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); var previousRange; @@ -112541,19 +117668,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: return 79 /* ClassKeyword */; + case 245 /* InterfaceDeclaration */: return 113 /* InterfaceKeyword */; + case 243 /* FunctionDeclaration */: return 93 /* FunctionKeyword */; + case 247 /* EnumDeclaration */: return 247 /* EnumDeclaration */; + case 162 /* GetAccessor */: return 130 /* GetKeyword */; + case 163 /* SetAccessor */: return 141 /* SetKeyword */; + case 160 /* MethodDeclaration */: if (node.asteriskToken) { - return 40 /* AsteriskToken */; + return 41 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -112603,22 +117730,22 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 84 /* ElseKeyword */: - case 108 /* WhileKeyword */: - case 58 /* AtToken */: + case 86 /* ElseKeyword */: + case 110 /* WhileKeyword */: + case 59 /* AtToken */: return false; - case 42 /* SlashToken */: - case 30 /* GreaterThanToken */: + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 185 /* MappedType */) { return false; } break; @@ -112665,6 +117792,12 @@ var ts; } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } + if (!node.parent && formattingScanner.isOnEOF()) { + var token = formattingScanner.readEOFTokenRange(); + if (token.end <= node.end && previousRange) { + processPair(token, sourceFile.getLineAndCharacterOfPosition(token.pos).line, node, previousRange, previousRangeStartLine, previousParent, contextNode, nodeDynamicIndentation); + } + } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; @@ -112710,7 +117843,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 156 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 11 /* JsxText */) { @@ -112718,7 +117851,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 191 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -112886,35 +118019,39 @@ var ts; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = getRule(formattingContext); - var trimTrailingWhitespaces; + var rules = getRules(formattingContext); + var trimTrailingWhitespaces = false; var lineAction = 0 /* None */; - if (rule) { - lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - switch (lineAction) { - case 2 /* LineRemoved */: - // Handle the case where the next line is moved to be the end of this line. - // In this case we don't indent the next line in the next pass. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); - } - break; - case 1 /* LineAdded */: - // Handle the case where token2 is moved to the new line. - // In this case we indent token2 in the next pass but we set - // sameLineIndent flag to notify the indenter that the indentation is within the line. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); - } - break; - default: - ts.Debug.assert(lineAction === 0 /* None */); - } - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = !(rule.action & 8 /* Delete */) && rule.flags !== 1 /* CanDeleteNewLines */; + if (rules) { + // Apply rules in reverse order so that higher priority rules (which are first in the array) + // win in a conflict with lower priority rules. + ts.forEachRight(rules, function (rule) { + lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + switch (lineAction) { + case 2 /* LineRemoved */: + // Handle the case where the next line is moved to be the end of this line. + // In this case we don't indent the next line in the next pass. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); + } + break; + case 1 /* LineAdded */: + // Handle the case where token2 is moved to the new line. + // In this case we indent token2 in the next pass but we set + // sameLineIndent flag to notify the indenter that the indentation is within the line. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); + } + break; + default: + ts.Debug.assert(lineAction === 0 /* None */); + } + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespaces = !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + }); } else { - trimTrailingWhitespaces = true; + trimTrailingWhitespaces = currentItem.kind !== 1 /* EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -113051,20 +118188,28 @@ var ts; edits.push(ts.createTextChangeFromStartLength(start, len, newText)); } } + function recordInsert(start, text) { + if (text) { + edits.push(ts.createTextChangeFromStartLength(start, 0, text)); + } + } function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* Ignore */: + case 1 /* StopProcessingSpaceActions */: // no action required return 0 /* None */; - case 8 /* Delete */: + case 16 /* DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } break; - case 4 /* NewLine */: + case 32 /* DeleteToken */: + recordDelete(previousRange.pos, previousRange.end - previousRange.pos); + break; + case 8 /* InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines @@ -113078,7 +118223,7 @@ var ts; return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; } break; - case 2 /* Space */: + case 4 /* InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { return 0 /* None */; @@ -113088,6 +118233,9 @@ var ts; recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } + break; + case 64 /* InsertTrailingSemicolon */: + recordInsert(previousRange.end, ";"); } return 0 /* None */; } @@ -113101,8 +118249,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -113111,6 +118258,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -113136,34 +118284,34 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 201 /* ArrowFunction */: if (node.typeParameters === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.parameters === list) { return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.arguments === list) { return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 168 /* TypeReference */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -113172,8 +118320,8 @@ var ts; switch (kind) { case 20 /* OpenParenToken */: return 21 /* CloseParenToken */; - case 28 /* LessThanToken */: - return 30 /* GreaterThanToken */; + case 29 /* LessThanToken */: + return 31 /* GreaterThanToken */; case 18 /* OpenBraceToken */: return 19 /* CloseBraceToken */; } @@ -113261,7 +118409,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -113280,7 +118429,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 208 /* 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 */) { @@ -113434,7 +118583,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 === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 288 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -113482,8 +118631,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); + if (parent.kind === 226 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 86 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -113517,40 +118666,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -113573,7 +118722,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 242 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -113646,83 +118795,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 225 /* ExpressionStatement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 191 /* ArrayLiteralExpression */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 185 /* MappedType */: + case 174 /* TupleType */: + case 250 /* CaseBlock */: + case 276 /* DefaultClause */: + case 275 /* CaseClause */: + case 199 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 224 /* VariableStatement */: + case 258 /* ExportAssignment */: + case 234 /* ReturnStatement */: + case 209 /* ConditionalExpression */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: + case 265 /* JsxSelfClosingElement */: + case 274 /* JsxExpression */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 155 /* Parameter */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 181 /* ParenthesizedType */: + case 197 /* TaggedTemplateExpression */: + case 205 /* AwaitExpression */: + case 260 /* NamedExports */: + case 256 /* NamedImports */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 158 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 241 /* VariableDeclaration */: + case 279 /* PropertyAssignment */: + case 208 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 192 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 208 /* BinaryExpression */) { + return true; + } + break; + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return childKind !== 222 /* Block */; + case 259 /* ExportDeclaration */: + return childKind !== 260 /* NamedExports */; + case 253 /* ImportDeclaration */: + return childKind !== 254 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 256 /* NamedImports */); + case 264 /* JsxElement */: + return childKind !== 267 /* JsxClosingElement */; + case 268 /* JsxFragment */: + return childKind !== 270 /* JsxClosingFragment */; + case 178 /* IntersectionType */: + case 177 /* UnionType */: + if (childKind === 172 /* TypeLiteral */) { return false; } // falls through @@ -113733,11 +118886,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: + return parent.kind !== 222 /* Block */; default: return false; } @@ -113879,7 +119032,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 192 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -114044,7 +119197,7 @@ var ts; } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 241 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -114076,7 +119229,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { var firstStatement = ts.firstOrUndefined(ctr.body.statements); if (!firstStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, [newStatement].concat(ctr.body.statements)); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays([newStatement], ctr.body.statements)); } else { this.insertNodeBefore(sourceFile, firstStatement, newStatement); @@ -114085,7 +119238,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, ctr.body.statements.concat([newStatement])); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays(ctr.body.statements, [newStatement])); } else { this.insertNodeAfter(sourceFile, lastStatement, newStatement); @@ -114118,7 +119271,7 @@ var ts; if (getMembersOrProperties(cls).length === 0) { if (ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(cls), { node: cls, sourceFile: sourceFile })) { // For `class C {\n}`, don't add the trailing "\n" - var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, getClassOrObjectBraceEnds(cls, sourceFile).concat([sourceFile])); // TODO: GH#4130 remove 'as any' + var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, __spreadArrays(getClassOrObjectBraceEnds(cls, sourceFile), [sourceFile])); // TODO: GH#4130 remove 'as any' return { prefix: this.newLineCharacter, suffix: comma + (shouldSuffix ? this.newLineCharacter : "") }; } else { @@ -114157,22 +119310,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 155 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -114181,12 +119334,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + if (node.kind === 201 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(91 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(93 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -114195,14 +119348,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 222 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(100 /* 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 === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 200 /* FunctionExpression */ ? 93 /* FunctionKeyword */ : 79 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -114453,29 +119606,34 @@ var ts; var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + noIndent + (options.suffix || ""); } + function getFormatCodeSettingsForWriting(_a, sourceFile) { + var options = _a.options; + var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore; + var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile); + return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore }); + } /** Note: this may mutate `nodeIn`. */ function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) { var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta; var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text; if (validate) validate(node, text); - var formatOptions = formatContext.options; + var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile); var initialIndentation = indentation !== undefined ? indentation : ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos); if (delta === undefined) { - delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatContext.options, nodeIn) ? (formatOptions.indentSize || 0) : 0; + delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? (formatOptions.indentSize || 0) : 0; } var file = { text: text, getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); } }; - var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, formatContext); + var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, __assign(__assign({}, formatContext), { options: formatOptions })); return applyChanges(text, changes); } /** Note: output node may be mutated input node. */ function getNonformattedText(node, sourceFile, newLineCharacter) { - var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); - var writer = createWriter(newLineCharacter, omitTrailingSemicolon); + var writer = createWriter(newLineCharacter); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -114510,9 +119668,9 @@ var ts; nodeArray.end = getEnd(nodes); return nodeArray; } - function createWriter(newLine, omitTrailingSemicolon) { + function createWriter(newLine) { var lastNonTriviaPosition = 0; - var writer = omitTrailingSemicolon ? ts.getTrailingSemicolonOmittingWriter(ts.createTextWriter(newLine)) : ts.createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var onEmitNode = function (hint, node, printCallback) { if (node) { setPos(node, lastNonTriviaPosition); @@ -114663,6 +119821,8 @@ var ts; getColumn: getColumn, getIndent: getIndent, isAtStartOfLine: isAtStartOfLine, + hasTrailingComment: function () { return writer.hasTrailingComment(); }, + hasTrailingWhitespace: function () { return writer.hasTrailingWhitespace(); }, clear: clear }; } @@ -114727,14 +119887,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 153 /* 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 152 /* Parameter */: { + case 155 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -114749,14 +119909,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 189 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -114764,13 +119924,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -114779,7 +119939,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -114826,13 +119986,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 253 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 278 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; @@ -114843,14 +120003,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -115011,10 +120171,10 @@ var ts; }); 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 assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) - : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(147 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(147 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -115030,7 +120190,7 @@ var ts; ts.Diagnostics.This_expression_is_not_callable.code, ts.Diagnostics.This_expression_is_not_constructable.code, ]; - var errorCodes = [ + var errorCodes = __spreadArrays([ ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, @@ -115046,13 +120206,13 @@ var ts; ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator.code, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code, propertyAccessCode - ].concat(callableConstructableErrorCodes); + ], callableConstructableErrorCodes); codefix.registerCodeFix({ fixIds: [fixId], errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -115066,27 +120226,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -115100,7 +120271,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -115113,64 +120284,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = function (identifier) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + return "continue"; + } + var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); + var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); + var variableStatement = ts.getAncestor(declaration, 224 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; - }); - if (isUsedElsewhere) { - return; + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; } - return declaration.initializer; + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; + } + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); + }); + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { - return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 243 /* FunctionDeclaration */ || + ancestor.parent.kind === 200 /* FunctionExpression */ || + ancestor.parent.kind === 201 /* ArrowFunction */ || + ancestor.parent.kind === 160 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -115233,16 +120486,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || fixedNodes.tryAdd(initializer)) { - changeTracker.insertModifierBefore(sourceFile, 78 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 80 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 75 /* Identifier */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -115256,8 +120509,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 75 /* Identifier */: + case 208 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -115277,6 +120530,42 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addMissingDeclareProperty"; + var errorCodes = [ + ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration.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); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Prefix_with_declare, fixId, ts.Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var fixedNodes = new ts.NodeSet(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start, fixedNodes); }); + }, + }); + function makeChange(changeTracker, sourceFile, pos, fixedNodes) { + var token = ts.getTokenAtPosition(sourceFile, pos); + if (!ts.isIdentifier(token)) { + return; + } + var declaration = token.parent; + if (declaration.kind === 158 /* PropertyDeclaration */ && + (!fixedNodes || fixedNodes.tryAdd(declaration))) { + changeTracker.insertModifierBefore(sourceFile, 129 /* DeclareKeyword */, declaration); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -115398,33 +120687,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 241 /* VariableDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 158 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -115446,7 +120735,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 299 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); 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); @@ -115486,8 +120775,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -115591,7 +120880,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 73 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 101 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 103 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -115678,13 +120967,8 @@ var ts; if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, 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); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -115703,14 +120987,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -115745,7 +121026,7 @@ var ts; function annotate(changes, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 157 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -115785,14 +121066,14 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); + var jsDocNode = parent.kind === 201 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 158 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -115802,14 +121083,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 306 /* JSDocParameterTag */: { + case 310 /* 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 307 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -115821,25 +121102,31 @@ var ts; } 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); + return inferTypeFromReferences(program, references, cancellationToken).single(); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + } + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); + case 161 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 128 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -115848,54 +121135,109 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - 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); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + var builtinConstructors = { + string: function () { return checker.getStringType(); }, + number: function () { return checker.getNumberType(); }, + Array: function (t) { return checker.createArrayType(t); }, + Promise: function (t) { return checker.createPromiseType(t); }, + }; + var builtins = [ + checker.getStringType(), + checker.getNumberType(), + checker.createArrayType(checker.getAnyType()), + checker.createPromiseType(checker.getAnyType()), + ]; + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function createEmptyUsage() { + return { + isNumber: undefined, + isString: undefined, + isNumberOrString: undefined, + candidateTypes: undefined, + properties: undefined, + calls: undefined, + constructs: undefined, + numberIndex: undefined, + stringIndex: undefined, + candidateThisTypes: undefined, + inferredTypes: undefined, + }; + } + function combineUsages(usages) { + var combinedProperties = ts.createUnderscoreEscapedMap(); + for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) { + var u = usages_1[_i]; + if (u.properties) { + u.properties.forEach(function (p, name) { + if (!combinedProperties.has(name)) { + combinedProperties.set(name, []); + } + combinedProperties.get(name).push(p); + }); + } } - return inferFromContext(usageContext, checker); + var properties = ts.createUnderscoreEscapedMap(); + combinedProperties.forEach(function (ps, name) { + properties.set(name, combineUsages(ps)); + }); + return { + isNumber: usages.some(function (u) { return u.isNumber; }), + isString: usages.some(function (u) { return u.isString; }), + isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }), + candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }), + properties: properties, + calls: ts.flatMap(usages, function (u) { return u.calls; }), + constructs: ts.flatMap(usages, function (u) { return u.constructs; }), + numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }), + stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }), + candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }), + inferredTypes: undefined, + }; + } + function single() { + return combineTypes(inferTypesFromReferencesSingle(references)); } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = createEmptyUsage(); + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = (usageContext.constructContexts || []).concat(usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return 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) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.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])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = combineTypes(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -115903,242 +121245,255 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = createEmptyUsage(); + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return combineTypes(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = createEmptyUsage(); for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferTypes(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 225 /* ExpressionStatement */: + addCandidateType(usage, checker.getVoidType()); + break; + case 207 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 206 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 208 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 193 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 194 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 158 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 241 /* 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)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - usageContext.isNumber = true; + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + usage.isNumber = true; break; - case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + case 39 /* PlusToken */: + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: // MultiplicativeOperator - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + // falls through + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: // ShiftOperator - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // falls through + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator - case 49 /* AmpersandToken */: - case 50 /* BarToken */: - case 51 /* CaretToken */: + // falls through + case 50 /* AmpersandToken */: + case 51 /* BarToken */: + case 52 /* CaretToken */: // CompoundAssignmentOperator - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 71 /* BarEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: + // falls through + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 73 /* BarEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator - case 39 /* MinusToken */: + // falls through + case 40 /* MinusToken */: // RelationalOperator - case 28 /* LessThanToken */: - case 31 /* LessThanEqualsToken */: - case 30 /* GreaterThanToken */: - case 32 /* GreaterThanEqualsToken */: + // falls through + case 29 /* LessThanToken */: + case 32 /* LessThanEqualsToken */: + case 31 /* GreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; - case 61 /* PlusEqualsToken */: - case 38 /* PlusToken */: + case 63 /* PlusEqualsToken */: + case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; + } + else if (otherOperandType.flags & 1 /* Any */) { + // do nothing, maybe we'll learn something elsewhere } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators - case 60 /* EqualsToken */: - case 33 /* EqualsEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + case 62 /* EqualsToken */: + case 34 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 94 /* InKeyword */: + case 96 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; - // LogicalOperator - case 55 /* BarBarToken */: + // LogicalOperator Or NullishCoalescing + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 241 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: // nothing to infer here break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], - returnType: {} + return_: createEmptyUsage() }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.return_); + if (parent.kind === 195 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || createEmptyUsage(); + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = createEmptyUsage(); + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -116147,17 +121502,19 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { - if (fallback === void 0) { fallback = checker.getAnyType(); } + function combineFromUsage(usage) { + return combineTypes(inferTypes(usage)); + } + function combineTypes(inferences) { if (!inferences.length) - return fallback; + return checker.getAnyType(); // 1. string or number individually override string | number // 2. non-any, non-void overrides any or void // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types @@ -116180,12 +121537,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function combineAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -116221,109 +121577,173 @@ var ts; }); 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) { + function inferTypes(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - 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) { - types.push(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 + if (usage.numberIndex) { + types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); } + if (usage.properties && usage.properties.size + || usage.calls && usage.calls.length + || usage.constructs && usage.constructs.length + || usage.stringIndex) { + types.push(inferStructuralType(usage)); + } + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + types.push.apply(types, inferNamedTypesFromProperties(usage)); return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + function inferStructuralType(usage) { + var members = ts.createUnderscoreEscapedMap(); + if (usage.properties) { + usage.properties.forEach(function (u, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = combineFromUsage(u); + members.set(name, symbol); + }); } + var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; + var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; + var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); + return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + function inferNamedTypesFromProperties(usage) { + if (!usage.properties || !usage.properties.size) + return []; + var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); }); + if (0 < types.length && types.length < 3) { + return types.map(function (t) { return inferInstantiationFromUsage(t, usage); }); + } + return []; + } + function allPropertiesAreAssignableToUsage(type, usage) { + if (!usage.properties) + return false; + return !ts.forEachEntry(usage.properties, function (propUsage, name) { + var source = checker.getTypeOfPropertyOfType(type, name); + if (!source) { + return true; + } + if (propUsage.calls) { + var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); + } + else { + return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage)); + } + }); + } + /** + * inference is limited to + * 1. generic types with a single parameter + * 2. inference to/from calls with a single signature + */ + function inferInstantiationFromUsage(type, usage) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + return type; + } + var generic = type.target; + var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters); + if (!singleTypeParameter) + return type; 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])); + usage.properties.forEach(function (propUsage, name) { + var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name); + ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference."); + types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter)); + }); + return builtinConstructors[type.symbol.escapedName](combineTypes(types)); + } + function inferTypeParameters(genericType, usageType, typeParameter) { + if (genericType === typeParameter) { + return [usageType]; + } + else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); + } + else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference + var genericArgs = checker.getTypeArguments(genericType); + var usageArgs = checker.getTypeArguments(usageType); + var types = []; + if (genericArgs && usageArgs) { + for (var i = 0; i < genericArgs.length; i++) { + if (usageArgs[i]) { + types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter)); } } } + return types; } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + if (genericSigs.length === 1 && usageSigs.length === 1) { + return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } - return undefined; + return []; + } + function inferFromSignatures(genericSig, usageSig, typeParameter) { + var types = []; + for (var i = 0; i < genericSig.parameters.length; i++) { + var genericParam = genericSig.parameters[i]; + var usageParam = usageSig.parameters[i]; + var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]); + if (!usageParam) { + break; + } + var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); + if (elementType) { + genericParamType = elementType; + } + var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); + } + var genericReturn = checker.getReturnTypeOfSignature(genericSig); + var usageReturn = checker.getReturnTypeOfSignature(usageSig); + types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter)); + return types; + } + function getFunctionFromCalls(calls) { + return checker.createAnonymousType(undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); } - function getSignatureFromCallContext(callContext, checker) { + function getSignatureFromCalls(calls) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); + var _loop_12 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); + if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { + symbol.flags |= 16777216 /* Optional */; + } parameters.push(symbol); + }; + for (var i = 0; i < length; i++) { + _loop_12(i); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -116352,12 +121772,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -116389,7 +121809,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(117 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(119 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -116412,7 +121832,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 === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 225 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -116420,27 +121840,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 201 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 222 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -116461,17 +121881,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 200 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 73 /* Identifier */) { + if (node.name.kind !== 75 /* 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, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 88 /* 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 @@ -116482,7 +121902,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 88 /* 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 @@ -116545,12 +121965,12 @@ var ts; return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 122 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 125 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_13 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -116562,7 +121982,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_13(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -116856,10 +122276,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 73 /* Identifier */: // identifier includes undefined + case 75 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -116881,8 +122301,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -116994,6 +122414,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -117085,10 +122506,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -117114,7 +122535,7 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(node.name.text, node, 67220415 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. res.set(text, makeUniqueName("_" + text, identifiers)); } @@ -117134,29 +122555,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 === 60 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 62 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 195 /* 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 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -117196,8 +122617,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -117205,11 +122626,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -117248,18 +122669,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); + case 160 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(88 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -117288,12 +122710,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -117306,7 +122726,7 @@ 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(86 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(88 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -117315,14 +122735,14 @@ var ts; } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(86 /* ExportKeyword */), ts.createToken(78 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(88 /* ExportKeyword */), ts.createToken(80 /* 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(86 /* ExportKeyword */)]; + var modifiers = [ts.createToken(88 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -117330,10 +122750,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -117351,18 +122771,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 188 /* 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 + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 189 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -117373,10 +122795,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -117398,7 +122820,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` var idName = namedBindingsNames.get(propertyName); if (idName === undefined) { idName = makeUniqueName(propertyName, identifiers); @@ -117445,11 +122867,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -117524,8 +122946,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -117552,7 +122976,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -117650,7 +123074,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -117663,7 +123087,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -117671,14 +123095,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -117715,28 +123139,29 @@ var ts; ImportKind[ImportKind["Default"] = 1] = "Default"; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; + ImportKind[ImportKind["ConstEquals"] = 4] = "ConstEquals"; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { - var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); + ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { + function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { var result = []; forEachExternalModule(checker, allSourceFiles, function (moduleSymbol, moduleFile) { // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(sourceFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); if (defaultInfo && defaultInfo.name === symbolName && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); } @@ -117750,7 +123175,7 @@ var ts; return result; } function isTypeOnlySymbol(s, checker) { - return !(ts.skipAlias(s, checker).flags & 67220415 /* Value */); + return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); @@ -117759,7 +123184,7 @@ var ts; var addToExisting = tryAddToExistingImport(existingImports); // Don't bother providing an action to add a new import if we can add to an existing one. var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences); - return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); + return __spreadArrays((useNamespace ? [useNamespace] : ts.emptyArray), addImport); } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -117788,21 +123213,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 253 /* 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 === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 256 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 253 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 255 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -117813,22 +123238,35 @@ 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 === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 253 /* ImportDeclaration */ || i.kind === 252 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } function getNewImportInfos(program, sourceFile, position, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); + var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); - // Sort to keep the shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + // Sort by presence in package.json, then shortest paths first + return ts.sort(choicesForEachExportingModule, function (a, b) { + var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); + var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); + if (allowsImportingA && !allowsImportingB) { + return -1; + } + if (allowsImportingB && !allowsImportingA) { + return 1; + } + return a.moduleSpecifier.length - b.moduleSpecifier.length; + }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -117836,9 +123274,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 253 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 263 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -117848,7 +123286,7 @@ var ts; var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ? getFixesInfoForUMDImport(context, symbolToken) : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken) : undefined; - return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -117858,7 +123296,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } @@ -117870,10 +123308,10 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67220415 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } - function getUmdImportKind(compilerOptions) { + function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { return 1 /* Default */; @@ -117884,6 +123322,9 @@ var ts; case ts.ModuleKind.AMD: case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 4 /* ConstEquals */; + } return 3 /* Equals */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: @@ -117892,7 +123333,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -117905,24 +123346,25 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - ts.Debug.assert(symbolName !== "default" /* Default */); - var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); + var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, host); + var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program, host) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); function addSymbol(moduleSymbol, exportedSymbol, importKind) { originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); } - forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, program.getCompilerOptions()); + var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind); } @@ -117934,20 +123376,41 @@ var ts; }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(moduleSymbol, checker); + function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); if (!exported) return undefined; var symbol = exported.symbol, kind = exported.kind; var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); return info && __assign({ symbol: symbol, kind: kind }, info); } - function getDefaultLikeExportWorker(moduleSymbol, checker) { + function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); if (defaultExport) return { symbol: defaultExport, kind: 1 /* Default */ }; var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); - return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: 3 /* Equals */ }; + return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions, checker) }; + } + function getExportEqualsImportKind(importingFile, compilerOptions, checker) { + if (ts.getAllowSyntheticDefaultImports(compilerOptions) && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return 1 /* Default */; + } + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 1 /* Default */ : 4 /* ConstEquals */; + } + for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isImportEqualsDeclaration(statement)) { + return 3 /* Equals */; + } + if (ts.isImportDeclaration(statement) && statement.importClause && statement.importClause.name) { + var moduleSymbol = checker.getImmediateAliasedSymbol(statement.importClause.symbol); + if (moduleSymbol && moduleSymbol.name !== "default" /* Default */) { + return 1 /* Default */; + } + } + } + return 3 /* Equals */; } function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -117958,7 +123421,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -117974,7 +123437,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -118008,12 +123471,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -118031,7 +123494,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -118056,21 +123519,46 @@ var ts; ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); } if (namespaceLikeImport) { - ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ - ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) - : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) : + namespaceLikeImport.importKind === 4 /* ConstEquals */ ? createConstEqualsRequireDeclaration(namespaceLikeImport.name, quotedModuleSpecifier) : + ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); } } + function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) { + return ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.createIdentifier(name), + /*type*/ undefined, ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) + ], 2 /* Const */)); + } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(checker, from, allSourceFiles, cb) { - forEachExternalModule(checker, allSourceFiles, function (module, sourceFile) { - if (sourceFile === undefined || sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { - cb(module); + function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, cb) { + var filteredCount = 0; + var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host); + var allSourceFiles = program.getSourceFiles(); + forEachExternalModule(program.getTypeChecker(), allSourceFiles, function (module, sourceFile) { + if (sourceFile === undefined) { + if (!packageJson || packageJson.allowsImportingAmbientModule(module, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } + } + else if (sourceFile && sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { + if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } } }); + if (host.log) { + host.log("forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); + } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; function forEachExternalModule(checker, allSourceFiles, cb) { @@ -118125,6 +123613,109 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; + function createAutoImportFilter(fromFile, program, host) { + var packageJsons = host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host); + var dependencyGroups = 1 /* Dependencies */ | 2 /* DevDependencies */ | 8 /* OptionalDependencies */; + // Mix in `getProbablySymlinks` from Program when host doesn't have it + // in order for non-Project hosts to have a symlinks cache. + var moduleSpecifierResolutionHost = { + directoryExists: ts.maybeBind(host, host.directoryExists), + fileExists: ts.maybeBind(host, host.fileExists), + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + readFile: ts.maybeBind(host, host.readFile), + useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || program.getProbableSymlinks, + }; + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName, dependencyGroups) || packageJson.has(ts.getTypesPackageName(packageName), dependencyGroups)) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, allSourceFiles); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, allSourceFiles); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + /** + * Use for a specific module specifier that has already been resolved. + * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve + * the best module specifier for a given module _and_ determine if it’s importable. + */ + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, allSourceFiles) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, allSourceFiles, program.redirectTargetsMap); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -118168,12 +123759,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (property access)"); 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 === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -118202,10 +123793,10 @@ var ts; flags |= 1920 /* Namespace */; } if (meaning & 2 /* Type */) { - flags |= 67897832 /* Type */; + flags |= 788968 /* Type */; } if (meaning & 1 /* Value */) { - flags |= 67220415 /* Value */; + flags |= 111551 /* Value */; } return flags; } @@ -118276,7 +123867,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -118303,7 +123894,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_14(info); } }); })); @@ -118364,7 +123955,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 213 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -118390,7 +123981,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 208 /* 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))); @@ -118400,7 +123991,7 @@ var ts; var contextualType = checker.getContextualType(token.parent); typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; } - return typeNode || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return typeNode || ts.createKeywordTypeNode(124 /* 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); }); @@ -118409,7 +124000,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -118433,7 +124024,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(139 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(142 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -118453,7 +124044,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, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 160 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -118661,7 +124252,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 101 /* ThisKeyword */) + if (token.kind !== 103 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -118700,7 +124291,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 128 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -118744,6 +124335,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -118771,14 +124399,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 87 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 89 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(110 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(112 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 87 /* ExtendsKeyword */ && - heritageClauses[1].token === 110 /* ImplementsKeyword */) { + heritageClauses[0].token === 89 /* ExtendsKeyword */ && + heritageClauses[1].token === 112 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* CommaToken */)); @@ -118865,7 +124493,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 === 28 /* LessThanToken */) { + if (token.kind === 29 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -118885,7 +124513,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* 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)); @@ -118917,7 +124545,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 128 /* InferKeyword */) + if (token.kind === 131 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -118926,7 +124554,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 28 /* LessThanToken */) { + else if (token.kind === 29 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -118936,7 +124564,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -118947,23 +124575,23 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(144 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(147 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 93 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 95 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 155 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -118974,7 +124602,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -118983,7 +124611,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 === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -118992,14 +124620,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 155 /* Parameter */: + case 154 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return true; } } @@ -119046,26 +124674,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 160 /* 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 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* 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); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 75 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -119101,11 +124729,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); 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 223 /* IfStatement */: + case 226 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -119116,15 +124744,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -119166,7 +124794,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, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -119190,7 +124818,7 @@ 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 === 292 /* JSDocNullableType */) { + if (typeNode.kind === 295 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -119210,7 +124838,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 295 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -119227,22 +124855,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 216 /* AsExpression */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 162 /* GetAccessor */: + case 166 /* IndexSignature */: + case 185 /* MappedType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 198 /* TypeAssertionExpression */: + case 241 /* VariableDeclaration */: return true; default: return false; @@ -119271,12 +124899,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -119296,14 +124927,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 93 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -119318,11 +124949,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 73 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 75 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 122 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 125 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -119430,18 +125061,40 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); + var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); switch (declaration.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 158 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: { + var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); + var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + var orderedAccessors = allAccessors.secondAccessor + ? [allAccessors.firstAccessor, allAccessors.secondAccessor] + : [allAccessors.firstAccessor]; + for (var _i = 0, orderedAccessors_1 = orderedAccessors; _i < orderedAccessors_1.length; _i++) { + var accessor = orderedAccessors_1[_i]; + if (ts.isGetAccessorDeclaration(accessor)) { + out(ts.createGetAccessor( + /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); + } + else { + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); + var parameter = ts.getSetAccessorValueParameter(accessor); + var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; + out(ts.createSetAccessor( + /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(preferences))); + } + } + break; + } + case 159 /* MethodSignature */: + case 160 /* 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 @@ -119454,23 +125107,25 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; } - for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { - var signature = signatures_1[_i]; + for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) { + var signature = signatures_1[_a]; // 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)); } - if (declarations.length > signatures.length) { - var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); - } - else { - ts.Debug.assert(declarations.length === signatures.length); - out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + if (!ambient) { + if (declarations.length > signatures.length) { + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + } + else { + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); + out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + } } break; } @@ -119482,14 +125137,14 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 160 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(57 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -119503,15 +125158,14 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(41 /* 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); @@ -119528,8 +125182,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(121 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(124 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -119557,11 +125211,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(121 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(124 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -119572,7 +125226,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -119583,10 +125237,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(116 /* PublicKeyword */); + return ts.createToken(118 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(115 /* ProtectedKeyword */); + return ts.createToken(117 /* ProtectedKeyword */); } return undefined; } @@ -119658,7 +125312,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 195 /* CallExpression */ : 196 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -119769,7 +125423,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(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -119777,7 +125431,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(142 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(145 /* 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)); @@ -119898,6 +125552,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -119919,8 +125606,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 95 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 187 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -119972,8 +125659,8 @@ 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(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); - var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(137 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); @@ -120003,7 +125690,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 123 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 126 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -120014,7 +125701,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 96 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 98 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -120025,6 +125712,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -120041,8 +125762,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -120062,16 +125783,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -120080,7 +125801,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + ts.Debug.assert(!wasDefault, "Can't have a default flag here"); return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } default: @@ -120094,40 +125815,40 @@ 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, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 83 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 88 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(83 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 224 /* 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. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* 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))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -120141,27 +125862,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 257 /* ImportSpecifier */: + case 261 /* 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 251 /* ImportClause */: { + case 254 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 255 /* 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 */; @@ -120182,11 +125903,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 257 /* 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); @@ -120199,7 +125920,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 261 /* 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";` @@ -120208,7 +125929,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -120232,13 +125953,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 255 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 255 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -120255,7 +125976,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 255 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -120276,7 +125997,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -120315,7 +126036,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -120334,7 +126055,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -120455,6 +126176,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -120546,6 +126268,9 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -120598,20 +126323,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 158 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 155 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 161 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 160 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -120629,13 +126354,13 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 4194304 /* Ambient */) { + if (nodeToCheck.flags & 8388608 /* Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -120654,7 +126379,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 241 /* 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`! @@ -120666,13 +126391,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 99 /* SuperKeyword */: + case 101 /* 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 === 192 /* CallExpression */) { + if (node.parent.kind === 195 /* 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)) { @@ -120687,8 +126412,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -120700,20 +126425,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 222 /* Block */: + if (node.parent && node.parent.kind === 239 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -120725,19 +126450,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 182 /* ThisType */: + case 103 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -120746,20 +126471,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 233 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -120813,7 +126538,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 === 152 /* Parameter */) { + if (current.kind === 155 /* 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; } @@ -120824,7 +126549,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 288 /* SourceFile */) { return scopes; } } @@ -120914,32 +126639,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 244 /* 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 === 246 /* ModuleBlock */ + return scope.kind === 249 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -121005,20 +126730,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(114 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(116 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(122 /* AsyncKeyword */)); + modifiers.push(ts.createToken(125 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(122 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(125 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* 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; @@ -121035,7 +126760,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(40 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(41 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -121043,8 +126768,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -121112,7 +126837,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -121159,9 +126884,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 142 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 145 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(142 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); } } /** @@ -121169,6 +126894,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -121179,16 +126905,17 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(114 /* PrivateKeyword */)); + modifiers.push(ts.createToken(116 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } - modifiers.push(ts.createToken(134 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(137 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -121217,7 +126944,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 225 /* 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( @@ -121236,7 +126963,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 225 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -121250,6 +126977,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -121323,7 +127107,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 234 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -121386,11 +127170,11 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; - for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { - var member = members_2[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.pos > maxPos) { return prevMember || members[0]; } @@ -121428,11 +127212,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -121501,7 +127285,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 !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 243 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -121554,7 +127338,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -121564,7 +127348,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -121586,7 +127370,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -121604,7 +127388,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -121817,30 +127601,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 282 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 253 /* ImportDeclaration */ && + parent.kind !== 257 /* ImportSpecifier */; + case 212 /* SpreadElement */: + case 188 /* ObjectBindingPattern */: + case 190 /* BindingElement */: return false; - case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + case 75 /* Identifier */: + return parent.kind !== 190 /* BindingElement */ && + parent.kind !== 257 /* ImportSpecifier */ && + parent.kind !== 261 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 222 /* Block */: + case 288 /* SourceFile */: + case 249 /* ModuleBlock */: + case 275 /* CaseClause */: return true; default: return false; @@ -121856,6 +127640,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -121865,22 +127650,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -121895,11 +127692,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; + } + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function isStatementAndHasJSDoc(n) { return ts.isStatement(n) && ts.hasJSDocNodes(n); @@ -121936,7 +127758,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 67220415 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); if (symbol && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -121950,15 +127772,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(311 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(315 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -121966,10 +127799,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(310 /* JSDocTemplateTag */); + var template = ts.createNode(314 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(154 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -122019,10 +127852,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 116 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 118 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 114 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 116 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -122050,7 +127883,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -122060,7 +127893,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(117 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(119 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -122083,7 +127916,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 155 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -122129,24 +127962,22 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 101 /* ThisKeyword */ && + node.expression.kind === 103 /* ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 103 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -122171,7 +128002,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -122228,11 +128059,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -122267,7 +128098,7 @@ var ts; deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return __spreadArrays(getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference), addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { @@ -122285,10 +128116,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -122310,25 +128141,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 253 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 255 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -122356,20 +128187,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 253 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 252 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -122411,7 +128242,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -122439,19 +128270,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -122460,7 +128291,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 255 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -122470,9 +128301,9 @@ var ts; } if (namedBindings) { if (namedBindingsUnused) { - changes.delete(sourceFile, namedBindings); + changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 256 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -122485,14 +128316,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 188 /* 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); } @@ -122566,7 +128397,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -122619,13 +128450,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -122637,7 +128468,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -122647,18 +128478,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -122668,11 +128499,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 188 /* 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; @@ -122724,18 +128555,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -122743,17 +128574,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -122763,13 +128594,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -122777,9 +128608,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -122810,55 +128641,55 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(88 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { - return [decl].concat(getNamesToExportInCommonJS(decl).map(createExportAssignment)); + return __spreadArrays([decl], getNamesToExportInCommonJS(decl).map(createExportAssignment)); } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 225 /* ExpressionStatement */: + return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 60 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 62 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -122981,7 +128812,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -123013,7 +128844,7 @@ var ts; function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); var classNames = ts.isConstructorDeclaration(functionDeclaration) ? getClassNames(functionDeclaration) : []; - var names = ts.deduplicate(functionNames.concat(classNames), ts.equateValues); + var names = ts.deduplicate(__spreadArrays(functionNames, classNames), ts.equateValues); var checker = program.getTypeChecker(); var references = ts.flatMap(names, /*mapfn*/ function (/*mapfn*/ name) { return ts.FindAllReferences.getReferenceEntriesForNode(-1, name, program, program.getSourceFiles(), cancellationToken); }); var groupedReferences = groupReferences(references); @@ -123120,15 +128951,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -123138,7 +128969,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -123157,14 +128988,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -123206,11 +129037,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 161 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -123218,8 +129049,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -123229,7 +129060,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 81 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 83 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -123344,7 +129175,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(56 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, /*initializer*/ undefined); ts.suppressLeadingAndTrailingTrivia(propertySignature); copyComments(parameterDeclaration.name, propertySignature.name); @@ -123390,15 +129221,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 83 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -123409,30 +129240,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 83 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: - var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + case 161 /* Constructor */: + var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 128 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 213 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -123444,10 +129275,10 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 73 /* Identifier */ ? new IdentifierObject(73 /* Identifier */, pos, end) : + kind === 75 /* Identifier */ ? new IdentifierObject(75 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 12679168 /* ContextFlags */; + node.flags = parent.flags & 25358336 /* ContextFlags */; return node; } var NodeObject = /** @class */ (function () { @@ -123461,7 +129292,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -123518,8 +129349,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 312 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 292 /* FirstJSDocNode */ || kid.kind > 316 /* LastJSDocNode */; }); + return child.kind < 152 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -123530,7 +129361,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 152 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -123576,7 +129407,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 73 /* Identifier */) { + if (token === 75 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -123588,7 +129419,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(313 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(317 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -123711,7 +129542,9 @@ var ts; var IdentifierObject = /** @class */ (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { - return _super.call(this, pos, end) || this; + var _this = _super.call(this, pos, end) || this; + _this.kind = 75 /* Identifier */; + return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { get: function () { @@ -123722,7 +129555,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 73 /* Identifier */; + IdentifierObject.prototype.kind = 75 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -123758,9 +129591,15 @@ var ts; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; }; + TypeObject.prototype.isNullableType = function () { + return this.checker.isNullableType(this); + }; TypeObject.prototype.getNonNullableType = function () { return this.checker.getNonNullableType(this); }; + TypeObject.prototype.getNonOptionalType = function () { + return this.checker.getNonOptionalType(this); + }; TypeObject.prototype.getConstraint = function () { return this.checker.getBaseConstraintOfType(this); }; @@ -123865,7 +129704,9 @@ var ts; var SourceFileObject = /** @class */ (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - return _super.call(this, kind, pos, end) || this; + var _this = _super.call(this, kind, pos, end) || this; + _this.kind = 288 /* SourceFile */; + return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -123923,10 +129764,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -123946,31 +129787,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 172 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -123981,19 +129822,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 259 /* 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 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -124005,7 +129846,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -124014,7 +129855,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -124211,7 +130052,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -124331,16 +130172,20 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; }, getCurrentDirectory: function () { return currentDirectory; }, getProgram: getProgram, - fileExists: host.fileExists && (function (f) { return host.fileExists(f); }), - readFile: host.readFile && (function (f, encoding) { return host.readFile(f, encoding); }), - getDocumentPositionMapper: host.getDocumentPositionMapper && (function (generatedFileName, sourceFileName) { return host.getDocumentPositionMapper(generatedFileName, sourceFileName); }), - getSourceFileLike: host.getSourceFileLike && (function (f) { return host.getSourceFileLike(f); }), + fileExists: ts.maybeBind(host, host.fileExists), + readFile: ts.maybeBind(host, host.readFile), + getDocumentPositionMapper: ts.maybeBind(host, host.getDocumentPositionMapper), + getSourceFileLike: ts.maybeBind(host, host.getSourceFileLike), log: log }); function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - throw new Error("Could not find sourceFile: '" + fileName + "' in " + (program && JSON.stringify(program.getSourceFiles().map(function (f) { return f.fileName; }))) + "."); + var error = new Error("Could not find source file: '" + fileName + "'."); + // We've been having trouble debugging this, so attach sidecar data for the tsserver log. + // See https://github.com/microsoft/TypeScript/issues/30180. + error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); + throw error; } return sourceFile; } @@ -124409,13 +130254,29 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; + compilerHost.resolveModuleNames = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); + compilerHost.resolveTypeReferenceDirectives = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); }; } + if (host.setResolvedProjectReferenceCallbacks) { + compilerHost.setResolvedProjectReferenceCallbacks = function (callbacks) { return host.setResolvedProjectReferenceCallbacks(callbacks); }; + } + if (host.useSourceOfProjectReferenceRedirect) { + compilerHost.useSourceOfProjectReferenceRedirect = function () { return host.useSourceOfProjectReferenceRedirect(); }; + } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -124551,7 +130412,7 @@ var ts; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return semanticDiagnostics.concat(declarationDiagnostics); + return __spreadArrays(semanticDiagnostics, declarationDiagnostics); } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); @@ -124559,12 +130420,12 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + return __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names - var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); + var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } @@ -124576,7 +130437,7 @@ var ts; } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); - return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }); + return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host); } function getQuickInfoAtPosition(fileName, position) { synchronizeHostData(); @@ -124620,15 +130481,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 99 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 101 /* SuperKeyword */: return true; default: return false; @@ -124654,13 +130515,13 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }, highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); + var sourceFilesToSearch = ts.mapDefined(filesToSearch, function (fileName) { return program.getSourceFile(fileName); }); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -124730,16 +130591,16 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: case 10 /* StringLiteral */: - case 88 /* FalseKeyword */: - case 103 /* TrueKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 73 /* Identifier */: + case 90 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 75 /* Identifier */: break; // Cant create the text span default: @@ -124755,7 +130616,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 === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 248 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -124820,7 +130681,7 @@ var ts; _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, + _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -124944,7 +130805,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -125207,7 +131068,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 263 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -125223,14 +131084,15 @@ var ts; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 153 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 192 /* ObjectLiteralExpression */ || node.parent.parent.kind === 272 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -125272,7 +131134,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -125319,7 +131181,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 4194304 /* Ambient */) { + if (tokenAtLocation.flags & 8388608 /* Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -125352,114 +131214,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 190 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 156 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -125477,19 +131339,19 @@ var ts; return spanInOpenParenToken(node); case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 57 /* ColonToken */: + case 58 /* ColonToken */: return spanInColonToken(node); - case 30 /* GreaterThanToken */: - case 28 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return spanInWhileKeyword(node); - case 84 /* ElseKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + case 86 /* ElseKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 151 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -125501,14 +131363,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 === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + if ((node.kind === 75 /* Identifier */ || + node.kind === 212 /* SpreadElement */ || + node.kind === 279 /* PropertyAssignment */ || + node.kind === 280 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 208 /* 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 @@ -125517,7 +131379,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 60 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -125530,22 +131392,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 156 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 208 /* 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 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -125554,21 +131416,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 279 /* 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 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 241 /* VariableDeclaration */: + case 155 /* 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)) { @@ -125576,7 +131438,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -125606,7 +131468,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 230 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -125618,7 +131480,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 231 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -125659,7 +131521,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 244 /* ClassDeclaration */ && functionDeclaration.kind !== 161 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -125682,26 +131544,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 230 /* 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 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* 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 === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 242 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -125726,21 +131588,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 190 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 189 /* ArrayBindingPattern */ && node.kind !== 188 /* ObjectBindingPattern */); + var elements = node.kind === 191 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -125748,18 +131610,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 === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 208 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -125767,25 +131629,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 249 /* 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 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -125793,7 +131655,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 188 /* 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); @@ -125809,7 +131671,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 189 /* 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); @@ -125824,12 +131686,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 227 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 195 /* CallExpression */ || + node.parent.kind === 196 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 199 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -125838,21 +131700,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 199 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -125862,20 +131724,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 279 /* PropertyAssignment */ || + node.parent.kind === 155 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 198 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 227 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -125883,7 +131745,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 231 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -125928,10 +131790,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -125953,9 +131814,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -126026,6 +131889,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -126054,6 +131918,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -126065,6 +131930,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -126208,13 +132074,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -126222,13 +132088,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -126599,7 +132466,7 @@ var ts; typeAcquisition: configFile.typeAcquisition, files: configFile.fileNames, raw: configFile.raw, - errors: realizeDiagnostics(result.parseDiagnostics.concat(configFile.errors), "\r\n") + errors: realizeDiagnostics(__spreadArrays(result.parseDiagnostics, configFile.errors), "\r\n") }; }); }; @@ -126686,8 +132553,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; @@ -126706,7 +132572,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -127187,11 +133052,13 @@ var ts; } }; ThrottledOperations.run = function (self, operationId, cb) { + ts.perfLogger.logStartScheduledOperation(operationId); self.pendingTimeouts.delete(operationId); if (self.logger) { self.logger.info("Running: " + operationId); } cb(); + ts.perfLogger.logStopScheduledOperation(); }; return ThrottledOperations; }()); @@ -127211,6 +133078,7 @@ var ts; }; GcTimer.run = function (self) { self.timerId = undefined; + ts.perfLogger.logStartScheduledOperation("GC collect"); var log = self.logger.hasLevel(server.LogLevel.requestTime); var before = log && self.host.getMemoryUsage(); // TODO: GH#18217 self.host.gc(); // TODO: GH#18217 @@ -127218,6 +133086,7 @@ var ts; var after = self.host.getMemoryUsage(); // TODO: GH#18217 self.logger.perftrc("GC::before " + before + ", after " + after); } + ts.perfLogger.logStopScheduledOperation(); }; return GcTimer; }()); @@ -127264,9 +133133,10 @@ var ts; WatchType["MissingSourceMapFile"] = "Missing source map file"; WatchType["NoopConfigFileForInferredRoot"] = "Noop Config file for the inferred project root"; WatchType["MissingGeneratedFile"] = "Missing generated file"; + WatchType["PackageJsonFile"] = "package.json file for import suggestions"; })(WatchType = ts.WatchType || (ts.WatchType = {})); })(ts || (ts = {})); -// tslint:disable no-unnecessary-qualifier +/* eslint-disable @typescript-eslint/no-unnecessary-qualifier */ /** * Declaration module describing the TypeScript Server protocol */ @@ -127415,6 +133285,12 @@ var ts; IndentStyle["Block"] = "Block"; IndentStyle["Smart"] = "Smart"; })(IndentStyle = protocol.IndentStyle || (protocol.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = protocol.SemicolonPreference || (protocol.SemicolonPreference = {})); var JsxEmit; (function (JsxEmit) { JsxEmit["None"] = "None"; @@ -127844,16 +133720,20 @@ var ts; // the default project; if no configured projects, the first external project should // be the default project; otherwise the first inferred project should be the default. var firstExternalProject = void 0; + var firstConfiguredProject = void 0; for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { var project = _a[_i]; if (project.projectKind === server.ProjectKind.Configured) { - return project; + if (!project.isSourceOfProjectReferenceRedirect(this.fileName)) + return project; + if (!firstConfiguredProject) + firstConfiguredProject = project; } else if (project.projectKind === server.ProjectKind.External && !firstExternalProject) { firstExternalProject = project; } } - return firstExternalProject || this.containingProjects[0]; + return firstConfiguredProject || firstExternalProject || this.containingProjects[0]; } }; ScriptInfo.prototype.registerFileUpdate = function () { @@ -127869,14 +133749,14 @@ var ts; ts.assign(this.formatSettings, formatSettings); } else { - this.formatSettings = __assign({}, this.formatSettings, formatSettings); + this.formatSettings = __assign(__assign({}, this.formatSettings), formatSettings); } } if (preferences) { if (!this.preferences) { this.preferences = ts.emptyOptions; } - this.preferences = __assign({}, this.preferences, preferences); + this.preferences = __assign(__assign({}, this.preferences), preferences); } }; ScriptInfo.prototype.getLatestVersion = function () { @@ -127916,7 +133796,7 @@ var ts; ScriptInfo.prototype.markContainingProjectsAsDirty = function () { for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { var p = _a[_i]; - p.markAsDirty(); + p.markFileAsDirty(this.path); } }; ScriptInfo.prototype.isOrphan = function () { @@ -128196,6 +134076,8 @@ var ts; /*@internal*/ this.typingFiles = server.emptyArray; /*@internal*/ + this.importSuggestionsCache = ts.Completions.createImportSuggestionsForFileCache(); + /*@internal*/ this.globalCacheResolutionModuleName = ts.JsTyping.nonRelativeModuleNameForTypingCache; this.directoryStructureHost = directoryStructureHost; this.currentDirectory = this.projectService.getNormalizedAbsolutePath(currentDirectory || ""); @@ -128230,7 +134112,12 @@ var ts; } this.markAsDirty(); this.projectService.pendingEnsureProjectForOpenFiles = true; + this.packageJsonCache = server.createPackageJsonCache(this); } + /*@internal*/ + Project.prototype.getResolvedProjectReferenceToRedirect = function (_fileName) { + return undefined; + }; Project.prototype.isNonTsProject = function () { server.updateProjectIfDirty(this); return allFilesAreJsOrDts(this); @@ -128254,7 +134141,7 @@ var ts; return this.typingsCache.isKnownTypesPackageName(name); }; Project.prototype.installPackage = function (options) { - return this.typingsCache.installPackage(__assign({}, options, { projectName: this.projectName, projectRootPath: this.toPath(this.currentDirectory) })); + return this.typingsCache.installPackage(__assign(__assign({}, options), { projectName: this.projectName, projectRootPath: this.toPath(this.currentDirectory) })); }; Object.defineProperty(Project.prototype, "typingsCache", { get: function () { @@ -128263,6 +134150,10 @@ var ts; enumerable: true, configurable: true }); + /*@internal*/ + Project.prototype.getProbableSymlinks = function (files) { + return this.symlinks || (this.symlinks = ts.discoverProbableSymlinks(files, this.getCanonicalFileName, this.getCurrentDirectory())); + }; // Method of LanguageServiceHost Project.prototype.getCompilationSettings = function () { return this.compilerOptions; @@ -128344,6 +134235,10 @@ var ts; return this.projectService.host.writeFile(fileName, content); }; Project.prototype.fileExists = function (file) { + return this.fileExistsWithCache(file); + }; + /* @internal */ + Project.prototype.fileExistsWithCache = function (file) { // As an optimization, don't hit the disks for files we already know don't exist // (because we're watching for their creation). var path = this.toPath(file); @@ -128440,8 +134335,11 @@ var ts; Project.prototype.getSourceFileLike = function (fileName) { return this.projectService.getSourceFileLike(fileName, this); }; + /*@internal*/ Project.prototype.shouldEmitFile = function (scriptInfo) { - return scriptInfo && !scriptInfo.isDynamicOrHasMixedContent(); + return scriptInfo && + !scriptInfo.isDynamicOrHasMixedContent() && + !this.program.isSourceOfProjectReferenceRedirect(scriptInfo.path); }; Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { var _this = this; @@ -128500,7 +134398,7 @@ var ts; // Nothing to filter out, so just return as-is return newTypeAcquisition; } - return __assign({}, newTypeAcquisition, { include: this.removeExistingTypings(newTypeAcquisition.include) }); + return __assign(__assign({}, newTypeAcquisition), { include: this.removeExistingTypings(newTypeAcquisition.include) }); }; Project.prototype.getExternalFiles = function () { var _this = this; @@ -128567,6 +134465,10 @@ var ts; ts.clearMap(this.missingFilesMap, ts.closeFileWatcher); this.missingFilesMap = undefined; } + if (this.packageJsonFilesMap) { + ts.clearMap(this.packageJsonFilesMap, ts.closeFileWatcher); + this.packageJsonFilesMap = undefined; + } this.clearGeneratedFileWatch(); // signal language service to release source files acquired from document registry this.languageService.dispose(); @@ -128723,6 +134625,13 @@ var ts; Project.prototype.registerFileUpdate = function (fileName) { (this.updatedFileNames || (this.updatedFileNames = ts.createMap())).set(fileName, true); }; + /*@internal*/ + Project.prototype.markFileAsDirty = function (changedFile) { + this.markAsDirty(); + if (!this.importSuggestionsCache.isEmpty()) { + (this.dirtyFilesForSuggestions || (this.dirtyFilesForSuggestions = ts.createMap())).set(changedFile, true); + } + }; Project.prototype.markAsDirty = function () { if (!this.dirty) { this.projectStateVersion++; @@ -128738,6 +134647,7 @@ var ts; * @returns: true if set of files in the project stays the same and false - otherwise. */ Project.prototype.updateGraph = function () { + ts.perfLogger.logStartUpdateGraph(); this.resolutionCache.startRecordingFilesWithChangedResolutions(); var hasNewProgram = this.updateGraphWorker(); var hasAddedorRemovedFiles = this.hasAddedorRemovedFiles; @@ -128768,6 +134678,7 @@ var ts; if (hasNewProgram) { this.projectProgramVersion++; } + ts.perfLogger.logStopUpdateGraph(); return !hasNewProgram; }; /*@internal*/ @@ -128856,6 +134767,27 @@ var ts; this.resolutionCache.updateTypeRootsWatch(); } } + if (!this.importSuggestionsCache.isEmpty()) { + if (this.hasAddedorRemovedFiles || oldProgram && !oldProgram.structureIsReused) { + this.importSuggestionsCache.clear(); + } + else if (this.dirtyFilesForSuggestions && oldProgram && this.program) { + ts.forEachKey(this.dirtyFilesForSuggestions, function (fileName) { + var oldSourceFile = oldProgram.getSourceFile(fileName); + var sourceFile = _this.program.getSourceFile(fileName); + if (_this.sourceFileHasChangedOwnImportSuggestions(oldSourceFile, sourceFile)) { + _this.importSuggestionsCache.clear(); + return true; + } + }); + } + } + if (this.dirtyFilesForSuggestions) { + this.dirtyFilesForSuggestions.clear(); + } + if (this.hasAddedorRemovedFiles) { + this.symlinks = undefined; + } var oldExternalFiles = this.externalFiles || server.emptyArray; this.externalFiles = this.getExternalFiles(); ts.enumerateInsertsAndDeletes(this.externalFiles, oldExternalFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), @@ -128868,11 +134800,62 @@ var ts; }, function (removed) { return _this.detachScriptInfoFromProject(removed); }); var elapsed = ts.timestamp() - start; this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + " Elapsed: " + elapsed + "ms"); - if (this.program !== oldProgram) { + if (this.hasAddedorRemovedFiles) { this.print(); } + else if (this.program !== oldProgram) { + this.writeLog("Different program with same set of files:: oldProgram.structureIsReused:: " + (oldProgram && oldProgram.structureIsReused)); + } return hasNewProgram; }; + /*@internal*/ + Project.prototype.sourceFileHasChangedOwnImportSuggestions = function (oldSourceFile, newSourceFile) { + if (!oldSourceFile && !newSourceFile) { + return false; + } + // Probably shouldn’t get this far, but on the off chance the file was added or removed, + // we can’t reliably tell anything about it. + if (!oldSourceFile || !newSourceFile) { + return true; + } + ts.Debug.assertEqual(oldSourceFile.fileName, newSourceFile.fileName); + // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. + // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. + if (this.getTypeAcquisition().enable && ts.consumesNodeCoreModules(oldSourceFile) !== ts.consumesNodeCoreModules(newSourceFile)) { + return true; + } + // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. + // Changes elsewhere in the file can change the *type* of an export in a module augmentation, + // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. + if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || + !this.ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { + return true; + } + return false; + }; + /*@internal*/ + Project.prototype.ambientModuleDeclarationsAreEqual = function (oldSourceFile, newSourceFile) { + if (!ts.arrayIsEqualTo(oldSourceFile.ambientModuleNames, newSourceFile.ambientModuleNames)) { + return false; + } + var oldFileStatementIndex = -1; + var newFileStatementIndex = -1; + var _loop_1 = function (ambientModuleName) { + var isMatchingModuleDeclaration = function (node) { return ts.isNonGlobalAmbientModule(node) && node.name.text === ambientModuleName; }; + oldFileStatementIndex = ts.findIndex(oldSourceFile.statements, isMatchingModuleDeclaration, oldFileStatementIndex + 1); + newFileStatementIndex = ts.findIndex(newSourceFile.statements, isMatchingModuleDeclaration, newFileStatementIndex + 1); + if (oldSourceFile.statements[oldFileStatementIndex] !== newSourceFile.statements[newFileStatementIndex]) { + return { value: false }; + } + }; + for (var _i = 0, _a = newSourceFile.ambientModuleNames; _i < _a.length; _i++) { + var ambientModuleName = _a[_i]; + var state_1 = _loop_1(ambientModuleName); + if (typeof state_1 === "object") + return state_1.value; + } + return true; + }; Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName, noRemoveResolution) { var scriptInfoToDetach = this.projectService.getScriptInfo(uncheckedFileName); if (scriptInfoToDetach) { @@ -129049,6 +135032,10 @@ var ts; ts.orderedRemoveItem(this.rootFiles, info); this.rootFilesMap.delete(info.path); }; + /*@internal*/ + Project.prototype.isSourceOfProjectReferenceRedirect = function (fileName) { + return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName); + }; Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { @@ -129057,9 +135044,9 @@ var ts; } // Search our peer node_modules, then any globally-specified probe paths // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ - var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); + var searchPaths = __spreadArrays([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations); if (this.projectService.globalPlugins) { - var _loop_1 = function (globalPluginName) { + var _loop_2 = function (globalPluginName) { // Skip empty names from odd commandline parses if (!globalPluginName) return "continue"; @@ -129074,7 +135061,7 @@ var ts; // Enable global plugins with synthetic configuration entries for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) { var globalPluginName = _a[_i]; - _loop_1(globalPluginName); + _loop_2(globalPluginName); } } }; @@ -129105,7 +135092,7 @@ var ts; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { - this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did expose a proper factory function"); + this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did not expose a proper factory function"); return; } var info = { @@ -129119,6 +135106,7 @@ var ts; var newLS = pluginModule.create(info); for (var _i = 0, _a = Object.keys(this.languageService); _i < _a.length; _i++) { var k = _a[_i]; + // eslint-disable-next-line no-in-operator if (!(k in newLS)) { this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); newLS[k] = this.languageService[k]; @@ -129144,6 +135132,61 @@ var ts; Project.prototype.refreshDiagnostics = function () { this.projectService.sendProjectsUpdatedInBackgroundEvent(); }; + /*@internal*/ + Project.prototype.getPackageJsonsVisibleToFile = function (fileName, rootDir) { + var packageJsonCache = this.packageJsonCache; + var watchPackageJsonFile = this.watchPackageJsonFile.bind(this); + var toPath = this.toPath.bind(this); + var rootPath = rootDir && toPath(rootDir); + var filePath = toPath(fileName); + var result = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(filePath), function processDirectory(directory) { + switch (packageJsonCache.directoryHasPackageJson(directory)) { + // Sync and check same directory again + case 1 /* Maybe */: + packageJsonCache.searchDirectoryAndAncestors(directory); + return processDirectory(directory); + // Check package.json + case -1 /* True */: + var packageJsonFileName = ts.combinePaths(directory, "package.json"); + watchPackageJsonFile(packageJsonFileName); + result.push(ts.Debug.assertDefined(packageJsonCache.getInDirectory(directory))); + } + if (rootPath && rootPath === toPath(directory)) { + return true; + } + }); + return result; + }; + /*@internal*/ + Project.prototype.onAddPackageJson = function (path) { + this.packageJsonCache.addOrUpdate(path); + this.watchPackageJsonFile(path); + }; + /*@internal*/ + Project.prototype.getImportSuggestionsCache = function () { + return this.importSuggestionsCache; + }; + Project.prototype.watchPackageJsonFile = function (path) { + var _this = this; + var watchers = this.packageJsonFilesMap || (this.packageJsonFilesMap = ts.createMap()); + if (!watchers.has(path)) { + watchers.set(path, this.projectService.watchFactory.watchFile(this.projectService.host, path, function (fileName, eventKind) { + var path = _this.toPath(fileName); + switch (eventKind) { + case ts.FileWatcherEventKind.Created: + return ts.Debug.fail(); + case ts.FileWatcherEventKind.Changed: + _this.packageJsonCache.addOrUpdate(path); + break; + case ts.FileWatcherEventKind.Deleted: + _this.packageJsonCache.delete(path); + watchers.get(path).close(); + watchers.delete(path); + } + }, ts.PollingInterval.Low, "package.json file for import suggestions" /* PackageJsonFile */)); + } + }; return Project; }()); server.Project = Project; @@ -129283,9 +135326,63 @@ var ts; _this.isInitialLoadPending = ts.returnTrue; /*@internal*/ _this.sendLoadingProjectFinish = false; + /* @internal */ + _this.useSourceOfProjectReferenceRedirect = function () { return !!_this.languageServiceEnabled && + !_this.getCompilerOptions().disableSourceOfProjectReferenceRedirect; }; _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); return _this; } + /* @internal */ + ConfiguredProject.prototype.setResolvedProjectReferenceCallbacks = function (projectReferenceCallbacks) { + this.projectReferenceCallbacks = projectReferenceCallbacks; + }; + /** + * This implementation of fileExists checks if the file being requested is + * .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that file exists on host + */ + ConfiguredProject.prototype.fileExists = function (file) { + // Project references go to source file instead of .d.ts file + if (this.useSourceOfProjectReferenceRedirect() && this.projectReferenceCallbacks) { + var source = this.projectReferenceCallbacks.getSourceOfProjectReferenceRedirect(file); + if (source) + return ts.isString(source) ? _super.prototype.fileExists.call(this, source) : true; + } + return _super.prototype.fileExists.call(this, file); + }; + /** + * This implementation of directoryExists checks if the directory being requested is + * directory of .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that directory exists on host + */ + ConfiguredProject.prototype.directoryExists = function (path) { + var _this = this; + if (_super.prototype.directoryExists.call(this, path)) + return true; + if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) + return false; + if (!this.mapOfDeclarationDirectories) { + this.mapOfDeclarationDirectories = ts.createMap(); + this.projectReferenceCallbacks.forEachResolvedProjectReference(function (ref) { + if (!ref) + return; + var out = ref.commandLine.options.outFile || ref.commandLine.options.outDir; + if (out) { + _this.mapOfDeclarationDirectories.set(ts.getDirectoryPath(_this.toPath(out)), true); + } + else { + // Set declaration's in different locations only, if they are next to source the directory present doesnt change + var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir; + if (declarationDir) { + _this.mapOfDeclarationDirectories.set(_this.toPath(declarationDir), true); + } + } + }); + } + var dirPath = this.toPath(path); + var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + return !!ts.forEachKey(this.mapOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator); }); + }; /** * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph * @returns: true if set of files in the project stays the same and false - otherwise. @@ -129294,6 +135391,8 @@ var ts; this.isInitialLoadPending = ts.returnFalse; var reloadLevel = this.pendingReload; this.pendingReload = ts.ConfigFileProgramReloadLevel.None; + this.projectReferenceCallbacks = undefined; + this.mapOfDeclarationDirectories = undefined; var result; switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: @@ -129331,6 +135430,11 @@ var ts; return program && program.forEachResolvedProjectReference(cb); }; /*@internal*/ + ConfiguredProject.prototype.getResolvedProjectReferenceToRedirect = function (fileName) { + var program = this.getCurrentProgram(); + return program && program.getResolvedProjectReferenceToRedirect(fileName); + }; + /*@internal*/ ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { @@ -129339,7 +135443,7 @@ var ts; } // Search our peer node_modules, then any globally-specified probe paths // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ - var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); + var searchPaths = __spreadArrays([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations); if (this.projectService.allowLocalPluginLoads) { var local = ts.getDirectoryPath(this.canonicalConfigFilePath); this.projectService.logger.info("Local plugin loading enabled; adding " + local + " to search paths"); @@ -129397,6 +135501,8 @@ var ts; this.stopWatchingWildCards(); this.projectErrors = undefined; this.configFileSpecs = undefined; + this.projectReferenceCallbacks = undefined; + this.mapOfDeclarationDirectories = undefined; _super.prototype.close.call(this); }; /* @internal */ @@ -129490,7 +135596,6 @@ var ts; server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; /*@internal*/ server.maxFileSize = 4 * 1024 * 1024; - // tslint:disable variable-name server.ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; server.ProjectLoadingStartEvent = "projectLoadingStart"; server.ProjectLoadingFinishEvent = "projectLoadingFinish"; @@ -130060,7 +136165,7 @@ var ts; }; ProjectService.prototype.getPreferences = function (file) { var info = this.getScriptInfoForNormalizedPath(file); - return __assign({}, this.hostConfiguration.preferences, info && info.getPreferences()); + return __assign(__assign({}, this.hostConfiguration.preferences), info && info.getPreferences()); }; ProjectService.prototype.getHostFormatCodeOptions = function () { return this.hostConfiguration.formatCodeOptions; @@ -130147,7 +136252,7 @@ var ts; var _this = this; return this.watchFactory.watchDirectory(this.host, directory, function (fileOrDirectory) { var fileOrDirectoryPath = _this.toPath(fileOrDirectory); - project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + var fsResult = project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); // don't trigger callback on open, existing files if (project.fileIsOpen(fileOrDirectoryPath)) { return; @@ -130155,6 +136260,11 @@ var ts; if (ts.isPathIgnored(fileOrDirectoryPath)) return; var configFilename = project.getConfigFilePath(); + if (ts.getBaseFileName(fileOrDirectoryPath) === "package.json" && !ts.isInsideNodeModules(fileOrDirectoryPath) && + (fsResult && fsResult.fileExists || !fsResult && _this.host.fileExists(fileOrDirectoryPath))) { + _this.logger.info("Project: " + configFilename + " Detected new package.json: " + fileOrDirectory); + project.onAddPackageJson(fileOrDirectoryPath); + } // 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, project.getCompilationSettings(), _this.hostConfiguration.extraFileExtensions)) { @@ -130258,7 +136368,7 @@ var ts; } project.updateGraph(); if (!this.useSingleInferredProject && !project.projectRootPath) { - var _loop_2 = function (inferredProject) { + var _loop_3 = function (inferredProject) { if (inferredProject === project || inferredProject.isOrphan()) { return "continue"; } @@ -130279,7 +136389,7 @@ var ts; // Note that we need to create a copy of the array since the list of project can change for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var inferredProject = _a[_i]; - _loop_2(inferredProject); + _loop_3(inferredProject); } } return project; @@ -130798,6 +136908,11 @@ var ts; if (parsedCommandLine.errors.length) { configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); } + this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ + rootNames: parsedCommandLine.fileNames, + options: parsedCommandLine.options, + projectReferences: parsedCommandLine.projectReferences + }, /*replacer*/ undefined, " ")); ts.Debug.assert(!!parsedCommandLine.fileNames); var compilerOptions = parsedCommandLine.options; // Update the project @@ -130824,7 +136939,7 @@ var ts; } 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 + this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); }; ProjectService.prototype.updateNonInferredProjectFiles = function (project, files, propertyReader) { var projectRootFilesMap = project.getRootFilesMap(); @@ -130837,7 +136952,7 @@ var ts; var scriptInfo = void 0; var path = void 0; // Use the project's fileExists so that it can use caching instead of reaching to disk for the query - if (!isDynamic && !project.fileExists(newRootFile)) { + if (!isDynamic && !project.fileExistsWithCache(newRootFile)) { path = server.normalizedPathToPath(normalizedPath, this.currentDirectory, this.toCanonicalFileName); var existingValue = projectRootFilesMap.get(path); if (server.isScriptInfo(existingValue)) { @@ -130869,7 +136984,7 @@ var ts; projectRootFilesMap.forEach(function (value, path) { if (!newRootScriptInfoMap.has(path)) { if (server.isScriptInfo(value)) { - project.removeFile(value, project.fileExists(path), /*detachFromProject*/ true); + project.removeFile(value, project.fileExistsWithCache(path), /*detachFromProject*/ true); } else { projectRootFilesMap.delete(path); @@ -131048,7 +137163,7 @@ var ts; return projects; function combineProjects(toAddInfo) { if (toAddInfo !== info) { - var _loop_3 = function (project) { + var _loop_4 = function (project) { // Add the projects only if they can use symLink targets and not already in the list if (project.languageServiceEnabled && !project.isOrphan() && @@ -131065,7 +137180,7 @@ var ts; }; for (var _i = 0, _a = toAddInfo.containingProjects; _i < _a.length; _i++) { var project = _a[_i]; - _loop_3(project); + _loop_4(project); } } } @@ -131375,12 +137490,12 @@ var ts; this.logger.info("Host information " + args.hostInfo); } if (args.formatOptions) { - this.hostConfiguration.formatCodeOptions = __assign({}, this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + this.hostConfiguration.formatCodeOptions = __assign(__assign({}, this.hostConfiguration.formatCodeOptions), convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } if (args.preferences) { var lazyConfiguredProjectsFromExternalProject = this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject; - this.hostConfiguration.preferences = __assign({}, this.hostConfiguration.preferences, args.preferences); + this.hostConfiguration.preferences = __assign(__assign({}, this.hostConfiguration.preferences), args.preferences); if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) { // Load configured projects for external projects that are pending reload this.configuredProjects.forEach(function (project) { @@ -131530,7 +137645,9 @@ var ts; }; /*@internal*/ ProjectService.prototype.getOriginalLocationEnsuringConfiguredProject = function (project, location) { - var originalLocation = project.getSourceMapper().tryGetSourcePosition(location); + var originalLocation = project.isSourceOfProjectReferenceRedirect(location.fileName) ? + location : + project.getSourceMapper().tryGetSourcePosition(location); if (!originalLocation) return undefined; var fileName = originalLocation.fileName; @@ -131541,7 +137658,9 @@ var ts; if (!configFileName) return undefined; var configuredProject = this.findConfiguredProjectByProjectName(configFileName) || - this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + " for location: " + location.fileName); + this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + if (configuredProject === project) + return originalLocation; updateProjectIfDirty(configuredProject); // Keep this configured project as referenced from project addOriginalConfiguredProject(configuredProject); @@ -131582,6 +137701,7 @@ var ts; var configFileName; var configFileErrors; var project = this.findExternalProjectContainingOpenScriptInfo(info); + var defaultConfigProject; if (!project && !this.syntaxOnly) { // Checking syntaxOnly is an optimization configFileName = this.getConfigFileNameForFile(info); if (configFileName) { @@ -131602,6 +137722,7 @@ var ts; // Ensure project is ready to check if it contains opened script info updateProjectIfDirty(project); } + defaultConfigProject = project; } } // Project we have at this point is going to be updated since its either found through @@ -131618,12 +137739,12 @@ var ts; this.assignOrphanScriptInfoToInferredProject(info, this.openFiles.get(info.path)); } ts.Debug.assert(!info.isOrphan()); - return { configFileName: configFileName, configFileErrors: configFileErrors }; + return { configFileName: configFileName, configFileErrors: configFileErrors, defaultConfigProject: defaultConfigProject }; }; - ProjectService.prototype.cleanupAfterOpeningFile = function () { + ProjectService.prototype.cleanupAfterOpeningFile = function (toRetainConfigProjects) { // This was postponed from closeOpenFile to after opening next file, // so that we can reuse the project if we need to right away - this.removeOrphanConfiguredProjects(); + this.removeOrphanConfiguredProjects(toRetainConfigProjects); // Remove orphan inferred projects now that we have reused projects // We need to create a duplicate because we cant guarantee order after removal for (var _i = 0, _a = this.inferredProjects.slice(); _i < _a.length; _i++) { @@ -131637,25 +137758,33 @@ var ts; // It was then postponed to cleanup these script infos so that they can be reused if // the file from that old project is reopened because of opening file from here. this.removeOrphanScriptInfos(); - this.printProjects(); }; ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent, projectRootPath) { var info = this.getOrCreateOpenScriptInfo(fileName, fileContent, scriptKind, hasMixedContent, projectRootPath); - var result = this.assignProjectToOpenedScriptInfo(info); - this.cleanupAfterOpeningFile(); + var _a = this.assignProjectToOpenedScriptInfo(info), defaultConfigProject = _a.defaultConfigProject, result = __rest(_a, ["defaultConfigProject"]); + this.cleanupAfterOpeningFile(defaultConfigProject); this.telemetryOnOpenFile(info); + this.printProjects(); return result; }; - ProjectService.prototype.removeOrphanConfiguredProjects = function () { + ProjectService.prototype.removeOrphanConfiguredProjects = function (toRetainConfiguredProjects) { var _this = this; var toRemoveConfiguredProjects = ts.cloneMap(this.configuredProjects); + if (toRetainConfiguredProjects) { + if (ts.isArray(toRetainConfiguredProjects)) { + toRetainConfiguredProjects.forEach(retainConfiguredProject); + } + else { + retainConfiguredProject(toRetainConfiguredProjects); + } + } // Do not remove configured projects that are used as original projects of other this.inferredProjects.forEach(markOriginalProjectsAsUsed); this.externalProjects.forEach(markOriginalProjectsAsUsed); this.configuredProjects.forEach(function (project) { // If project has open ref (there are more than zero references from external project/open file), keep it alive as well as any project it references if (project.hasOpenRef()) { - toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + retainConfiguredProject(project); markOriginalProjectsAsUsed(project); } else { @@ -131664,7 +137793,7 @@ var ts; if (ref) { var refProject = _this.configuredProjects.get(ref.sourceFile.path); if (refProject && refProject.hasOpenRef()) { - toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + retainConfiguredProject(project); } } }); @@ -131677,6 +137806,9 @@ var ts; project.originalConfiguredProjects.forEach(function (_value, configuredProjectPath) { return toRemoveConfiguredProjects.delete(configuredProjectPath); }); } } + function retainConfiguredProject(project) { + toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + } }; ProjectService.prototype.removeOrphanScriptInfos = function () { var _this = this; @@ -131749,13 +137881,13 @@ var ts; return result; }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_4 = function (proj) { + var _loop_5 = function (proj) { var knownProject = ts.find(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName(); }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_4(proj); + _loop_5(proj); } }; /* @internal */ @@ -131804,18 +137936,24 @@ var ts; } } // All the script infos now exist, so ok to go update projects for open files + var defaultConfigProjects; if (openScriptInfos) { - openScriptInfos.forEach(function (info) { return _this.assignProjectToOpenedScriptInfo(info); }); + defaultConfigProjects = ts.mapDefined(openScriptInfos, function (info) { return _this.assignProjectToOpenedScriptInfo(info).defaultConfigProject; }); } // While closing files there could be open files that needed assigning new inferred projects, do it now if (assignOrphanScriptInfosToInferredProject) { this.assignOrphanScriptInfosToInferredProject(); } - // Cleanup projects - this.cleanupAfterOpeningFile(); - // Telemetry - ts.forEach(openScriptInfos, function (info) { return _this.telemetryOnOpenFile(info); }); - this.printProjects(); + if (openScriptInfos) { + // Cleanup projects + this.cleanupAfterOpeningFile(defaultConfigProjects); + // Telemetry + openScriptInfos.forEach(function (info) { return _this.telemetryOnOpenFile(info); }); + this.printProjects(); + } + else if (ts.length(closedFiles)) { + this.printProjects(); + } }; /* @internal */ ProjectService.prototype.applyChangesToFile = function (scriptInfo, changes) { @@ -131892,7 +138030,7 @@ var ts; var excludeRules = []; var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); var excludedFiles = []; - var _loop_5 = function (name) { + var _loop_6 = function (name) { var rule = this_2.safelist[name]; for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) { var root = normalizedNames_1[_i]; @@ -131910,7 +138048,7 @@ var ts; } } if (rule.exclude) { - var _loop_7 = function (exclude) { + var _loop_8 = function (exclude) { var processedRule = root.replace(rule.match, function () { var groups = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -131937,7 +138075,7 @@ var ts; }; for (var _c = 0, _d = rule.exclude; _c < _d.length; _c++) { var exclude = _d[_c]; - _loop_7(exclude); + _loop_8(exclude); } } else { @@ -131953,11 +138091,11 @@ var ts; var this_2 = this; for (var _i = 0, _a = Object.keys(this.safelist); _i < _a.length; _i++) { var name = _a[_i]; - _loop_5(name); + _loop_6(name); } var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); var filesToKeep = []; - var _loop_6 = function (i) { + var _loop_7 = function (i) { if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) { excludedFiles.push(normalizedNames[i]); } @@ -131995,7 +138133,7 @@ var ts; }; var this_3 = this; for (var i = 0; i < proj.rootFiles.length; i++) { - _loop_6(i); + _loop_7(i); } proj.rootFiles = filesToKeep; return excludedFiles; @@ -132153,6 +138291,55 @@ var ts; } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + var server; + (function (server) { + function createPackageJsonCache(project) { + var packageJsons = ts.createMap(); + var directoriesWithoutPackageJson = ts.createMap(); + return { + addOrUpdate: addOrUpdate, + delete: function (fileName) { + packageJsons.delete(fileName); + directoriesWithoutPackageJson.set(ts.getDirectoryPath(fileName), true); + }, + getInDirectory: function (directory) { + return packageJsons.get(ts.combinePaths(directory, "package.json")); + }, + directoryHasPackageJson: directoryHasPackageJson, + searchDirectoryAndAncestors: function (directory) { + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (directoryHasPackageJson(ancestor) !== 1 /* Maybe */) { + return true; + } + var packageJsonFileName = project.toPath(ts.combinePaths(ancestor, "package.json")); + if (ts.tryFileExists(project, packageJsonFileName)) { + addOrUpdate(packageJsonFileName); + } + else { + directoriesWithoutPackageJson.set(ancestor, true); + } + }); + }, + }; + function addOrUpdate(fileName) { + var packageJsonInfo = ts.createPackageJsonInfo(fileName, project); + if (packageJsonInfo) { + packageJsons.set(fileName, packageJsonInfo); + directoriesWithoutPackageJson.delete(ts.getDirectoryPath(fileName)); + } + } + function directoryHasPackageJson(directory) { + return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* True */ : + directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : + 1 /* Maybe */; + } + } + server.createPackageJsonCache = createPackageJsonCache; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); var ts; (function (ts) { var server; @@ -132187,6 +138374,9 @@ var ts; } return false; } + function dtsChangeCanAffectEmit(compilationSettings) { + return ts.getEmitDeclarations(compilationSettings) || !!compilationSettings.emitDecoratorMetadata; + } function formatDiag(fileName, project, diag) { var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); // TODO: GH#18217 return { @@ -132239,12 +138429,12 @@ var ts; relatedInformation: ts.map(diag.relatedInformation, formatRelatedInformation), }; return includeFileName - ? __assign({}, common, { fileName: diag.file && diag.file.fileName }) : common; + ? __assign(__assign({}, common), { fileName: diag.file && diag.file.fileName }) : common; } function allEditsBeforePos(edits, pos) { return edits.every(function (edit) { return ts.textSpanEnd(edit.span) < pos; }); } - server.CommandNames = server.protocol.CommandTypes; // tslint:disable-line variable-name + server.CommandNames = server.protocol.CommandTypes; function formatMessage(msg, logger, byteLength, newLine) { var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); @@ -132400,10 +138590,10 @@ var ts; var outputs = []; combineProjectOutputWorker(projects, defaultProject, initialLocation, function (_a, getMappedLocation) { var project = _a.project, location = _a.location; - var _loop_8 = function (outputReferencedSymbol) { + var _loop_9 = function (outputReferencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); var definition = mappedDefinitionFile === undefined ? - outputReferencedSymbol.definition : __assign({}, outputReferencedSymbol.definition, { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); + outputReferencedSymbol.definition : __assign(__assign({}, outputReferencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); var symbolToAddTo = ts.find(outputs, function (o) { return ts.documentSpansEqual(o.definition, definition); }); if (!symbolToAddTo) { symbolToAddTo = { definition: definition, references: [] }; @@ -132419,7 +138609,7 @@ var ts; }; 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); + _loop_9(outputReferencedSymbol); } }, function () { return getDefinitionLocation(defaultProject, initialLocation); }); return outputs.filter(function (o) { return o.references.length !== 0; }); @@ -132453,7 +138643,7 @@ var ts; projectService.forEachEnabledProject(function (project) { if (!ts.addToSeen(seenProjects, project.projectName)) return; - var definition = getDefinitionInProject(memGetDefinition_1(), defaultProject, project); + var definition = mapDefinitionInProject(memGetDefinition_1(), defaultProject, project); if (definition) { toDo = callbackProjectAndLocation({ project: project, location: definition }, projectService, toDo, seenProjects, cb); } @@ -132463,15 +138653,41 @@ var ts; toDo = callbackProjectAndLocation(ts.Debug.assertDefined(toDo.pop()), projectService, toDo, seenProjects, cb); } } - function getDefinitionInProject(definition, definingProject, project) { - if (!definition || project.containsFile(server.toNormalizedPath(definition.fileName))) + function mapDefinitionInProject(definition, definingProject, project) { + // If the definition is actually from the project, definition is correct as is + if (!definition || + project.containsFile(server.toNormalizedPath(definition.fileName)) && + !isLocationProjectReferenceRedirect(project, definition)) { return definition; - var mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); + } + var mappedDefinition = definingProject.isSourceOfProjectReferenceRedirect(definition.fileName) ? + definition : + definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); return mappedDefinition && project.containsFile(server.toNormalizedPath(mappedDefinition.fileName)) ? mappedDefinition : undefined; } + function isLocationProjectReferenceRedirect(project, location) { + if (!location) + return false; + var program = project.getLanguageService().getProgram(); + if (!program) + return false; + var sourceFile = program.getSourceFile(location.fileName); + // It is possible that location is attached to project but + // the program actually includes its redirect instead. + // This happens when rootFile in project is one of the file from referenced project + // Thus root is attached but program doesnt have the actual .ts file but .d.ts + // If this is not the file we were actually looking, return rest of the toDo + return !!sourceFile && + sourceFile.resolvedPath !== sourceFile.path && + sourceFile.resolvedPath !== project.toPath(location.fileName); + } function callbackProjectAndLocation(projectAndLocation, projectService, toDo, seenProjects, cb) { - if (projectAndLocation.project.getCancellationToken().isCancellationRequested()) + var project = projectAndLocation.project, location = projectAndLocation.location; + if (project.getCancellationToken().isCancellationRequested()) return undefined; // Skip rest of toDo if cancelled + // If this is not the file we were actually looking, return rest of the toDo + if (isLocationProjectReferenceRedirect(project, location)) + return toDo; cb(projectAndLocation, function (project, location) { seenProjects.set(projectAndLocation.project.projectName, true); var originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(project, location); @@ -132485,14 +138701,14 @@ var ts; } var symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo); if (symlinkedProjectsMap) { - symlinkedProjectsMap.forEach(function (symlinkedProjects) { + symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) { for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) { var symlinkedProject = symlinkedProjects_2[_i]; - addToTodo({ project: symlinkedProject, location: originalLocation }, toDo, seenProjects); + addToTodo({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } }, toDo, seenProjects); } }); } - return originalLocation; + return originalLocation === location ? undefined : originalLocation; }); return toDo; } @@ -132533,8 +138749,8 @@ var ts; } var Session = /** @class */ (function () { function Session(opts) { - var _this = this; var _a; + var _this = this; this.changeSeq = 0; this.handlers = ts.createMapFromTemplate((_a = {}, _a[server.CommandNames.Status] = function () { @@ -133001,9 +139217,10 @@ var ts; msg += "\n\nFile text of " + fileRequest.file + ":" + server.indent(text) + "\n"; } } - catch (_b) { } // tslint:disable-line no-empty + catch (_b) { } // eslint-disable-line no-empty } - if (err.message && err.message.indexOf("Could not find sourceFile:") !== -1) { + if (err.ProgramFiles) { + msg += "\n\nProgram files: " + JSON.stringify(err.ProgramFiles) + "\n"; msg += "\n\nProjects::\n"; var counter_1 = 0; var addProjectInfo = function (project) { @@ -133026,7 +139243,9 @@ var ts; } return; } - this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); + var msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine); + ts.perfLogger.logEvent("Response message size: " + msgText.length); + this.host.write(msgText); }; Session.prototype.event = function (body, eventName) { this.send(toEvent(eventName, body)); @@ -133245,7 +139464,7 @@ var ts; Session.prototype.mapDefinitionInfoLocations = function (definitions, project) { return definitions.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign({}, newDocumentSpan, { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }); + return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }); }); }; Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) { @@ -133274,7 +139493,9 @@ var ts; }; Session.prototype.getEmitOutput = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getEmitOutput(file); + return project.shouldEmitFile(project.getScriptInfo(file)) ? + project.getLanguageService().getEmitOutput(file) : + { emitSkipped: true, outputFiles: [] }; }; Session.prototype.mapDefinitionInfo = function (definitions, project) { var _this = this; @@ -133290,7 +139511,7 @@ var ts; Session.mapToOriginalLocation = function (def) { if (def.originalFileName) { ts.Debug.assert(def.originalTextSpan !== undefined, "originalTextSpan should be present if originalFileName is"); - return __assign({}, def, { fileName: def.originalFileName, textSpan: def.originalTextSpan, targetFileName: def.fileName, targetTextSpan: def.textSpan, contextSpan: def.originalContextSpan, targetContextSpan: def.contextSpan }); + return __assign(__assign({}, def), { fileName: def.originalFileName, textSpan: def.originalTextSpan, targetFileName: def.fileName, targetTextSpan: def.textSpan, contextSpan: def.originalContextSpan, targetContextSpan: def.contextSpan }); } return def; }; @@ -133307,7 +139528,7 @@ var ts; Session.prototype.toFileSpanWithContext = function (fileName, textSpan, contextSpan, project) { var fileSpan = this.toFileSpan(fileName, textSpan, project); var context = contextSpan && this.toFileSpan(fileName, contextSpan, project); - return context ? __assign({}, fileSpan, { contextStart: context.start, contextEnd: context.end }) : + return context ? __assign(__assign({}, fileSpan), { contextStart: context.start, contextEnd: context.end }) : fileSpan; }; Session.prototype.getTypeDefinition = function (args) { @@ -133319,7 +139540,7 @@ var ts; Session.prototype.mapImplementationLocations = function (implementations, project) { return implementations.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign({}, newDocumentSpan, { kind: info.kind, displayParts: info.displayParts }); + return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { kind: info.kind, displayParts: info.displayParts }); }); }; Session.prototype.getImplementation = function (args, simplifiedResult) { @@ -133342,7 +139563,7 @@ var ts; occurrences.map(function (occurrence) { var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan, isInString = occurrence.isInString, contextSpan = occurrence.contextSpan; var scriptInfo = project.getScriptInfo(fileName); - return __assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), { file: fileName, isWriteAccess: isWriteAccess }, (isInString ? { isInString: isInString } : undefined)); + return __assign(__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), { file: fileName, isWriteAccess: isWriteAccess }), (isInString ? { isInString: isInString } : undefined)); }) : server.emptyArray; }; @@ -133391,7 +139612,7 @@ var ts; file: fileName, highlightSpans: highlightSpans.map(function (_a) { var textSpan = _a.textSpan, kind = _a.kind, contextSpan = _a.contextSpan; - return (__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), { kind: kind })); + return (__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), { kind: kind })); }) }; }); @@ -133486,7 +139707,7 @@ var ts; if (!group_1) map.set(fileName, group_1 = { file: fileName, locs: [] }); var scriptInfo = ts.Debug.assertDefined(this.projectService.getScriptInfo(fileName)); - group_1.locs.push(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), prefixSuffixText)); + group_1.locs.push(__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), prefixSuffixText)); } return ts.arrayFrom(map.values()); }; @@ -133512,7 +139733,7 @@ var ts; var span = toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo); var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1); var lineText = scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, ""); - return __assign({ file: fileName }, span, { lineText: lineText, + return __assign(__assign({ file: fileName }, span), { lineText: lineText, isWriteAccess: isWriteAccess, isDefinition: isDefinition }); }); @@ -133714,7 +139935,7 @@ var ts; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); - var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign({}, server.convertUserPreferences(this.getPreferences(file)), { triggerCharacter: args.triggerCharacter, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions })); + var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions })); if (completions === undefined) return undefined; if (kind === "completions-full" /* CompletionsFull */) @@ -133733,7 +139954,7 @@ var ts; entries.metadata = completions.metadata; return entries; } - var res = __assign({}, completions, { entries: entries }); + var res = __assign(__assign({}, completions), { entries: entries }); return res; }; Session.prototype.getCompletionEntryDetails = function (args, simplifiedResult) { @@ -133747,7 +139968,7 @@ var ts; return project.getLanguageService().getCompletionEntryDetails(file, position, name, formattingOptions, source, _this.getPreferences(file)); }); return simplifiedResult - ? result.map(function (details) { return (__assign({}, details, { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }) })); }) + ? result.map(function (details) { return (__assign(__assign({}, details), { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }) })); }) : result; }; Session.prototype.getCompileOnSaveAffectedFileList = function (args) { @@ -133758,15 +139979,19 @@ var ts; return server.emptyArray; } return combineProjectOutput(info, function (path) { return _this.projectService.getScriptInfoForPath(path); }, projects, function (project, info) { - var result; - if (project.compileOnSaveEnabled && project.languageServiceEnabled && !project.isOrphan() && !project.getCompilationSettings().noEmit) { - result = { - projectFileName: project.getProjectName(), - fileNames: project.getCompileOnSaveAffectedFileList(info), - projectUsesOutFile: !!project.getCompilationSettings().outFile || !!project.getCompilationSettings().out - }; + if (!project.compileOnSaveEnabled || !project.languageServiceEnabled || project.isOrphan()) { + return undefined; } - return result; + var compilationSettings = project.getCompilationSettings(); + if (!!compilationSettings.noEmit || ts.fileExtensionIs(info.fileName, ".d.ts" /* Dts */) && !dtsChangeCanAffectEmit(compilationSettings)) { + // avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled + return undefined; + } + return { + projectFileName: project.getProjectName(), + fileNames: project.getCompileOnSaveAffectedFileList(info), + projectUsesOutFile: !!compilationSettings.outFile || !!compilationSettings.out + }; }); }; Session.prototype.emitFile = function (args) { @@ -133806,11 +140031,11 @@ var ts; return helpItems; } }; - Session.prototype.createCheckList = function (fileNames, defaultProject) { + Session.prototype.createCheckList = function (fileNames) { var _this = this; return ts.mapDefined(fileNames, function (uncheckedFileName) { var fileName = server.toNormalizedPath(uncheckedFileName); - var project = defaultProject || _this.projectService.tryGetDefaultProjectForFile(fileName); + var project = _this.projectService.tryGetDefaultProjectForFile(fileName); return project && { fileName: fileName, project: project }; }); }; @@ -134157,7 +140382,7 @@ var ts; } } } - var sortedFiles = highPriorityFiles.concat(mediumPriorityFiles, lowPriorityFiles, veryLowPriorityFiles); + var sortedFiles = __spreadArrays(highPriorityFiles, mediumPriorityFiles, lowPriorityFiles, veryLowPriorityFiles); var checkList = sortedFiles.map(function (fileName) { return ({ fileName: fileName, project: project }); }); // Project level error analysis runs on background files too, therefore // doesn't require the file to be opened @@ -134247,6 +140472,7 @@ var ts; try { request = JSON.parse(message); relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined; + ts.perfLogger.logStartCommand("" + request.command, message.substring(0, 100)); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; if (this.logger.hasLevel(server.LogLevel.requestTime)) { var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); @@ -134257,6 +140483,8 @@ var ts; this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); } } + // Note: Log before writing the response, else the editor can complete its activity before the server does + ts.perfLogger.logStopCommand("" + request.command, "Success"); if (response) { this.doOutput(response, request.command, request.seq, /*success*/ true); } @@ -134267,10 +140495,12 @@ var ts; catch (err) { if (err instanceof ts.OperationCanceledException) { // Handle cancellation exceptions + ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err); this.doOutput({ canceled: true }, request.command, request.seq, /*success*/ true); return; } this.logErrorWorker(err, message, relevantFile); + ts.perfLogger.logStopCommand("" + (request && request.command), "Error: " + err); this.doOutput( /*info*/ undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, /*success*/ false, "Error processing request. " + err.message + "\n" + err.stack); @@ -134300,7 +140530,7 @@ var ts; function toProtocolTextSpanWithContext(span, contextSpan, scriptInfo) { var textSpan = toProcolTextSpan(span, scriptInfo); var contextTextSpan = contextSpan && toProcolTextSpan(contextSpan, scriptInfo); - return contextTextSpan ? __assign({}, textSpan, { contextStart: contextTextSpan.start, contextEnd: contextTextSpan.end }) : + return contextTextSpan ? __assign(__assign({}, textSpan), { contextStart: contextTextSpan.start, contextEnd: contextTextSpan.end }) : textSpan; } function convertTextChangeToCodeEdit(change, scriptInfo) { @@ -135101,7 +141331,6 @@ var ts; }()); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -// tslint:disable no-unnecessary-type-assertion (TODO: tslint can't find node types) var ts; (function (ts) { var server; @@ -135206,6 +141435,17 @@ var ts; }; Logger.prototype.msg = function (s, type) { if (type === void 0) { type = server.Msg.Err; } + switch (type) { + case server.Msg.Info: + ts.perfLogger.logInfoEvent(s); + break; + case server.Msg.Perf: + ts.perfLogger.logPerfEvent(s); + break; + default: // Msg.Err + ts.perfLogger.logErrEvent(s); + break; + } if (!this.canWrite) return; s = "[" + server.nowString() + "] " + s + "\n"; @@ -135228,7 +141468,7 @@ var ts; Logger.prototype.write = function (s) { if (this.fd >= 0) { var buf = sys.bufferFrom(s); - // tslint:disable-next-line no-null-keyword + // eslint-disable-next-line no-null/no-null fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null); // TODO: GH#18217 } if (this.traceToConsole) { @@ -135474,6 +141714,7 @@ var ts; // so we defer until the next tick. // // Construction should finish before the next tick fires, so we do not need to do this recursively. + // eslint-disable-next-line no-restricted-globals setImmediate(function () { return _this.event(body, eventName); }); } }; @@ -135667,7 +141908,7 @@ var ts; // stat due to inconsistencies of fs.watch // and efficiency of stat on modern filesystems function startWatchTimer() { - // tslint:disable-next-line:ban + // eslint-disable-next-line no-restricted-globals setInterval(function () { var count = 0; var nextToCheck = nextFileToCheck; @@ -135836,10 +142077,12 @@ var ts; close: function () { return pollingWatchedFileSet.removeFile(watchedFile); } }; }; + /* eslint-disable no-restricted-globals */ sys.setTimeout = setTimeout; sys.clearTimeout = clearTimeout; sys.setImmediate = setImmediate; sys.clearImmediate = clearImmediate; + /* eslint-enable no-restricted-globals */ if (typeof global !== "undefined" && global.gc) { sys.gc = function () { return global.gc(); }; } @@ -135859,14 +142102,11 @@ var ts; catch (e) { cancellationToken = server.nullCancellationToken; } - var eventPort; - { - var str = server.findArgument("--eventPort"); - var v = str === undefined ? undefined : parseInt(str); - if (v !== undefined && !isNaN(v)) { - eventPort = v; - } + function parseEventPort(eventPortStr) { + var eventPort = eventPortStr === undefined ? undefined : parseInt(eventPortStr); + return eventPort !== undefined && !isNaN(eventPort) ? eventPort : undefined; } + var eventPort = parseEventPort(server.findArgument("--eventPort")); var localeStr = server.findArgument("--locale"); if (localeStr) { ts.validateLocaleAndSetLanguage(localeStr, sys); @@ -135902,7 +142142,6 @@ var ts; ioSession.logError(err, "unknown"); }); // See https://github.com/Microsoft/TypeScript/issues/11348 - // tslint:disable-next-line no-unnecessary-type-assertion-2 process.noAsar = true; // Start listening ioSession.listen(); @@ -135912,6 +142151,31 @@ var ts; if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) { ts.sys.tryEnableSourceMapsForHost(); } + // Overwrites the current console messages to instead write to + // the log. This is so that language service plugins which use + // console.log don't break the message passing between tsserver + // and the client + console.log = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return logger.msg(args.length === 1 ? args[0] : args.join(", "), server.Msg.Info); + }; + console.warn = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return logger.msg(args.length === 1 ? args[0] : args.join(", "), server.Msg.Err); + }; + console.error = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return logger.msg(args.length === 1 ? args[0] : args.join(", "), server.Msg.Err); + }; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); //# sourceMappingURL=tsserver.js.map \ No newline at end of file diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index c2bad61505ba7..6a691dc0af66d 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.6"; + const versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ const version: string; } @@ -65,17 +65,17 @@ declare namespace ts { } } declare namespace ts { - type Path = string & { + export type Path = string & { __pathBrand: any; }; - interface TextRange { + export interface TextRange { pos: number; end: number; } - type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - 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 { + export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | 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; + export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; + export enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, @@ -104,359 +104,367 @@ declare namespace ts { 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, + QuestionDotToken = 28, + LessThanToken = 29, + LessThanSlashToken = 30, + GreaterThanToken = 31, + LessThanEqualsToken = 32, + GreaterThanEqualsToken = 33, + EqualsEqualsToken = 34, + ExclamationEqualsToken = 35, + EqualsEqualsEqualsToken = 36, + ExclamationEqualsEqualsToken = 37, + EqualsGreaterThanToken = 38, + PlusToken = 39, + MinusToken = 40, + AsteriskToken = 41, + AsteriskAsteriskToken = 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 = 58, + AtToken = 59, + QuestionQuestionToken = 60, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - BacktickToken = 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 = 72, - Identifier = 73, - BreakKeyword = 74, - CaseKeyword = 75, - CatchKeyword = 76, - ClassKeyword = 77, - ConstKeyword = 78, - ContinueKeyword = 79, - DebuggerKeyword = 80, - DefaultKeyword = 81, - DeleteKeyword = 82, - DoKeyword = 83, - ElseKeyword = 84, - EnumKeyword = 85, - ExportKeyword = 86, - ExtendsKeyword = 87, - FalseKeyword = 88, - FinallyKeyword = 89, - ForKeyword = 90, - FunctionKeyword = 91, - IfKeyword = 92, - ImportKeyword = 93, - InKeyword = 94, - InstanceOfKeyword = 95, - NewKeyword = 96, - NullKeyword = 97, - ReturnKeyword = 98, - SuperKeyword = 99, - SwitchKeyword = 100, - ThisKeyword = 101, - ThrowKeyword = 102, - TrueKeyword = 103, - TryKeyword = 104, - TypeOfKeyword = 105, - VarKeyword = 106, - VoidKeyword = 107, - WhileKeyword = 108, - WithKeyword = 109, - ImplementsKeyword = 110, - InterfaceKeyword = 111, - LetKeyword = 112, - PackageKeyword = 113, - PrivateKeyword = 114, - ProtectedKeyword = 115, - PublicKeyword = 116, - StaticKeyword = 117, - YieldKeyword = 118, - AbstractKeyword = 119, - AsKeyword = 120, - AnyKeyword = 121, - AsyncKeyword = 122, - AwaitKeyword = 123, - BooleanKeyword = 124, - ConstructorKeyword = 125, - DeclareKeyword = 126, - GetKeyword = 127, - InferKeyword = 128, - IsKeyword = 129, - KeyOfKeyword = 130, - ModuleKeyword = 131, - NamespaceKeyword = 132, - NeverKeyword = 133, - ReadonlyKeyword = 134, - RequireKeyword = 135, - NumberKeyword = 136, - ObjectKeyword = 137, - SetKeyword = 138, - StringKeyword = 139, - SymbolKeyword = 140, - TypeKeyword = 141, - UndefinedKeyword = 142, - UniqueKeyword = 143, - UnknownKeyword = 144, - FromKeyword = 145, - GlobalKeyword = 146, - BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocComment = 297, - JSDocTypeLiteral = 298, - JSDocSignature = 299, - JSDocTag = 300, - JSDocAugmentsTag = 301, - JSDocAuthorTag = 302, - JSDocClassTag = 303, - JSDocCallbackTag = 304, - JSDocEnumTag = 305, - JSDocParameterTag = 306, - JSDocReturnTag = 307, - JSDocThisTag = 308, - JSDocTypeTag = 309, - JSDocTemplateTag = 310, - JSDocTypedefTag = 311, - JSDocPropertyTag = 312, - SyntaxList = 313, - NotEmittedStatement = 314, - PartiallyEmittedExpression = 315, - CommaListExpression = 316, - MergeDeclarationMarker = 317, - EndOfDeclarationMarker = 318, - Count = 319, - FirstAssignment = 60, - LastAssignment = 72, - FirstCompoundAssignment = 61, - LastCompoundAssignment = 72, - FirstReservedWord = 74, - LastReservedWord = 109, - FirstKeyword = 74, - LastKeyword = 148, - FirstFutureReservedWord = 110, - LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + BacktickToken = 61, + EqualsToken = 62, + PlusEqualsToken = 63, + MinusEqualsToken = 64, + AsteriskEqualsToken = 65, + AsteriskAsteriskEqualsToken = 66, + SlashEqualsToken = 67, + PercentEqualsToken = 68, + LessThanLessThanEqualsToken = 69, + GreaterThanGreaterThanEqualsToken = 70, + GreaterThanGreaterThanGreaterThanEqualsToken = 71, + AmpersandEqualsToken = 72, + BarEqualsToken = 73, + CaretEqualsToken = 74, + Identifier = 75, + BreakKeyword = 76, + CaseKeyword = 77, + CatchKeyword = 78, + ClassKeyword = 79, + ConstKeyword = 80, + ContinueKeyword = 81, + DebuggerKeyword = 82, + DefaultKeyword = 83, + DeleteKeyword = 84, + DoKeyword = 85, + ElseKeyword = 86, + EnumKeyword = 87, + ExportKeyword = 88, + ExtendsKeyword = 89, + FalseKeyword = 90, + FinallyKeyword = 91, + ForKeyword = 92, + FunctionKeyword = 93, + IfKeyword = 94, + ImportKeyword = 95, + InKeyword = 96, + InstanceOfKeyword = 97, + NewKeyword = 98, + NullKeyword = 99, + ReturnKeyword = 100, + SuperKeyword = 101, + SwitchKeyword = 102, + ThisKeyword = 103, + ThrowKeyword = 104, + TrueKeyword = 105, + TryKeyword = 106, + TypeOfKeyword = 107, + VarKeyword = 108, + VoidKeyword = 109, + WhileKeyword = 110, + WithKeyword = 111, + ImplementsKeyword = 112, + InterfaceKeyword = 113, + LetKeyword = 114, + PackageKeyword = 115, + PrivateKeyword = 116, + ProtectedKeyword = 117, + PublicKeyword = 118, + StaticKeyword = 119, + YieldKeyword = 120, + AbstractKeyword = 121, + AsKeyword = 122, + AssertsKeyword = 123, + AnyKeyword = 124, + AsyncKeyword = 125, + AwaitKeyword = 126, + BooleanKeyword = 127, + ConstructorKeyword = 128, + DeclareKeyword = 129, + GetKeyword = 130, + InferKeyword = 131, + IsKeyword = 132, + KeyOfKeyword = 133, + ModuleKeyword = 134, + NamespaceKeyword = 135, + NeverKeyword = 136, + ReadonlyKeyword = 137, + RequireKeyword = 138, + NumberKeyword = 139, + ObjectKeyword = 140, + SetKeyword = 141, + StringKeyword = 142, + SymbolKeyword = 143, + TypeKeyword = 144, + UndefinedKeyword = 145, + UniqueKeyword = 146, + UnknownKeyword = 147, + FromKeyword = 148, + GlobalKeyword = 149, + BigIntKeyword = 150, + OfKeyword = 151, + QualifiedName = 152, + ComputedPropertyName = 153, + TypeParameter = 154, + Parameter = 155, + Decorator = 156, + PropertySignature = 157, + PropertyDeclaration = 158, + MethodSignature = 159, + MethodDeclaration = 160, + Constructor = 161, + GetAccessor = 162, + SetAccessor = 163, + CallSignature = 164, + ConstructSignature = 165, + IndexSignature = 166, + TypePredicate = 167, + TypeReference = 168, + FunctionType = 169, + ConstructorType = 170, + TypeQuery = 171, + TypeLiteral = 172, + ArrayType = 173, + TupleType = 174, + OptionalType = 175, + RestType = 176, + UnionType = 177, + IntersectionType = 178, + ConditionalType = 179, + InferType = 180, + ParenthesizedType = 181, + ThisType = 182, + TypeOperator = 183, + IndexedAccessType = 184, + MappedType = 185, + LiteralType = 186, + ImportType = 187, + ObjectBindingPattern = 188, + ArrayBindingPattern = 189, + BindingElement = 190, + ArrayLiteralExpression = 191, + ObjectLiteralExpression = 192, + PropertyAccessExpression = 193, + ElementAccessExpression = 194, + CallExpression = 195, + NewExpression = 196, + TaggedTemplateExpression = 197, + TypeAssertionExpression = 198, + ParenthesizedExpression = 199, + FunctionExpression = 200, + ArrowFunction = 201, + DeleteExpression = 202, + TypeOfExpression = 203, + VoidExpression = 204, + AwaitExpression = 205, + PrefixUnaryExpression = 206, + PostfixUnaryExpression = 207, + BinaryExpression = 208, + ConditionalExpression = 209, + TemplateExpression = 210, + YieldExpression = 211, + SpreadElement = 212, + ClassExpression = 213, + OmittedExpression = 214, + ExpressionWithTypeArguments = 215, + AsExpression = 216, + NonNullExpression = 217, + MetaProperty = 218, + SyntheticExpression = 219, + TemplateSpan = 220, + SemicolonClassElement = 221, + Block = 222, + EmptyStatement = 223, + VariableStatement = 224, + ExpressionStatement = 225, + IfStatement = 226, + DoStatement = 227, + WhileStatement = 228, + ForStatement = 229, + ForInStatement = 230, + ForOfStatement = 231, + ContinueStatement = 232, + BreakStatement = 233, + ReturnStatement = 234, + WithStatement = 235, + SwitchStatement = 236, + LabeledStatement = 237, + ThrowStatement = 238, + TryStatement = 239, + DebuggerStatement = 240, + VariableDeclaration = 241, + VariableDeclarationList = 242, + FunctionDeclaration = 243, + ClassDeclaration = 244, + InterfaceDeclaration = 245, + TypeAliasDeclaration = 246, + EnumDeclaration = 247, + ModuleDeclaration = 248, + ModuleBlock = 249, + CaseBlock = 250, + NamespaceExportDeclaration = 251, + ImportEqualsDeclaration = 252, + ImportDeclaration = 253, + ImportClause = 254, + NamespaceImport = 255, + NamedImports = 256, + ImportSpecifier = 257, + ExportAssignment = 258, + ExportDeclaration = 259, + NamedExports = 260, + ExportSpecifier = 261, + MissingDeclaration = 262, + ExternalModuleReference = 263, + JsxElement = 264, + JsxSelfClosingElement = 265, + JsxOpeningElement = 266, + JsxClosingElement = 267, + JsxFragment = 268, + JsxOpeningFragment = 269, + JsxClosingFragment = 270, + JsxAttribute = 271, + JsxAttributes = 272, + JsxSpreadAttribute = 273, + JsxExpression = 274, + CaseClause = 275, + DefaultClause = 276, + HeritageClause = 277, + CatchClause = 278, + PropertyAssignment = 279, + ShorthandPropertyAssignment = 280, + SpreadAssignment = 281, + EnumMember = 282, + UnparsedPrologue = 283, + UnparsedPrepend = 284, + UnparsedText = 285, + UnparsedInternalText = 286, + UnparsedSyntheticReference = 287, + SourceFile = 288, + Bundle = 289, + UnparsedSource = 290, + InputFiles = 291, + JSDocTypeExpression = 292, + JSDocAllType = 293, + JSDocUnknownType = 294, + JSDocNullableType = 295, + JSDocNonNullableType = 296, + JSDocOptionalType = 297, + JSDocFunctionType = 298, + JSDocVariadicType = 299, + JSDocNamepathType = 300, + JSDocComment = 301, + JSDocTypeLiteral = 302, + JSDocSignature = 303, + JSDocTag = 304, + JSDocAugmentsTag = 305, + JSDocAuthorTag = 306, + JSDocClassTag = 307, + JSDocCallbackTag = 308, + JSDocEnumTag = 309, + JSDocParameterTag = 310, + JSDocReturnTag = 311, + JSDocThisTag = 312, + JSDocTypeTag = 313, + JSDocTemplateTag = 314, + JSDocTypedefTag = 315, + JSDocPropertyTag = 316, + SyntaxList = 317, + NotEmittedStatement = 318, + PartiallyEmittedExpression = 319, + CommaListExpression = 320, + MergeDeclarationMarker = 321, + EndOfDeclarationMarker = 322, + SyntheticReferenceExpression = 323, + Count = 324, + FirstAssignment = 62, + LastAssignment = 74, + FirstCompoundAssignment = 63, + LastCompoundAssignment = 74, + FirstReservedWord = 76, + LastReservedWord = 111, + FirstKeyword = 76, + LastKeyword = 151, + FirstFutureReservedWord = 112, + LastFutureReservedWord = 120, + FirstTypeNode = 167, + LastTypeNode = 187, FirstPunctuation = 18, - LastPunctuation = 72, + LastPunctuation = 74, FirstToken = 0, - LastToken = 148, + LastToken = 151, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, LastLiteralToken = 14, FirstTemplateToken = 14, LastTemplateToken = 17, - FirstBinaryOperator = 28, - LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 312, - FirstJSDocTagNode = 300, - LastJSDocTagNode = 312, - } - enum NodeFlags { + FirstBinaryOperator = 29, + LastBinaryOperator = 74, + FirstStatement = 224, + LastStatement = 240, + FirstNode = 152, + FirstJSDocNode = 292, + LastJSDocNode = 316, + FirstJSDocTagNode = 304, + LastJSDocTagNode = 316, + } + export enum NodeFlags { None = 0, Let = 1, Const = 2, NestedNamespace = 4, Synthesized = 8, Namespace = 16, - ExportContext = 32, - ContainsThis = 64, - HasImplicitReturn = 128, - HasExplicitReturn = 256, - GlobalAugmentation = 512, - HasAsyncFunctions = 1024, - DisallowInContext = 2048, - YieldContext = 4096, - DecoratorContext = 8192, - AwaitContext = 16384, - ThisNodeHasError = 32768, - JavaScriptFile = 65536, - ThisNodeOrAnySubNodesHasError = 131072, - HasAggregatedChildData = 262144, - JSDoc = 2097152, - JsonFile = 16777216, + OptionalChain = 32, + ExportContext = 64, + ContainsThis = 128, + HasImplicitReturn = 256, + HasExplicitReturn = 512, + GlobalAugmentation = 1024, + HasAsyncFunctions = 2048, + DisallowInContext = 4096, + YieldContext = 8192, + DecoratorContext = 16384, + AwaitContext = 32768, + ThisNodeHasError = 65536, + JavaScriptFile = 131072, + ThisNodeOrAnySubNodesHasError = 262144, + HasAggregatedChildData = 524288, + JSDoc = 4194304, + JsonFile = 33554432, BlockScoped = 3, - ReachabilityCheckFlags = 384, - ReachabilityAndEmitFlags = 1408, - ContextFlags = 12679168, - TypeExcludesFlags = 20480, + ReachabilityCheckFlags = 768, + ReachabilityAndEmitFlags = 2816, + ContextFlags = 25358336, + TypeExcludesFlags = 40960, } - enum ModifierFlags { + export enum ModifierFlags { None = 0, Export = 1, Ambient = 2, @@ -477,7 +485,7 @@ declare namespace ts { ExportDefault = 513, All = 3071 } - enum JsxFlags { + export enum JsxFlags { None = 0, /** An element from a named property of the JSX.IntrinsicElements interface */ IntrinsicNamedElement = 1, @@ -485,40 +493,43 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3 } - interface Node extends TextRange { + export interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; decorators?: NodeArray; modifiers?: ModifiersArray; parent: Node; } - interface JSDocContainer { + export interface JSDocContainer { } - type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; - type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; - type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; - type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; - interface NodeArray extends ReadonlyArray, TextRange { + export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; + export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; + export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; + export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; + export interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; } - interface Token extends Node { + export interface Token extends Node { kind: TKind; } - type DotDotDotToken = Token; - type QuestionToken = Token; - type ExclamationToken = Token; - type ColonToken = Token; - type EqualsToken = Token; - type AsteriskToken = Token; - type EqualsGreaterThanToken = Token; - type EndOfFileToken = Token & JSDocContainer; - type ReadonlyToken = Token; - type AwaitKeywordToken = Token; - type PlusToken = Token; - type MinusToken = Token; - type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; - type ModifiersArray = NodeArray; - interface Identifier extends PrimaryExpression, Declaration { + export type DotToken = Token; + export type DotDotDotToken = Token; + export type QuestionToken = Token; + export type QuestionDotToken = Token; + export type ExclamationToken = Token; + export type ColonToken = Token; + export type EqualsToken = Token; + export type AsteriskToken = Token; + export type EqualsGreaterThanToken = Token; + export type EndOfFileToken = Token & JSDocContainer; + export type ReadonlyToken = Token; + export type AwaitKeywordToken = Token; + export type PlusToken = Token; + export type MinusToken = Token; + export type AssertsToken = Token; + export type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; + export type ModifiersArray = NodeArray; + export interface Identifier extends PrimaryExpression, Declaration { kind: SyntaxKind.Identifier; /** * Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.) @@ -528,37 +539,37 @@ declare namespace ts { originalKeywordKind?: SyntaxKind; isInJSDocNamespace?: boolean; } - interface TransientIdentifier extends Identifier { + export interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } - interface QualifiedName extends Node { + export interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } - type EntityName = Identifier | QualifiedName; - type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; - interface Declaration extends Node { + export type EntityName = Identifier | QualifiedName; + export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; + export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression; + export interface Declaration extends Node { _declarationBrand: any; } - interface NamedDeclaration extends Declaration { + export interface NamedDeclaration extends Declaration { name?: DeclarationName; } - interface DeclarationStatement extends NamedDeclaration, Statement { + export interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } - interface ComputedPropertyName extends Node { + export interface ComputedPropertyName extends Node { parent: Declaration; kind: SyntaxKind.ComputedPropertyName; expression: Expression; } - interface Decorator extends Node { + export interface Decorator extends Node { kind: SyntaxKind.Decorator; parent: NamedDeclaration; expression: LeftHandSideExpression; } - interface TypeParameterDeclaration extends NamedDeclaration { + export interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; parent: DeclarationWithTypeParameterChildren | InferTypeNode; name: Identifier; @@ -567,22 +578,22 @@ declare namespace ts { default?: TypeNode; expression?: Expression; } - interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { + export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; type?: TypeNode; } - type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; - interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; + export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } - interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } - type BindingName = Identifier | BindingPattern; - interface VariableDeclaration extends NamedDeclaration { + export type BindingName = Identifier | BindingPattern; + export interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; parent: VariableDeclarationList | CatchClause; name: BindingName; @@ -590,12 +601,12 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface VariableDeclarationList extends Node { + export interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; parent: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } - interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { + export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; @@ -604,7 +615,7 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface BindingElement extends NamedDeclaration { + export interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; parent: BindingPattern; propertyName?: PropertyName; @@ -612,14 +623,14 @@ declare namespace ts { name: BindingName; initializer?: Expression; } - interface PropertySignature extends TypeElement, JSDocContainer { + export interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } - interface PropertyDeclaration extends ClassElement, JSDocContainer { + export interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; parent: ClassLikeDeclaration; name: PropertyName; @@ -628,20 +639,20 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface ObjectLiteralElement extends NamedDeclaration { + export interface ObjectLiteralElement extends NamedDeclaration { _objectLiteralBrand: any; name?: PropertyName; } /** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */ - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; - interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; + export interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; initializer: Expression; } - interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; @@ -650,27 +661,27 @@ declare namespace ts { equalsToken?: Token; objectAssignmentInitializer?: Expression; } - interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { + export interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } - type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; - interface PropertyLikeDeclaration extends NamedDeclaration { + export type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; + export interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; } - interface ObjectBindingPattern extends Node { + export interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - interface ArrayBindingPattern extends Node { + export interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; - type ArrayBindingElement = BindingElement | OmittedExpression; + export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; + export type ArrayBindingElement = BindingElement | OmittedExpression; /** * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclarationBase. @@ -679,298 +690,299 @@ declare namespace ts { * - MethodDeclaration * - AccessorDeclaration */ - interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { + export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; exclamationToken?: ExclamationToken; body?: Block | Expression; } - type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; + export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; /** @deprecated Use SignatureDeclaration */ - type FunctionLike = SignatureDeclaration; - interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { + export type FunctionLike = SignatureDeclaration; + export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.FunctionDeclaration; name?: Identifier; body?: FunctionBody; } - interface MethodSignature extends SignatureDeclarationBase, TypeElement { + export interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; parent: ObjectTypeDeclaration; name: PropertyName; } - interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { + export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent: ClassLikeDeclaration; body?: FunctionBody; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ - interface SemicolonClassElement extends ClassElement { + export interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; parent: ClassLikeDeclaration; } - interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { + export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; + export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent: ObjectTypeDeclaration; } - interface TypeNode extends Node { + export interface TypeNode extends Node { _typeNodeBrand: any; } - interface KeywordTypeNode extends TypeNode { + export interface KeywordTypeNode extends TypeNode { 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 { + export interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; } - interface ThisTypeNode extends TypeNode { + export interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } - type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { + export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; + export interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; type: TypeNode; } - interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.ConstructorType; } - interface NodeWithTypeArguments extends TypeNode { + export interface NodeWithTypeArguments extends TypeNode { typeArguments?: NodeArray; } - type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; - interface TypeReferenceNode extends NodeWithTypeArguments { + export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; + export interface TypeReferenceNode extends NodeWithTypeArguments { kind: SyntaxKind.TypeReference; typeName: EntityName; } - interface TypePredicateNode extends TypeNode { + export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; + assertsModifier?: AssertsToken; parameterName: Identifier | ThisTypeNode; - type: TypeNode; + type?: TypeNode; } - interface TypeQueryNode extends TypeNode { + export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; exprName: EntityName; } - interface TypeLiteralNode extends TypeNode, Declaration { + export interface TypeLiteralNode extends TypeNode, Declaration { kind: SyntaxKind.TypeLiteral; members: NodeArray; } - interface ArrayTypeNode extends TypeNode { + export interface ArrayTypeNode extends TypeNode { kind: SyntaxKind.ArrayType; elementType: TypeNode; } - interface TupleTypeNode extends TypeNode { + export interface TupleTypeNode extends TypeNode { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } - interface OptionalTypeNode extends TypeNode { + export interface OptionalTypeNode extends TypeNode { kind: SyntaxKind.OptionalType; type: TypeNode; } - interface RestTypeNode extends TypeNode { + export interface RestTypeNode extends TypeNode { kind: SyntaxKind.RestType; type: TypeNode; } - type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; - interface UnionTypeNode extends TypeNode { + export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; + export interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; types: NodeArray; } - interface IntersectionTypeNode extends TypeNode { + export interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; types: NodeArray; } - interface ConditionalTypeNode extends TypeNode { + export interface ConditionalTypeNode extends TypeNode { kind: SyntaxKind.ConditionalType; checkType: TypeNode; extendsType: TypeNode; trueType: TypeNode; falseType: TypeNode; } - interface InferTypeNode extends TypeNode { + export interface InferTypeNode extends TypeNode { kind: SyntaxKind.InferType; typeParameter: TypeParameterDeclaration; } - interface ParenthesizedTypeNode extends TypeNode { + export interface ParenthesizedTypeNode extends TypeNode { kind: SyntaxKind.ParenthesizedType; type: TypeNode; } - interface TypeOperatorNode extends TypeNode { + export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword; type: TypeNode; } - interface IndexedAccessTypeNode extends TypeNode { + export interface IndexedAccessTypeNode extends TypeNode { kind: SyntaxKind.IndexedAccessType; objectType: TypeNode; indexType: TypeNode; } - interface MappedTypeNode extends TypeNode, Declaration { + export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; readonlyToken?: ReadonlyToken | PlusToken | MinusToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken | PlusToken | MinusToken; type?: TypeNode; } - interface LiteralTypeNode extends TypeNode { + export interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - interface StringLiteral extends LiteralExpression { + export interface StringLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.StringLiteral; } - type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; - interface Expression extends Node { + export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; + export interface Expression extends Node { _expressionBrand: any; } - interface OmittedExpression extends Expression { + export interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } - interface PartiallyEmittedExpression extends LeftHandSideExpression { + export interface PartiallyEmittedExpression extends LeftHandSideExpression { kind: SyntaxKind.PartiallyEmittedExpression; expression: Expression; } - interface UnaryExpression extends Expression { + export interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } /** Deprecated, please use UpdateExpression */ - type IncrementExpression = UpdateExpression; - interface UpdateExpression extends UnaryExpression { + export type IncrementExpression = UpdateExpression; + export interface UpdateExpression extends UnaryExpression { _updateExpressionBrand: any; } - type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; - interface PrefixUnaryExpression extends UpdateExpression { + export type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; + export interface PrefixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: PrefixUnaryOperator; operand: UnaryExpression; } - type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; - interface PostfixUnaryExpression extends UpdateExpression { + export type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; + export interface PostfixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface LeftHandSideExpression extends UpdateExpression { + export interface LeftHandSideExpression extends UpdateExpression { _leftHandSideExpressionBrand: any; } - interface MemberExpression extends LeftHandSideExpression { + export interface MemberExpression extends LeftHandSideExpression { _memberExpressionBrand: any; } - interface PrimaryExpression extends MemberExpression { + export interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } - interface NullLiteral extends PrimaryExpression, TypeNode { + export interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } - interface BooleanLiteral extends PrimaryExpression, TypeNode { + export interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - interface ThisExpression extends PrimaryExpression, KeywordTypeNode { + export interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } - interface SuperExpression extends PrimaryExpression { + export interface SuperExpression extends PrimaryExpression { kind: SyntaxKind.SuperKeyword; } - interface ImportExpression extends PrimaryExpression { + export interface ImportExpression extends PrimaryExpression { kind: SyntaxKind.ImportKeyword; } - interface DeleteExpression extends UnaryExpression { + export interface DeleteExpression extends UnaryExpression { kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; } - interface TypeOfExpression extends UnaryExpression { + export interface TypeOfExpression extends UnaryExpression { kind: SyntaxKind.TypeOfExpression; expression: UnaryExpression; } - interface VoidExpression extends UnaryExpression { + export interface VoidExpression extends UnaryExpression { kind: SyntaxKind.VoidExpression; expression: UnaryExpression; } - interface AwaitExpression extends UnaryExpression { + export interface AwaitExpression extends UnaryExpression { kind: SyntaxKind.AwaitExpression; expression: UnaryExpression; } - interface YieldExpression extends Expression { + export interface YieldExpression extends Expression { kind: SyntaxKind.YieldExpression; asteriskToken?: AsteriskToken; expression?: Expression; } - interface SyntheticExpression extends Expression { + export interface SyntheticExpression extends Expression { kind: SyntaxKind.SyntheticExpression; isSpread: boolean; type: Type; } - type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; - type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; - type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; - type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; - type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; - type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; - type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; - type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; - type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; - type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; - type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; - type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; - type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; - type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; - type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; - type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; - type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; - type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; - type BinaryOperatorToken = Token; - interface BinaryExpression extends Expression, Declaration { + export type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; + export type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; + export type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; + export type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; + export type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; + export type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; + export type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; + export type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; + export type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; + export type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; + export type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; + export type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; + export type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; + export type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; + export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; + export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; + export type AssignmentOperatorOrHigher = SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | AssignmentOperator; + export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; + export type BinaryOperatorToken = Token; + export interface BinaryExpression extends Expression, Declaration { kind: SyntaxKind.BinaryExpression; left: Expression; operatorToken: BinaryOperatorToken; right: Expression; } - type AssignmentOperatorToken = Token; - interface AssignmentExpression extends BinaryExpression { + export type AssignmentOperatorToken = Token; + export interface AssignmentExpression extends BinaryExpression { left: LeftHandSideExpression; operatorToken: TOperator; } - interface ObjectDestructuringAssignment extends AssignmentExpression { + export interface ObjectDestructuringAssignment extends AssignmentExpression { left: ObjectLiteralExpression; } - interface ArrayDestructuringAssignment extends AssignmentExpression { + export interface ArrayDestructuringAssignment extends AssignmentExpression { left: ArrayLiteralExpression; } - type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; - type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; - type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; - type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; - type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; - type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; - type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; - type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; - interface ConditionalExpression extends Expression { + export type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; + export type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; + export type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; + export type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; + export type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; + export type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; + export type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; + export type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; + export interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; questionToken: QuestionToken; @@ -978,34 +990,37 @@ declare namespace ts { colonToken: ColonToken; whenFalse: Expression; } - type FunctionBody = Block; - type ConciseBody = FunctionBody | Expression; - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { + export type FunctionBody = Block; + export type ConciseBody = FunctionBody | Expression; + export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } - interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { + export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; name: never; } - interface LiteralLikeNode extends Node { + export interface LiteralLikeNode extends Node { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; } - interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { + export interface TemplateLiteralLikeNode extends LiteralLikeNode { + rawText?: string; + } + export interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; } - interface RegularExpressionLiteral extends LiteralExpression { + export interface RegularExpressionLiteral extends LiteralExpression { kind: SyntaxKind.RegularExpressionLiteral; } - interface NoSubstitutionTemplateLiteral extends LiteralExpression { + export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode, Declaration { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } - enum TokenFlags { + export enum TokenFlags { None = 0, Scientific = 16, Octal = 32, @@ -1013,45 +1028,45 @@ declare namespace ts { BinarySpecifier = 128, OctalSpecifier = 256, } - interface NumericLiteral extends LiteralExpression { + export interface NumericLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.NumericLiteral; } - interface BigIntLiteral extends LiteralExpression { + export interface BigIntLiteral extends LiteralExpression { kind: SyntaxKind.BigIntLiteral; } - interface TemplateHead extends LiteralLikeNode { + export interface TemplateHead extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateHead; parent: TemplateExpression; } - interface TemplateMiddle extends LiteralLikeNode { + export interface TemplateMiddle extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateMiddle; parent: TemplateSpan; } - interface TemplateTail extends LiteralLikeNode { + export interface TemplateTail extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateTail; parent: TemplateSpan; } - type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; - interface TemplateExpression extends PrimaryExpression { + export type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; + export interface TemplateExpression extends PrimaryExpression { kind: SyntaxKind.TemplateExpression; head: TemplateHead; templateSpans: NodeArray; } - interface TemplateSpan extends Node { + export interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; parent: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } - interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { + export interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } - interface ArrayLiteralExpression extends PrimaryExpression { + export interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; } - interface SpreadElement extends Expression { + export interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; parent: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; @@ -1062,413 +1077,426 @@ declare namespace ts { * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) */ - interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { + export interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { properties: NodeArray; } - interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { + export interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; } - type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; - type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; - interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { + export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; + export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; name: Identifier; } - interface SuperPropertyAccessExpression extends PropertyAccessExpression { + export interface PropertyAccessChain extends PropertyAccessExpression { + _optionalChainBrand: any; + } + export interface SuperPropertyAccessExpression extends PropertyAccessExpression { expression: SuperExpression; } /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ - interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { + export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { _propertyAccessExpressionLikeQualifiedNameBrand?: any; expression: EntityNameExpression; } - interface ElementAccessExpression extends MemberExpression { + export interface ElementAccessExpression extends MemberExpression { kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; argumentExpression: Expression; } - interface SuperElementAccessExpression extends ElementAccessExpression { + export interface ElementAccessChain extends ElementAccessExpression { + _optionalChainBrand: any; + } + export interface SuperElementAccessExpression extends ElementAccessExpression { expression: SuperExpression; } - type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; - interface CallExpression extends LeftHandSideExpression, Declaration { + export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; + export interface CallExpression extends LeftHandSideExpression, Declaration { kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; typeArguments?: NodeArray; arguments: NodeArray; } - interface SuperCall extends CallExpression { + export interface CallChain extends CallExpression { + _optionalChainBrand: any; + } + export type OptionalChain = PropertyAccessChain | ElementAccessChain | CallChain; + export interface SuperCall extends CallExpression { expression: SuperExpression; } - interface ImportCall extends CallExpression { + export interface ImportCall extends CallExpression { expression: ImportExpression; } - interface ExpressionWithTypeArguments extends NodeWithTypeArguments { + export interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; parent: HeritageClause | JSDocAugmentsTag; expression: LeftHandSideExpression; } - interface NewExpression extends PrimaryExpression, Declaration { + export interface NewExpression extends PrimaryExpression, Declaration { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments?: NodeArray; } - interface TaggedTemplateExpression extends MemberExpression { + export interface TaggedTemplateExpression extends MemberExpression { kind: SyntaxKind.TaggedTemplateExpression; tag: LeftHandSideExpression; typeArguments?: NodeArray; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; - interface AsExpression extends Expression { + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; + export interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; type: TypeNode; } - interface TypeAssertion extends UnaryExpression { + export interface TypeAssertion extends UnaryExpression { kind: SyntaxKind.TypeAssertionExpression; type: TypeNode; expression: UnaryExpression; } - type AssertionExpression = TypeAssertion | AsExpression; - interface NonNullExpression extends LeftHandSideExpression { + export type AssertionExpression = TypeAssertion | AsExpression; + export interface NonNullExpression extends LeftHandSideExpression { kind: SyntaxKind.NonNullExpression; expression: Expression; } - interface MetaProperty extends PrimaryExpression { + export interface MetaProperty extends PrimaryExpression { kind: SyntaxKind.MetaProperty; keywordToken: SyntaxKind.NewKeyword | SyntaxKind.ImportKeyword; name: Identifier; } - interface JsxElement extends PrimaryExpression { + export interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; - interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; + export type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + export interface JsxTagNamePropertyAccess extends PropertyAccessExpression { expression: JsxTagNameExpression; } - interface JsxAttributes extends ObjectLiteralExpressionBase { + export interface JsxAttributes extends ObjectLiteralExpressionBase { kind: SyntaxKind.JsxAttributes; parent: JsxOpeningLikeElement; } - interface JsxOpeningElement extends Expression { + export interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; parent: JsxElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxSelfClosingElement extends PrimaryExpression { + export interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxFragment extends PrimaryExpression { + export interface JsxFragment extends PrimaryExpression { kind: SyntaxKind.JsxFragment; openingFragment: JsxOpeningFragment; children: NodeArray; closingFragment: JsxClosingFragment; } - interface JsxOpeningFragment extends Expression { + export interface JsxOpeningFragment extends Expression { kind: SyntaxKind.JsxOpeningFragment; parent: JsxFragment; } - interface JsxClosingFragment extends Expression { + export interface JsxClosingFragment extends Expression { kind: SyntaxKind.JsxClosingFragment; parent: JsxFragment; } - interface JsxAttribute extends ObjectLiteralElement { + export interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; parent: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends ObjectLiteralElement { + export interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; parent: JsxAttributes; expression: Expression; } - interface JsxClosingElement extends Node { + export interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; parent: JsxElement; tagName: JsxTagNameExpression; } - interface JsxExpression extends Expression { + export interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; parent: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } - interface JsxText extends LiteralLikeNode { + export interface JsxText extends LiteralLikeNode { kind: SyntaxKind.JsxText; containsOnlyTriviaWhiteSpaces: boolean; parent: JsxElement; } - type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; - interface Statement extends Node { + export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; + export interface Statement extends Node { _statementBrand: any; } - interface NotEmittedStatement extends Statement { + export interface NotEmittedStatement extends Statement { kind: SyntaxKind.NotEmittedStatement; } /** * A list of comma-separated expressions. This node is only created by transformations. */ - interface CommaListExpression extends Expression { + export interface CommaListExpression extends Expression { kind: SyntaxKind.CommaListExpression; elements: NodeArray; } - interface EmptyStatement extends Statement { + export interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } - interface DebuggerStatement extends Statement { + export interface DebuggerStatement extends Statement { kind: SyntaxKind.DebuggerStatement; } - interface MissingDeclaration extends DeclarationStatement { + export interface MissingDeclaration extends DeclarationStatement { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; - interface Block extends Statement { + export type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; + export interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; } - interface VariableStatement extends Statement, JSDocContainer { + export interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } - interface ExpressionStatement extends Statement, JSDocContainer { + export interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } - interface IfStatement extends Statement { + export interface IfStatement extends Statement { kind: SyntaxKind.IfStatement; expression: Expression; thenStatement: Statement; elseStatement?: Statement; } - interface IterationStatement extends Statement { + export interface IterationStatement extends Statement { statement: Statement; } - interface DoStatement extends IterationStatement { + export interface DoStatement extends IterationStatement { kind: SyntaxKind.DoStatement; expression: Expression; } - interface WhileStatement extends IterationStatement { + export interface WhileStatement extends IterationStatement { kind: SyntaxKind.WhileStatement; expression: Expression; } - type ForInitializer = VariableDeclarationList | Expression; - interface ForStatement extends IterationStatement { + export type ForInitializer = VariableDeclarationList | Expression; + export interface ForStatement extends IterationStatement { kind: SyntaxKind.ForStatement; initializer?: ForInitializer; condition?: Expression; incrementor?: Expression; } - type ForInOrOfStatement = ForInStatement | ForOfStatement; - interface ForInStatement extends IterationStatement { + export type ForInOrOfStatement = ForInStatement | ForOfStatement; + export interface ForInStatement extends IterationStatement { kind: SyntaxKind.ForInStatement; initializer: ForInitializer; expression: Expression; } - interface ForOfStatement extends IterationStatement { + export interface ForOfStatement extends IterationStatement { kind: SyntaxKind.ForOfStatement; awaitModifier?: AwaitKeywordToken; initializer: ForInitializer; expression: Expression; } - interface BreakStatement extends Statement { + export interface BreakStatement extends Statement { kind: SyntaxKind.BreakStatement; label?: Identifier; } - interface ContinueStatement extends Statement { + export interface ContinueStatement extends Statement { kind: SyntaxKind.ContinueStatement; label?: Identifier; } - type BreakOrContinueStatement = BreakStatement | ContinueStatement; - interface ReturnStatement extends Statement { + export type BreakOrContinueStatement = BreakStatement | ContinueStatement; + export interface ReturnStatement extends Statement { kind: SyntaxKind.ReturnStatement; expression?: Expression; } - interface WithStatement extends Statement { + export interface WithStatement extends Statement { kind: SyntaxKind.WithStatement; expression: Expression; statement: Statement; } - interface SwitchStatement extends Statement { + export interface SwitchStatement extends Statement { kind: SyntaxKind.SwitchStatement; expression: Expression; caseBlock: CaseBlock; possiblyExhaustive?: boolean; } - interface CaseBlock extends Node { + export interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; parent: SwitchStatement; clauses: NodeArray; } - interface CaseClause extends Node { + export interface CaseClause extends Node { kind: SyntaxKind.CaseClause; parent: CaseBlock; expression: Expression; statements: NodeArray; } - interface DefaultClause extends Node { + export interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; parent: CaseBlock; statements: NodeArray; } - type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement, JSDocContainer { + export type CaseOrDefaultClause = CaseClause | DefaultClause; + export interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; } - interface ThrowStatement extends Statement { + export interface ThrowStatement extends Statement { kind: SyntaxKind.ThrowStatement; expression?: Expression; } - interface TryStatement extends Statement { + export interface TryStatement extends Statement { kind: SyntaxKind.TryStatement; tryBlock: Block; catchClause?: CatchClause; finallyBlock?: Block; } - interface CatchClause extends Node { + export interface CatchClause extends Node { kind: SyntaxKind.CatchClause; parent: TryStatement; variableDeclaration?: VariableDeclaration; block: Block; } - type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; - type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; - interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { + export type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; + export type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + export type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; + export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { + export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; /** May be undefined in `export default class { ... }`. */ name?: Identifier; } - interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { + export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } - type ClassLikeDeclaration = ClassDeclaration | ClassExpression; - interface ClassElement extends NamedDeclaration { + export type ClassLikeDeclaration = ClassDeclaration | ClassExpression; + export interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; } - interface TypeElement extends NamedDeclaration { + export interface TypeElement extends NamedDeclaration { _typeElementBrand: any; name?: PropertyName; questionToken?: QuestionToken; } - interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { + export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface HeritageClause extends Node { + export interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; parent: InterfaceDeclaration | ClassLikeDeclaration; token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } - interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { + export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } - interface EnumMember extends NamedDeclaration, JSDocContainer { + export interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent: EnumDeclaration; name: PropertyName; initializer?: Expression; } - interface EnumDeclaration extends DeclarationStatement, JSDocContainer { + export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } - type ModuleName = Identifier | StringLiteral; - type ModuleBody = NamespaceBody | JSDocNamespaceBody; - interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { + export type ModuleName = Identifier | StringLiteral; + export type ModuleBody = NamespaceBody | JSDocNamespaceBody; + export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent: ModuleBody | SourceFile; name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration; } - type NamespaceBody = ModuleBlock | NamespaceDeclaration; - interface NamespaceDeclaration extends ModuleDeclaration { + export type NamespaceBody = ModuleBlock | NamespaceDeclaration; + export interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; body: NamespaceBody; } - type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; - interface JSDocNamespaceDeclaration extends ModuleDeclaration { + export type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; + export interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; body?: JSDocNamespaceBody; } - interface ModuleBlock extends Node, Statement { + export interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; parent: ModuleDeclaration; statements: NodeArray; } - type ModuleReference = EntityName | ExternalModuleReference; + export type ModuleReference = EntityName | ExternalModuleReference; /** * One of: * - import x = require("mod"); * - import x = M.x; */ - interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { + export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } - interface ExternalModuleReference extends Node { + export interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; parent: ImportEqualsDeclaration; expression: Expression; } - interface ImportDeclaration extends Statement { + export interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; parent: SourceFile | ModuleBlock; importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; } - type NamedImportBindings = NamespaceImport | NamedImports; - interface ImportClause extends NamedDeclaration { + export type NamedImportBindings = NamespaceImport | NamedImports; + export interface ImportClause extends NamedDeclaration { kind: SyntaxKind.ImportClause; parent: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } - interface NamespaceImport extends NamedDeclaration { + export interface NamespaceImport extends NamedDeclaration { kind: SyntaxKind.NamespaceImport; parent: ImportClause; name: Identifier; } - interface NamespaceExportDeclaration extends DeclarationStatement { + export interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; } - interface ExportDeclaration extends DeclarationStatement, JSDocContainer { + export interface ExportDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ExportDeclaration; parent: SourceFile | ModuleBlock; /** Will not be assigned in the case of `export * from "foo";` */ @@ -1476,161 +1504,166 @@ declare namespace ts { /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier?: Expression; } - interface NamedImports extends Node { + export interface NamedImports extends Node { kind: SyntaxKind.NamedImports; parent: ImportClause; elements: NodeArray; } - interface NamedExports extends Node { + export interface NamedExports extends Node { kind: SyntaxKind.NamedExports; parent: ExportDeclaration; elements: NodeArray; } - type NamedImportsOrExports = NamedImports | NamedExports; - interface ImportSpecifier extends NamedDeclaration { + export type NamedImportsOrExports = NamedImports | NamedExports; + export interface ImportSpecifier extends NamedDeclaration { kind: SyntaxKind.ImportSpecifier; parent: NamedImports; propertyName?: Identifier; name: Identifier; } - interface ExportSpecifier extends NamedDeclaration { + export interface ExportSpecifier extends NamedDeclaration { kind: SyntaxKind.ExportSpecifier; parent: NamedExports; propertyName?: Identifier; name: Identifier; } - type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; + export type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; /** * This is either an `export =` or an `export default` declaration. * Unless `isExportEquals` is set, this node was parsed as an `export default`. */ - interface ExportAssignment extends DeclarationStatement { + export interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; parent: SourceFile; isExportEquals?: boolean; expression: Expression; } - interface FileReference extends TextRange { + export interface FileReference extends TextRange { fileName: string; } - interface CheckJsDirective extends TextRange { + export interface CheckJsDirective extends TextRange { enabled: boolean; } - type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; - interface CommentRange extends TextRange { + export type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; + export interface CommentRange extends TextRange { hasTrailingNewLine?: boolean; kind: CommentKind; } - interface SynthesizedComment extends CommentRange { + export interface SynthesizedComment extends CommentRange { text: string; pos: -1; end: -1; } - interface JSDocTypeExpression extends TypeNode { + export interface JSDocTypeExpression extends TypeNode { kind: SyntaxKind.JSDocTypeExpression; type: TypeNode; } - interface JSDocType extends TypeNode { + export interface JSDocType extends TypeNode { _jsDocTypeBrand: any; } - interface JSDocAllType extends JSDocType { + export interface JSDocAllType extends JSDocType { kind: SyntaxKind.JSDocAllType; } - interface JSDocUnknownType extends JSDocType { + export interface JSDocUnknownType extends JSDocType { kind: SyntaxKind.JSDocUnknownType; } - interface JSDocNonNullableType extends JSDocType { + export interface JSDocNonNullableType extends JSDocType { kind: SyntaxKind.JSDocNonNullableType; type: TypeNode; } - interface JSDocNullableType extends JSDocType { + export interface JSDocNullableType extends JSDocType { kind: SyntaxKind.JSDocNullableType; type: TypeNode; } - interface JSDocOptionalType extends JSDocType { + export interface JSDocOptionalType extends JSDocType { kind: SyntaxKind.JSDocOptionalType; type: TypeNode; } - interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { + export interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { kind: SyntaxKind.JSDocFunctionType; } - interface JSDocVariadicType extends JSDocType { + export interface JSDocVariadicType extends JSDocType { kind: SyntaxKind.JSDocVariadicType; type: TypeNode; } - type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; - interface JSDoc extends Node { + export interface JSDocNamepathType extends JSDocType { + kind: SyntaxKind.JSDocNamepathType; + type: TypeNode; + } + export type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; + export interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; parent: HasJSDoc; tags?: NodeArray; comment?: string; } - interface JSDocTag extends Node { + export interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; tagName: Identifier; comment?: string; } - interface JSDocUnknownTag extends JSDocTag { + export interface JSDocUnknownTag extends JSDocTag { kind: SyntaxKind.JSDocTag; } /** * Note that `@extends` is a synonym of `@augments`. * Both tags are represented by this interface. */ - interface JSDocAugmentsTag extends JSDocTag { + export interface JSDocAugmentsTag extends JSDocTag { kind: SyntaxKind.JSDocAugmentsTag; class: ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression; }; } - interface JSDocAuthorTag extends JSDocTag { + export interface JSDocAuthorTag extends JSDocTag { kind: SyntaxKind.JSDocAuthorTag; } - interface JSDocClassTag extends JSDocTag { + export interface JSDocClassTag extends JSDocTag { kind: SyntaxKind.JSDocClassTag; } - interface JSDocEnumTag extends JSDocTag { + export interface JSDocEnumTag extends JSDocTag, Declaration { + parent: JSDoc; kind: SyntaxKind.JSDocEnumTag; typeExpression?: JSDocTypeExpression; } - interface JSDocThisTag extends JSDocTag { + export interface JSDocThisTag extends JSDocTag { kind: SyntaxKind.JSDocThisTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTemplateTag extends JSDocTag { + export interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; constraint: JSDocTypeExpression | undefined; typeParameters: NodeArray; } - interface JSDocReturnTag extends JSDocTag { + export interface JSDocReturnTag extends JSDocTag { kind: SyntaxKind.JSDocReturnTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTypeTag extends JSDocTag { + export interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; typeExpression: JSDocTypeExpression; } - interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { + export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocTypedefTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression?: JSDocTypeExpression | JSDocTypeLiteral; } - interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { + export interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocCallbackTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression: JSDocSignature; } - interface JSDocSignature extends JSDocType, Declaration { + export interface JSDocSignature extends JSDocType, Declaration { kind: SyntaxKind.JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly JSDocTemplateTag[]; + parameters: readonly JSDocParameterTag[]; type: JSDocReturnTag | undefined; } - interface JSDocPropertyLikeTag extends JSDocTag, Declaration { + export interface JSDocPropertyLikeTag extends JSDocTag, Declaration { parent: JSDoc; name: EntityName; typeExpression?: JSDocTypeExpression; @@ -1638,19 +1671,19 @@ declare namespace ts { isNameFirst: boolean; isBracketed: boolean; } - interface JSDocPropertyTag extends JSDocPropertyLikeTag { + export interface JSDocPropertyTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocPropertyTag; } - interface JSDocParameterTag extends JSDocPropertyLikeTag { + export interface JSDocParameterTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocParameterTag; } - interface JSDocTypeLiteral extends JSDocType { + export interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; - jsDocPropertyTags?: ReadonlyArray; + jsDocPropertyTags?: readonly JSDocPropertyLikeTag[]; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } - enum FlowFlags { + export enum FlowFlags { Unreachable = 1, Start = 2, BranchLabel = 4, @@ -1660,72 +1693,77 @@ declare namespace ts { FalseCondition = 64, SwitchClause = 128, ArrayMutation = 256, - Referenced = 512, - Shared = 1024, - PreFinally = 2048, - AfterFinally = 4096, + Call = 512, + Referenced = 1024, + Shared = 2048, + PreFinally = 4096, + AfterFinally = 8192, Label = 12, Condition = 96 } - interface FlowLock { + export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation; + export interface FlowNodeBase { + flags: FlowFlags; + id?: number; + } + export interface FlowLock { locked?: boolean; } - interface AfterFinallyFlow extends FlowNodeBase, FlowLock { + export interface AfterFinallyFlow extends FlowNodeBase, FlowLock { antecedent: FlowNode; } - interface PreFinallyFlow extends FlowNodeBase { + export interface PreFinallyFlow extends FlowNodeBase { antecedent: FlowNode; lock: FlowLock; } - type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - interface FlowNodeBase { - flags: FlowFlags; - id?: number; - } - interface FlowStart extends FlowNodeBase { - container?: FunctionExpression | ArrowFunction | MethodDeclaration; + export interface FlowStart extends FlowNodeBase { + node?: FunctionExpression | ArrowFunction | MethodDeclaration; } - interface FlowLabel extends FlowNodeBase { + export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; } - interface FlowAssignment extends FlowNodeBase { + export interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } - interface FlowCondition extends FlowNodeBase { - expression: Expression; + export interface FlowCall extends FlowNodeBase { + node: CallExpression; + antecedent: FlowNode; + } + export interface FlowCondition extends FlowNodeBase { + node: Expression; antecedent: FlowNode; } - interface FlowSwitchClause extends FlowNodeBase { + export interface FlowSwitchClause extends FlowNodeBase { switchStatement: SwitchStatement; clauseStart: number; clauseEnd: number; antecedent: FlowNode; } - interface FlowArrayMutation extends FlowNodeBase { + export interface FlowArrayMutation extends FlowNodeBase { node: CallExpression | BinaryExpression; antecedent: FlowNode; } - type FlowType = Type | IncompleteType; - interface IncompleteType { + export type FlowType = Type | IncompleteType; + export interface IncompleteType { flags: TypeFlags; type: Type; } - interface AmdDependency { + export interface AmdDependency { path: string; name?: string; } - interface SourceFile extends Declaration { + export interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; statements: NodeArray; endOfFileToken: Token; fileName: string; text: string; - amdDependencies: ReadonlyArray; + amdDependencies: readonly AmdDependency[]; moduleName?: string; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray; - libReferenceDirectives: ReadonlyArray; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly FileReference[]; + libReferenceDirectives: readonly FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -1739,12 +1777,12 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } - interface Bundle extends Node { + export interface Bundle extends Node { kind: SyntaxKind.Bundle; - prepends: ReadonlyArray; - sourceFiles: ReadonlyArray; + prepends: readonly (InputFiles | UnparsedSource)[]; + sourceFiles: readonly SourceFile[]; } - interface InputFiles extends Node { + export interface InputFiles extends Node { kind: SyntaxKind.InputFiles; javascriptPath?: string; javascriptText: string; @@ -1755,70 +1793,70 @@ declare namespace ts { declarationMapPath?: string; declarationMapText?: string; } - interface UnparsedSource extends Node { + export interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; fileName: string; text: string; - prologues: ReadonlyArray; - helpers: ReadonlyArray | undefined; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray | undefined; - libReferenceDirectives: ReadonlyArray; + prologues: readonly UnparsedPrologue[]; + helpers: readonly UnscopedEmitHelper[] | undefined; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly string[] | undefined; + libReferenceDirectives: readonly FileReference[]; hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; - syntheticReferences?: ReadonlyArray; - texts: ReadonlyArray; + syntheticReferences?: readonly UnparsedSyntheticReference[]; + texts: readonly UnparsedSourceText[]; } - type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; - type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; - interface UnparsedSection extends Node { + export type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; + export type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; + export interface UnparsedSection extends Node { kind: SyntaxKind; data?: string; parent: UnparsedSource; } - interface UnparsedPrologue extends UnparsedSection { + export interface UnparsedPrologue extends UnparsedSection { kind: SyntaxKind.UnparsedPrologue; data: string; parent: UnparsedSource; } - interface UnparsedPrepend extends UnparsedSection { + export interface UnparsedPrepend extends UnparsedSection { kind: SyntaxKind.UnparsedPrepend; data: string; parent: UnparsedSource; - texts: ReadonlyArray; + texts: readonly UnparsedTextLike[]; } - interface UnparsedTextLike extends UnparsedSection { + export interface UnparsedTextLike extends UnparsedSection { kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; parent: UnparsedSource; } - interface UnparsedSyntheticReference extends UnparsedSection { + export interface UnparsedSyntheticReference extends UnparsedSection { kind: SyntaxKind.UnparsedSyntheticReference; parent: UnparsedSource; } - interface JsonSourceFile extends SourceFile { + export interface JsonSourceFile extends SourceFile { statements: NodeArray; } - interface TsConfigSourceFile extends JsonSourceFile { + export interface TsConfigSourceFile extends JsonSourceFile { extendedSourceFiles?: string[]; } - interface JsonMinusNumericLiteral extends PrefixUnaryExpression { + export interface JsonMinusNumericLiteral extends PrefixUnaryExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: SyntaxKind.MinusToken; operand: NumericLiteral; } - interface JsonObjectExpressionStatement extends ExpressionStatement { + export interface JsonObjectExpressionStatement extends ExpressionStatement { expression: ObjectLiteralExpression | ArrayLiteralExpression | JsonMinusNumericLiteral | NumericLiteral | StringLiteral | BooleanLiteral | NullLiteral; } - interface ScriptReferenceHost { + export interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile | undefined; getSourceFileByPath(path: Path): SourceFile | undefined; getCurrentDirectory(): string; } - interface ParseConfigHost { + export interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; + readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[]; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. @@ -1832,26 +1870,26 @@ declare namespace ts { * specified like "./blah" to an absolute path to an actual * tsconfig file, e.g. "/root/blah/tsconfig.json" */ - type ResolvedConfigFileName = string & { + export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray) => void; - class OperationCanceledException { + export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; + export class OperationCanceledException { } - interface CancellationToken { + export interface CancellationToken { isCancellationRequested(): boolean; /** @throws OperationCanceledException if isCancellationRequested is true */ throwIfCancellationRequested(): void; } - interface Program extends ScriptReferenceHost { + export interface Program extends ScriptReferenceHost { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): ReadonlyArray; + getRootFileNames(): readonly string[]; /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -1863,33 +1901,42 @@ declare namespace ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** The first time this is called, it will return global diagnostics (no location). */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + getRelationCacheSizes(): { + assignable: number; + identity: number; + subtype: number; + }; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; - getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; + getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; } - interface ResolvedProjectReference { + export interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; - references?: ReadonlyArray; + references?: readonly (ResolvedProjectReference | undefined)[]; } - type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; - interface CustomTransformer { + export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; + export interface CustomTransformer { transformSourceFile(node: SourceFile): SourceFile; transformBundle(node: Bundle): Bundle; } - interface CustomTransformers { + export interface CustomTransformers { /** Custom transformers to evaluate before built-in .js transformations. */ before?: (TransformerFactory | CustomTransformerFactory)[]; /** Custom transformers to evaluate after built-in .js transformations. */ @@ -1897,7 +1944,7 @@ declare namespace ts { /** Custom transformers to evaluate after built-in .d.ts transformations. */ afterDeclarations?: (TransformerFactory | CustomTransformerFactory)[]; } - interface SourceMapSpan { + export interface SourceMapSpan { /** Line number in the .js file. */ emittedLine: number; /** Column number in the .js file. */ @@ -1912,25 +1959,26 @@ declare namespace ts { sourceIndex: number; } /** Return code used by getEmitOutput function to indicate status of the function */ - enum ExitStatus { + export enum ExitStatus { Success = 0, DiagnosticsPresent_OutputsSkipped = 1, DiagnosticsPresent_OutputsGenerated = 2, - InvalidProject_OutputsSkipped = 3 + InvalidProject_OutputsSkipped = 3, + ProjectReferenceCycle_OutputsSkupped = 4 } - interface EmitResult { + export interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; emittedFiles?: string[]; } - interface TypeChecker { + export interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; + getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1938,6 +1986,7 @@ declare namespace ts { getReturnTypeOfSignature(signature: Signature): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; + getTypeArguments(type: TypeReference): readonly Type[]; /** Note that the resulting nodes cannot be checked. */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ @@ -1984,7 +2033,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): ReadonlyArray; + getRootSymbols(symbol: Symbol): readonly Symbol[]; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -2016,7 +2065,7 @@ declare namespace ts { */ runWithCancellationToken(token: CancellationToken, cb: (checker: TypeChecker) => T): T; } - enum NodeBuilderFlags { + export enum NodeBuilderFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2047,7 +2096,7 @@ declare namespace ts { InInitialEntityName = 16777216, InReverseMappedType = 33554432 } - enum TypeFormatFlags { + export enum TypeFormatFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2070,31 +2119,49 @@ declare namespace ts { /** @deprecated */ WriteOwnNameForAnyLike = 0, NodeBuilderFlagsMask = 9469291 } - enum SymbolFormatFlags { + export enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8, } - enum TypePredicateKind { + export enum TypePredicateKind { This = 0, - Identifier = 1 + Identifier = 1, + AssertsThis = 2, + AssertsIdentifier = 3 } - interface TypePredicateBase { + export interface TypePredicateBase { kind: TypePredicateKind; - type: Type; + type: Type | undefined; } - interface ThisTypePredicate extends TypePredicateBase { + export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; + parameterName: undefined; + parameterIndex: undefined; + type: Type; } - interface IdentifierTypePredicate extends TypePredicateBase { + export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; + type: Type; + } + export interface AssertsThisTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsThis; + parameterName: undefined; + parameterIndex: undefined; + type: Type | undefined; } - type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - enum SymbolFlags { + export interface AssertsIdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsIdentifier; + parameterName: string; + parameterIndex: number; + type: Type | undefined; + } + export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate; + export enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, @@ -2126,28 +2193,28 @@ declare namespace ts { ModuleExports = 134217728, Enum = 384, Variable = 3, - Value = 67220415, - Type = 67897832, + Value = 111551, + Type = 788968, Namespace = 1920, Module = 1536, Accessor = 98304, - FunctionScopedVariableExcludes = 67220414, - BlockScopedVariableExcludes = 67220415, - ParameterExcludes = 67220415, + FunctionScopedVariableExcludes = 111550, + BlockScopedVariableExcludes = 111551, + ParameterExcludes = 111551, PropertyExcludes = 0, - EnumMemberExcludes = 68008959, - FunctionExcludes = 67219887, - ClassExcludes = 68008383, - InterfaceExcludes = 67897736, - RegularEnumExcludes = 68008191, - ConstEnumExcludes = 68008831, + EnumMemberExcludes = 900095, + FunctionExcludes = 110991, + ClassExcludes = 899503, + InterfaceExcludes = 788872, + RegularEnumExcludes = 899327, + ConstEnumExcludes = 899967, ValueModuleExcludes = 110735, NamespaceModuleExcludes = 0, - MethodExcludes = 67212223, - GetAccessorExcludes = 67154879, - SetAccessorExcludes = 67187647, - TypeParameterExcludes = 67635688, - TypeAliasExcludes = 67897832, + MethodExcludes = 103359, + GetAccessorExcludes = 46015, + SetAccessorExcludes = 78783, + TypeParameterExcludes = 526824, + TypeAliasExcludes = 788968, AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, @@ -2155,7 +2222,7 @@ declare namespace ts { PropertyOrAccessor = 98308, ClassMember = 106500, } - interface Symbol { + export interface Symbol { flags: SymbolFlags; escapedName: __String; declarations: Declaration[]; @@ -2164,7 +2231,7 @@ declare namespace ts { exports?: SymbolTable; globalExports?: SymbolTable; } - enum InternalSymbolName { + export enum InternalSymbolName { Call = "__call", Constructor = "__constructor", New = "__new", @@ -2191,13 +2258,13 @@ declare namespace ts { * with a normal string (which is good, it cannot be misused on assignment or on usage), * while still being comparable with a normal string via === (also good) and castable from a string. */ - type __String = (string & { + export type __String = (string & { __escapedIdentifier: void; }) | (void & { __escapedIdentifier: void; }) | InternalSymbolName; /** ReadonlyMap where keys are `__String`s. */ - interface ReadonlyUnderscoreEscapedMap { + export interface ReadonlyUnderscoreEscapedMap { get(key: __String): T | undefined; has(key: __String): boolean; forEach(action: (value: T, key: __String) => void): void; @@ -2207,14 +2274,14 @@ declare namespace ts { entries(): Iterator<[__String, T]>; } /** Map where keys are `__String`s. */ - interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { + export interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { set(key: __String, value: T): this; delete(key: __String): boolean; clear(): void; } /** SymbolTable based on ES6 Map interface. */ - type SymbolTable = UnderscoreEscapedMap; - enum TypeFlags { + export type SymbolTable = UnderscoreEscapedMap; + export enum TypeFlags { Any = 1, Unknown = 2, String = 4, @@ -2263,35 +2330,35 @@ declare namespace ts { Narrowable = 133970943, NotUnionOrUnit = 67637251, } - type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; - interface Type { + export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + export interface Type { flags: TypeFlags; symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: ReadonlyArray; + aliasTypeArguments?: readonly Type[]; } - interface LiteralType extends Type { + export interface LiteralType extends Type { value: string | number | PseudoBigInt; freshType: LiteralType; regularType: LiteralType; } - interface UniqueESSymbolType extends Type { + export interface UniqueESSymbolType extends Type { symbol: Symbol; escapedName: __String; } - interface StringLiteralType extends LiteralType { + export interface StringLiteralType extends LiteralType { value: string; } - interface NumberLiteralType extends LiteralType { + export interface NumberLiteralType extends LiteralType { value: number; } - interface BigIntLiteralType extends LiteralType { + export interface BigIntLiteralType extends LiteralType { value: PseudoBigInt; } - interface EnumType extends Type { + export interface EnumType extends Type { } - enum ObjectFlags { + export enum ObjectFlags { Class = 1, Interface = 2, Reference = 4, @@ -2311,18 +2378,18 @@ declare namespace ts { ArrayLiteral = 65536, ClassOrInterface = 3, } - interface ObjectType extends Type { + export interface ObjectType extends Type { objectFlags: ObjectFlags; } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ - interface InterfaceType extends ObjectType { + export interface InterfaceType extends ObjectType { typeParameters: TypeParameter[] | undefined; outerTypeParameters: TypeParameter[] | undefined; localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; } - type BaseType = ObjectType | IntersectionType; - interface InterfaceTypeWithDeclaredMembers extends InterfaceType { + export type BaseType = ObjectType | IntersectionType | TypeVariable; + export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; @@ -2339,49 +2406,51 @@ declare namespace ts { * if the class or interface has no type parameters and the reference isn't specifying an * explicit "this" argument. */ - interface TypeReference extends ObjectType { + export interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: ReadonlyArray; + node?: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; } - interface GenericType extends InterfaceType, TypeReference { + export interface DeferredTypeReference extends TypeReference { } - interface TupleType extends GenericType { + export interface GenericType extends InterfaceType, TypeReference { + } + export interface TupleType extends GenericType { minLength: number; hasRestElement: boolean; readonly: boolean; associatedNames?: __String[]; } - interface TupleTypeReference extends TypeReference { + export interface TupleTypeReference extends TypeReference { target: TupleType; } - interface UnionOrIntersectionType extends Type { + export interface UnionOrIntersectionType extends Type { types: Type[]; } - interface UnionType extends UnionOrIntersectionType { + export interface UnionType extends UnionOrIntersectionType { } - interface IntersectionType extends UnionOrIntersectionType { + export interface IntersectionType extends UnionOrIntersectionType { } - type StructuredType = ObjectType | UnionType | IntersectionType; - interface EvolvingArrayType extends ObjectType { + export type StructuredType = ObjectType | UnionType | IntersectionType; + export interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; } - interface InstantiableType extends Type { + export interface InstantiableType extends Type { } - interface TypeParameter extends InstantiableType { + export interface TypeParameter extends InstantiableType { } - interface IndexedAccessType extends InstantiableType { + export interface IndexedAccessType extends InstantiableType { objectType: Type; indexType: Type; constraint?: Type; simplifiedForReading?: Type; simplifiedForWriting?: Type; } - type TypeVariable = TypeParameter | IndexedAccessType; - interface IndexType extends InstantiableType { + export type TypeVariable = TypeParameter | IndexedAccessType; + export interface IndexType extends InstantiableType { type: InstantiableType | UnionOrIntersectionType; } - interface ConditionalRoot { + export interface ConditionalRoot { node: ConditionalTypeNode; checkType: Type; extendsType: Type; @@ -2394,36 +2463,36 @@ declare namespace ts { aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } - interface ConditionalType extends InstantiableType { + export interface ConditionalType extends InstantiableType { root: ConditionalRoot; checkType: Type; extendsType: Type; resolvedTrueType: Type; resolvedFalseType: Type; } - interface SubstitutionType extends InstantiableType { + export interface SubstitutionType extends InstantiableType { typeVariable: TypeVariable; substitute: Type; } - enum SignatureKind { + export enum SignatureKind { Call = 0, Construct = 1 } - interface Signature { + export interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly TypeParameter[]; + parameters: readonly Symbol[]; } - enum IndexKind { + export enum IndexKind { String = 0, Number = 1 } - interface IndexInfo { + export interface IndexInfo { type: Type; isReadonly: boolean; declaration?: IndexSignatureDeclaration; } - enum InferencePriority { + export enum InferencePriority { NakedTypeVariable = 1, HomomorphicMappedType = 2, PartialHomomorphicMappedType = 4, @@ -2432,16 +2501,18 @@ declare namespace ts { LiteralKeyof = 32, NoConstraints = 64, AlwaysStrict = 128, - PriorityImpliesCombination = 56 + MaxValue = 256, + PriorityImpliesCombination = 56, + Circularity = -1 } /** @deprecated Use FileExtensionInfo instead. */ - type JsFileExtensionInfo = FileExtensionInfo; - interface FileExtensionInfo { + export type JsFileExtensionInfo = FileExtensionInfo; + export interface FileExtensionInfo { extension: string; isMixedContent: boolean; scriptKind?: ScriptKind; } - interface DiagnosticMessage { + export interface DiagnosticMessage { key: string; category: DiagnosticCategory; code: number; @@ -2454,19 +2525,19 @@ declare namespace ts { * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, * the difference is that messages are all preformatted in DMC. */ - interface DiagnosticMessageChain { + export interface DiagnosticMessageChain { messageText: string; category: DiagnosticCategory; code: number; next?: DiagnosticMessageChain[]; } - interface Diagnostic extends DiagnosticRelatedInformation { + export interface Diagnostic extends DiagnosticRelatedInformation { /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } - interface DiagnosticRelatedInformation { + export interface DiagnosticRelatedInformation { category: DiagnosticCategory; code: number; file: SourceFile | undefined; @@ -2474,25 +2545,25 @@ declare namespace ts { length: number | undefined; messageText: string | DiagnosticMessageChain; } - interface DiagnosticWithLocation extends Diagnostic { + export interface DiagnosticWithLocation extends Diagnostic { file: SourceFile; start: number; length: number; } - enum DiagnosticCategory { + export enum DiagnosticCategory { Warning = 0, Error = 1, Suggestion = 2, Message = 3 } - enum ModuleResolutionKind { + export enum ModuleResolutionKind { Classic = 1, NodeJs = 2 } - interface PluginImport { + export interface PluginImport { name: string; } - interface ProjectReference { + export interface ProjectReference { /** A normalized path on disk */ path: string; /** The path as the user originally wrote it */ @@ -2502,8 +2573,8 @@ declare namespace ts { /** True if it is intended that this reference form a circularity */ circular?: boolean; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; - interface CompilerOptions { + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; + export interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; allowUmdGlobalAccess?: boolean; @@ -2518,6 +2589,7 @@ declare namespace ts { emitDeclarationOnly?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + disableSourceOfProjectReferenceRedirect?: boolean; downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; @@ -2584,16 +2656,21 @@ declare namespace ts { /** Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; + useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } - interface TypeAcquisition { + export interface TypeAcquisition { + /** + * @deprecated typingOptions.enableAutoDiscovery + * Use typeAcquisition.enable instead. + */ enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; exclude?: string[]; [option: string]: string[] | boolean | undefined; } - enum ModuleKind { + export enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, @@ -2602,22 +2679,22 @@ declare namespace ts { ES2015 = 5, ESNext = 99 } - enum JsxEmit { + export enum JsxEmit { None = 0, Preserve = 1, React = 2, ReactNative = 3 } - enum NewLineKind { + export enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1 } - interface LineAndCharacter { + export interface LineAndCharacter { /** 0-based. */ line: number; character: number; } - enum ScriptKind { + export enum ScriptKind { Unknown = 0, JS = 1, JSX = 2, @@ -2631,7 +2708,7 @@ declare namespace ts { */ Deferred = 7 } - enum ScriptTarget { + export enum ScriptTarget { ES3 = 0, ES5 = 1, ES2015 = 2, @@ -2644,38 +2721,38 @@ declare namespace ts { JSON = 100, Latest = 99 } - enum LanguageVariant { + export enum LanguageVariant { Standard = 0, JSX = 1 } /** Either a parsed command line or a parsed tsconfig.json */ - interface ParsedCommandLine { + export interface ParsedCommandLine { options: CompilerOptions; typeAcquisition?: TypeAcquisition; fileNames: string[]; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; compileOnSave?: boolean; } - enum WatchDirectoryFlags { + export enum WatchDirectoryFlags { None = 0, Recursive = 1 } - interface ExpandResult { + export interface ExpandResult { fileNames: string[]; wildcardDirectories: MapLike; } - interface CreateProgramOptions { - rootNames: ReadonlyArray; + export interface CreateProgramOptions { + rootNames: readonly string[]; options: CompilerOptions; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; oldProgram?: Program; - configFileParsingDiagnostics?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; } - interface ModuleResolutionHost { + export interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string | undefined; trace?(s: string): void; @@ -2695,7 +2772,7 @@ declare namespace ts { * * Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred. */ - interface ResolvedModule { + export interface ResolvedModule { /** Path of the file the module was resolved to. */ resolvedFileName: string; /** True if `resolvedFileName` comes from `node_modules`. */ @@ -2706,7 +2783,7 @@ declare namespace ts { * Prefer this over `ResolvedModule`. * If changing this, remember to change `moduleResolutionIsEqualTo`. */ - interface ResolvedModuleFull extends ResolvedModule { + export interface ResolvedModuleFull extends ResolvedModule { /** * Extension of resolvedFileName. This must match what's at the end of resolvedFileName. * This is optional for backwards-compatibility, but will be added if not provided. @@ -2718,7 +2795,7 @@ declare namespace ts { * Unique identifier with a package name and version. * If changing this, remember to change `packageIdIsEqual`. */ - interface PackageId { + export interface PackageId { /** * Name of the package. * Should not include `@types`. @@ -2733,7 +2810,7 @@ declare namespace ts { /** Version of the package, e.g. "1.2.3" */ version: string; } - enum Extension { + export enum Extension { Ts = ".ts", Tsx = ".tsx", Dts = ".d.ts", @@ -2742,21 +2819,21 @@ declare namespace ts { Json = ".json", TsBuildInfo = ".tsbuildinfo" } - interface ResolvedModuleWithFailedLookupLocations { + export interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; } - interface ResolvedTypeReferenceDirective { + export interface ResolvedTypeReferenceDirective { primary: boolean; resolvedFileName: string | undefined; packageId?: PackageId; /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; } - interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { + export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: ReadonlyArray; + readonly failedLookupLocations: readonly string[]; } - interface CompilerHost extends ModuleResolutionHost { + export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getCancellationToken?(): CancellationToken; @@ -2767,25 +2844,25 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; - readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (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, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } - interface SourceMapRange extends TextRange { + export interface SourceMapRange extends TextRange { source?: SourceMapSource; } - interface SourceMapSource { + export interface SourceMapSource { fileName: string; text: string; skipTrivia?: (pos: number) => number; } - enum EmitFlags { + export enum EmitFlags { None = 0, SingleLine = 1, AdviseOnEmitNode = 2, @@ -2816,18 +2893,18 @@ declare namespace ts { Iterator = 8388608, NoAsciiEscaping = 16777216, } - interface EmitHelper { + export interface EmitHelper { readonly name: string; readonly scoped: boolean; readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; } - interface UnscopedEmitHelper extends EmitHelper { + export interface UnscopedEmitHelper extends EmitHelper { readonly scoped: false; readonly text: string; } - type EmitHelperUniqueNameCallback = (name: string) => string; - enum EmitHint { + export type EmitHelperUniqueNameCallback = (name: string) => string; + export enum EmitHint { SourceFile = 0, Expression = 1, IdentifierName = 2, @@ -2835,7 +2912,7 @@ declare namespace ts { Unspecified = 4, EmbeddedStatement = 5 } - interface TransformationContext { + export interface TransformationContext { /** Gets the compiler options supplied to the transformer. */ getCompilerOptions(): CompilerOptions; /** Starts a new lexical environment. */ @@ -2885,7 +2962,7 @@ declare namespace ts { */ onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; } - interface TransformationResult { + export interface TransformationResult { /** Gets the transformed source files. */ transformed: T[]; /** Gets diagnostics for the transformation. */ @@ -2914,17 +2991,17 @@ declare namespace ts { * A function that is used to initialize and return a `Transformer` callback, which in turn * will be used to transform one or more nodes. */ - type TransformerFactory = (context: TransformationContext) => Transformer; + export type TransformerFactory = (context: TransformationContext) => Transformer; /** * A function that transforms a node. */ - type Transformer = (node: T) => T; + export type Transformer = (node: T) => T; /** * A function that accepts and possibly transforms a node. */ - type Visitor = (node: Node) => VisitResult; - type VisitResult = T | T[] | undefined; - interface Printer { + export type Visitor = (node: Node) => VisitResult; + export type VisitResult = T | T[] | undefined; + export interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. * @param hint A value indicating the purpose of a node. This is primarily used to @@ -2952,7 +3029,7 @@ declare namespace ts { */ printBundle(bundle: Bundle): string; } - interface PrintHandlers { + export interface PrintHandlers { /** * A hook used by the Printer when generating unique names to avoid collisions with * globally defined names that exist outside of the current source file. @@ -2995,28 +3072,33 @@ declare namespace ts { */ substituteNode?(hint: EmitHint, node: Node): Node; } - interface PrinterOptions { + export interface PrinterOptions { removeComments?: boolean; newLine?: NewLineKind; omitTrailingSemicolon?: boolean; noEmitHelpers?: boolean; } - interface GetEffectiveTypeRootsHost { + export interface GetEffectiveTypeRootsHost { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - interface TextSpan { + export interface ModuleSpecifierResolutionHost extends GetEffectiveTypeRootsHost { + useCaseSensitiveFileNames?(): boolean; + fileExists?(path: string): boolean; + readFile?(path: string): string | undefined; + } + export interface TextSpan { start: number; length: number; } - interface TextChangeRange { + export interface TextChangeRange { span: TextSpan; newLength: number; } - interface SyntaxList extends Node { + export interface SyntaxList extends Node { _children: Node[]; } - enum ListFormat { + export enum ListFormat { None = 0, SingleLine = 0, MultiLine = 1, @@ -3083,7 +3165,7 @@ declare namespace ts { IndexSignatureParameters = 8848, JSDocComment = 33 } - interface UserPreferences { + export interface UserPreferences { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; @@ -3095,22 +3177,23 @@ declare namespace ts { readonly providePrefixAndSuffixTextForRename?: boolean; } /** Represents a bigint literal value without requiring bigint support */ - interface PseudoBigInt { + export interface PseudoBigInt { negative: boolean; base10Value: string; } + export {}; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; declare namespace ts { - enum FileWatcherEventKind { + export enum FileWatcherEventKind { Created = 0, Changed = 1, Deleted = 2 } - type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; - type DirectoryWatcherCallback = (fileName: string) => void; - interface System { + export type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; + export type DirectoryWatcherCallback = (fileName: string) => void; + export interface System { args: string[]; newLine: string; useCaseSensitiveFileNames: boolean; @@ -3132,7 +3215,7 @@ declare namespace ts { getExecutingFilePath(): string; getCurrentDirectory(): string; getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; @@ -3151,11 +3234,12 @@ declare namespace ts { base64decode?(input: string): string; base64encode?(input: string): string; } - interface FileWatcher { + export interface FileWatcher { close(): void; } - function getNodeMajorVersion(): number | undefined; - let sys: System; + export function getNodeMajorVersion(): number | undefined; + export let sys: System; + export {}; } declare namespace ts { type ErrorCallback = (message: DiagnosticMessage, length: number) => void; @@ -3166,6 +3250,7 @@ declare namespace ts { getTokenPos(): number; getTokenText(): string; getTokenValue(): string; + hasUnicodeEscape(): boolean; hasExtendedUnicodeEscape(): boolean; hasPrecedingLineBreak(): boolean; isIdentifier(): boolean; @@ -3178,6 +3263,7 @@ declare namespace ts { scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; + reScanQuestionToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; @@ -3215,7 +3301,7 @@ declare namespace ts { } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; + function sortAndDeduplicateDiagnostics(diagnostics: readonly T[]): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3244,13 +3330,13 @@ declare namespace ts { * This function will then merge those changes into a single change range valid between V1 and * Vn. */ - function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: readonly TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; name: Identifier; }; - function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; + function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; @@ -3316,7 +3402,7 @@ declare namespace ts { * * For binding patterns, parameter tags are matched by position. */ - function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray; + function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[]; /** * Gets the JSDoc type parameter tags for the node if present. * @@ -3327,7 +3413,7 @@ declare namespace ts { * node are returned first, so in the previous example, the template * tag on the containing function expression would be first. */ - function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray; + function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[]; /** * Return true if the node has JSDoc parameter tags. * @@ -3369,14 +3455,14 @@ declare namespace ts { */ function getJSDocReturnType(node: Node): TypeNode | undefined; /** Get all JSDoc tags related to a node, including those on parent nodes. */ - function getJSDocTags(node: Node): ReadonlyArray; + function getJSDocTags(node: Node): readonly JSDocTag[]; /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ - function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray; + function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. */ - function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray; + function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; } declare namespace ts { @@ -3430,8 +3516,12 @@ declare namespace ts { function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression; function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression; function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression; + function isPropertyAccessChain(node: Node): node is PropertyAccessChain; function isElementAccessExpression(node: Node): node is ElementAccessExpression; + function isElementAccessChain(node: Node): node is ElementAccessChain; function isCallExpression(node: Node): node is CallExpression; + function isCallChain(node: Node): node is CallChain; + function isOptionalChain(node: Node): node is PropertyAccessChain | ElementAccessChain | CallChain; function isNewExpression(node: Node): node is NewExpression; function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression; function isTypeAssertion(node: Node): node is TypeAssertion; @@ -3529,7 +3619,7 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; - function isJSDocAllType(node: JSDocAllType): node is JSDocAllType; + function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType; @@ -3601,7 +3691,7 @@ declare namespace ts { function isStringLiteralLike(node: Node): node is StringLiteralLike; } declare namespace ts { - function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; + export function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, @@ -3615,25 +3705,26 @@ declare namespace ts { * @remarks `forEachChild` must visit the children of a node in the order * that they appear in the source code. The language service depends on this property to locate nodes by position. */ - function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; - function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; - function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; + export function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; + export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; + export function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; /** * Parse json text into SyntaxTree and return node and parse errors if any * @param fileName * @param sourceText */ - function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; - function isExternalModule(file: SourceFile): boolean; - function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; + export function isExternalModule(file: SourceFile): boolean; + export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export {}; } declare namespace ts { - function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; - type DiagnosticReporter = (diagnostic: Diagnostic) => void; + export function parseCommandLine(commandLine: readonly string[], readFile?: (path: string) => string | undefined): ParsedCommandLine; + export type DiagnosticReporter = (diagnostic: Diagnostic) => void; /** * Reports config file diagnostics */ - interface ConfigFileDiagnosticsReporter { + export interface ConfigFileDiagnosticsReporter { /** * Reports unrecoverable error when parsing config file */ @@ -3642,18 +3733,18 @@ declare namespace ts { /** * Interface extending ParseConfigHost to support ParseConfigFile that reads config file and reports errors */ - interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { + export interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { getCurrentDirectory(): string; } /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; + export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { + export function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { config?: any; error?: Diagnostic; }; @@ -3662,7 +3753,7 @@ declare namespace ts { * @param fileName The path to the config file * @param jsonText The text of the config file */ - function parseConfigFileTextToJson(fileName: string, jsonText: string): { + export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic; }; @@ -3670,11 +3761,11 @@ declare namespace ts { * Read tsconfig.json file * @param fileName The path to the config file */ - function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; + export function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; /** * Convert the json syntax tree into the json value */ - function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; + export function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -3682,7 +3773,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3690,8 +3781,8 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; - interface ParsedTsconfig { + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; + export interface ParsedTsconfig { raw: any; options?: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -3700,18 +3791,19 @@ declare namespace ts { */ extendedConfigPath?: string; } - interface ExtendedConfigCacheEntry { + export interface ExtendedConfigCacheEntry { extendedResult: TsConfigSourceFile; extendedConfig: ParsedTsconfig | undefined; } - function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; }; - function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypeAcquisition; errors: Diagnostic[]; }; + export {}; } declare namespace ts { function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; @@ -3755,7 +3847,7 @@ declare namespace ts { 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; + function createNodeArray(elements?: readonly T[], 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 | PseudoBigInt): NumericLiteral; @@ -3793,62 +3885,64 @@ declare namespace ts { function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - function createParameter(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + function createParameter(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createPropertySignature(modifiers: ReadonlyArray | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function updatePropertySignature(node: PropertySignature, modifiers: ReadonlyArray | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function createProperty(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function createMethodSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createProperty(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function createMethodSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; - function createMethod(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function createConstructor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function createGetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function createSetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function createCallSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createMethod(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; - function createConstructSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - function createIndexSignature(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; - function updateIndexSignature(node: IndexSignatureDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; + function createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; - function createTypeReferenceNode(typeName: string | EntityName, typeArguments: ReadonlyArray | undefined): TypeReferenceNode; + function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode; function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; - function createFunctionTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): FunctionTypeNode; + function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; - function createConstructorTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructorTypeNode; + function createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; + function createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; - function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createTupleTypeNode(elementTypes: readonly TypeNode[]): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]): TupleTypeNode; function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; function createRestTypeNode(type: TypeNode): RestTypeNode; function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; - function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; + function createUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; - function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; + function createIntersectionTypeNode(types: readonly TypeNode[]): IntersectionTypeNode; function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray): IntersectionTypeNode; - function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: ReadonlyArray): UnionOrIntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: readonly TypeNode[]): UnionOrIntersectionTypeNode; function createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; @@ -3861,36 +3955,42 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; - function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ReadonlyArray): ArrayBindingPattern; + function createObjectBindingPattern(elements: readonly BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: readonly BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: readonly ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: readonly ArrayBindingElement[]): ArrayBindingPattern; function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; - function createArrayLiteral(elements?: ReadonlyArray, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; - function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; + function createArrayLiteral(elements?: readonly Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier): PropertyAccessChain; + function updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier): PropertyAccessChain; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; - function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; + function createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain; + function updateElementAccessChain(node: ElementAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, argumentExpression: Expression): ElementAccessChain; + function createCall(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallExpression; + function createCallChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallChain; + function updateCallChain(node: CallChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallChain; + function createNew(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; /** @deprecated */ function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; /** @deprecated */ function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; - function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -3908,22 +4008,22 @@ declare namespace ts { /** @deprecated */ function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function createTemplateHead(text: string): TemplateHead; - function createTemplateMiddle(text: string): TemplateMiddle; - function createTemplateTail(text: string): TemplateTail; - function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; + function createTemplateExpression(head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function createTemplateHead(text: string, rawText?: string): TemplateHead; + function createTemplateMiddle(text: string, rawText?: string): TemplateMiddle; + function createTemplateTail(text: string, rawText?: string): TemplateTail; + function createNoSubstitutionTemplateLiteral(text: string, rawText?: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3933,10 +4033,10 @@ declare namespace ts { function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; - function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function updateBlock(node: Block, statements: ReadonlyArray): Block; - function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; + function createBlock(statements: readonly Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: readonly Statement[]): Block; + function createVariableStatement(modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; function createExpressionStatement(expression: Expression): ExpressionStatement; function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; @@ -3975,76 +4075,76 @@ declare namespace ts { function createDebuggerStatement(): DebuggerStatement; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - function createVariableDeclarationList(declarations: ReadonlyArray, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; - function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function createEnumDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, members: ReadonlyArray): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, members: ReadonlyArray): EnumDeclaration; - function createModuleDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; - function createModuleBlock(statements: ReadonlyArray): ModuleBlock; - function updateModuleBlock(node: ModuleBlock, statements: ReadonlyArray): ModuleBlock; - function createCaseBlock(clauses: ReadonlyArray): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: ReadonlyArray): CaseBlock; + function createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; + function createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + function createModuleBlock(statements: readonly Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; + function createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ReadonlyArray): NamedImports; - function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; + function createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; - function createNamedExports(elements: ReadonlyArray): NamedExports; - function updateNamedExports(node: NamedExports, elements: ReadonlyArray): NamedExports; + function createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; + function createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; - function createJsxElement(openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; + function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxFragment(openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function createJsxFragment(openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxText(text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function updateJsxText(node: JsxText, text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function createJsxOpeningFragment(): JsxOpeningFragment; function createJsxJsxClosingFragment(): JsxClosingFragment; - function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxAttributes(properties: ReadonlyArray): JsxAttributes; - function updateJsxAttributes(node: JsxAttributes, properties: ReadonlyArray): JsxAttributes; + function createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; - function createCaseClause(expression: Expression, statements: ReadonlyArray): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: ReadonlyArray): CaseClause; - function createDefaultClause(statements: ReadonlyArray): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; - function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; + function createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; + function createDefaultClause(statements: readonly Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause; + function createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause; function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; @@ -4055,7 +4155,7 @@ declare namespace ts { function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; - function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; + function updateSourceFileNode(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; /** * Creates a shallow, memberwise clone of a node for mutation. */ @@ -4077,20 +4177,20 @@ declare namespace ts { */ function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createCommaList(elements: ReadonlyArray): CommaListExpression; - function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; + function createCommaList(elements: readonly Expression[]): CommaListExpression; + function updateCommaList(node: CommaListExpression, elements: readonly Expression[]): CommaListExpression; + function createBundle(sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; - function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; + function updateBundle(node: Bundle, sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -4102,6 +4202,7 @@ declare namespace ts { function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createNullishCoalesce(left: Expression, right: Expression): BinaryExpression; function createLogicalNot(operand: Expression): PrefixUnaryExpression; function createVoidZero(): VoidExpression; function createExportDefault(expression: Expression): ExportAssignment; @@ -4158,7 +4259,7 @@ declare namespace ts { /** * Sets the constant value to emit for an expression. */ - function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): PropertyAccessExpression | ElementAccessExpression; + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): ElementAccessExpression | PropertyAccessExpression; /** * Adds an EmitHelper to a node. */ @@ -4263,23 +4364,25 @@ declare namespace ts { function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; } declare namespace ts { + function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined; + function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[]; function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } 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): ReadonlyArray; - interface FormatDiagnosticsHost { + export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; + export function resolveTripleslashReference(moduleName: string, containingFile: string): string; + export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + export interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; getNewLine(): string; } - function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; - function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; - function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + export function formatDiagnostics(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; + export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; + export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4290,7 +4393,7 @@ declare namespace ts { * @param createProgramOptions - The options for creating a program. * @returns A 'Program' object. */ - function createProgram(createProgramOptions: CreateProgramOptions): Program; + export function createProgram(createProgramOptions: CreateProgramOptions): Program; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4305,16 +4408,17 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; - /** @deprecated */ interface ResolveProjectReferencePathHost { + export function createProgram(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): Program; + /** @deprecated */ export interface ResolveProjectReferencePathHost { fileExists(fileName: string): boolean; } /** * Returns the target config filename of a project reference. * Note: The file might not exist. */ - function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; - /** @deprecated */ function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; + /** @deprecated */ export function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export {}; } declare namespace ts { interface EmitOutput { @@ -4366,31 +4470,31 @@ declare namespace ts { /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Get the diagnostics for compiler options */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics that dont belong to any file */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics from config file parsing */ - getConfigFileParsingDiagnostics(): ReadonlyArray; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Get the syntax diagnostics, for all source files if source file is not supplied */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the declaration diagnostics, for all source files if source file is not supplied */ - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** * Get all the dependencies of the file */ - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; + getAllDependencies(sourceFile: SourceFile): readonly string[]; /** * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program * The semantic diagnostics are cached and managed here @@ -4399,7 +4503,7 @@ declare namespace ts { * In case of SemanticDiagnosticsBuilderProgram if the source file is not provided, * it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Emits the JavaScript and declaration files. * When targetSource file is specified, emits the files corresponding to that source file, @@ -4425,7 +4529,7 @@ declare namespace ts { * Gets the semantic diagnostics from the program for the next affected file and caches it * Returns undefined if the iteration is complete */ - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; } /** * The builder that can handle the changes in program and iterate through changed file to emit the files @@ -4442,19 +4546,19 @@ declare namespace ts { /** * Create the builder to manage semantic diagnostics and cache them */ - function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ - function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ - function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): BuilderProgram; + function createAbstractBuilder(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram; } declare namespace ts { interface ReadBuildProgramHost { @@ -4465,21 +4569,21 @@ declare namespace ts { function readBuilderProgram(compilerOptions: CompilerOptions, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram | undefined; function createIncrementalCompilerHost(options: CompilerOptions, system?: System): CompilerHost; interface IncrementalProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - configFileParsingDiagnostics?: ReadonlyArray; - projectReferences?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; createProgram?: CreateProgram; } function createIncrementalProgram({ rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram }: IncrementalProgramOptions): T; - type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; + type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number) => void; /** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */ - type CreateProgram = (rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray | undefined) => T; + type CreateProgram = (rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[] | undefined) => T; /** Host that has watch functionality used in --watch mode */ interface WatchHost { /** If provided, called with Diagnostic message that informs about change in watch status */ - onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions): void; + onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number): void; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4515,7 +4619,7 @@ declare namespace ts { /** If provided, used in resolutions as well as handling directory structure */ getDirectories?(path: string): string[]; /** If provided, used to cache and handle directory structure modifications */ - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; /** Symbol links resolution */ realpath?(path: string): string; /** If provided would be used to write log about compilation */ @@ -4523,9 +4627,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[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; } interface WatchCompilerHost extends ProgramHost, WatchHost { /** If provided, callback to invoke after every new program creation */ @@ -4540,7 +4644,7 @@ declare namespace ts { /** Compiler options */ options: CompilerOptions; /** Project References */ - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; } /** * Host to create watch with config file @@ -4554,7 +4658,7 @@ declare namespace ts { * Used to generate source file names from the config file and its include, exclude, files rules * and also to cache the directory stucture */ - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; } interface Watch { /** Synchronize with host and get updated program */ @@ -4578,7 +4682,7 @@ declare namespace ts { * Create the watch compiler host for either configFile or fileNames and its options */ function createWatchCompilerHost(configFileName: string, optionsToExtend: CompilerOptions | undefined, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfConfigFile; - function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray): WatchCompilerHostOfFilesAndCompilerOptions; + function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions; /** * Creates the watch from the host for root files and compiler options */ @@ -4631,8 +4735,8 @@ declare namespace ts { function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter; function createSolutionBuilderHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary): SolutionBuilderHost; function createSolutionBuilderWithWatchHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): SolutionBuilderWithWatchHost; - function createSolutionBuilder(host: SolutionBuilderHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; - function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilder(host: SolutionBuilderHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; enum InvalidatedProjectKind { Build = 0, UpdateBundle = 1, @@ -4657,14 +4761,14 @@ declare namespace ts { getBuilderProgram(): T | undefined; getProgram(): Program | undefined; getSourceFile(fileName: string): SourceFile | undefined; - getSourceFiles(): ReadonlyArray; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSourceFiles(): readonly SourceFile[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getAllDependencies(sourceFile: SourceFile): readonly string[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } interface UpdateBundleProject extends InvalidatedProjectBase { @@ -4727,7 +4831,7 @@ declare namespace ts.server { readonly kind: EventBeginInstallTypes | EventEndInstallTypes; readonly eventId: number; readonly typingsInstallerVersion: string; - readonly packagesToInstall: ReadonlyArray; + readonly packagesToInstall: readonly string[]; } interface BeginInstallTypes extends InstallTypes { readonly kind: EventBeginInstallTypes; @@ -4780,8 +4884,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): ReadonlyArray; - getConstructSignatures(): ReadonlyArray; + getCallSignatures(): readonly Signature[]; + getConstructSignatures(): readonly Signature[]; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4809,7 +4913,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): ReadonlyArray; + getLineStarts(): readonly number[]; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -4858,7 +4962,7 @@ declare namespace ts { fileName: Path; packageName: string; } - interface LanguageServiceHost extends GetEffectiveTypeRootsHost { + interface LanguageServiceHost extends ModuleSpecifierResolutionHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; getProjectVersion?(): string; @@ -4866,7 +4970,7 @@ declare namespace ts { getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; - getProjectReferences?(): ReadonlyArray | undefined; + getProjectReferences?(): readonly ProjectReference[] | undefined; getLocalizedDiagnosticMessages?(): any; getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; @@ -4874,15 +4978,14 @@ declare namespace ts { log?(s: string): void; trace?(s: string): void; error?(s: string): void; - useCaseSensitiveFileNames?(): boolean; - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. @@ -4920,17 +5023,17 @@ 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, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined; getSmartSelectionRange(fileName: string, position: number): SelectionRange; - getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; - getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): readonly ImplementationLocation[] | 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): ReadonlyArray | undefined; + getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4950,7 +5053,7 @@ declare namespace ts { getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: FormatCodeSettings, preferences: UserPreferences): readonly CodeFixAction[]; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise; applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise; @@ -4963,8 +5066,8 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined; - organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; + organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program | undefined; dispose(): void; @@ -5113,8 +5216,8 @@ declare namespace ts { fixAllDescription?: string; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray; + changes: readonly FileTextChanges[]; + commands?: readonly CodeActionCommand[]; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -5235,6 +5338,11 @@ declare namespace ts { Block = 1, Smart = 2 } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorOptions { BaseIndentSize?: number; IndentSize: number; @@ -5287,6 +5395,7 @@ declare namespace ts { readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; readonly insertSpaceBeforeTypeAnnotation?: boolean; readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly semicolons?: SemicolonPreference; } function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; interface DefinitionInfo extends DocumentSpan { @@ -5296,7 +5405,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions?: ReadonlyArray; + definitions?: readonly DefinitionInfo[]; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -5665,6 +5774,7 @@ declare namespace ts { } } declare namespace ts { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier(): Classifier; } declare namespace ts { @@ -6328,7 +6438,7 @@ declare namespace ts.server.protocol { scope: OrganizeImportsScope; } interface OrganizeImportsResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } interface GetEditsForFileRenameRequest extends Request { command: CommandTypes.GetEditsForFileRename; @@ -6340,7 +6450,7 @@ declare namespace ts.server.protocol { readonly newFilePath: string; } interface GetEditsForFileRenameResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } /** * Request for the available codefixes at a specific position. @@ -6387,7 +6497,7 @@ declare namespace ts.server.protocol { /** * Errorcodes we want to get the fixes for. */ - errorCodes: ReadonlyArray; + errorCodes: readonly number[]; } interface GetCombinedCodeFixRequestArgs { scope: GetCombinedCodeFixScope; @@ -6504,7 +6614,7 @@ declare namespace ts.server.protocol { interface FileSpanWithContext extends FileSpan, TextSpanWithContext { } interface DefinitionInfoAndBoundSpan { - definitions: ReadonlyArray; + definitions: readonly FileSpanWithContext[]; textSpan: TextSpan; } /** @@ -6642,7 +6752,7 @@ declare namespace ts.server.protocol { /** * The file locations referencing the symbol. */ - refs: ReadonlyArray; + refs: readonly ReferencesResponseItem[]; /** * The name of the symbol. */ @@ -6746,7 +6856,7 @@ declare namespace ts.server.protocol { /** * An array of span groups (one per file) that refer to the item to be renamed. */ - locs: ReadonlyArray; + locs: readonly SpanGroup[]; } /** * Rename response message. @@ -7225,8 +7335,8 @@ declare namespace ts.server.protocol { commands?: {}[]; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray<{}>; + changes: readonly FileCodeEdits[]; + commands?: readonly {}[]; } interface CodeFixAction extends CodeAction { /** Short name to identify the fix, for use by telemetry. */ @@ -7433,7 +7543,7 @@ declare namespace ts.server.protocol { readonly isGlobalCompletion: boolean; readonly isMemberCompletion: boolean; readonly isNewIdentifierLocation: boolean; - readonly entries: ReadonlyArray; + readonly entries: readonly CompletionEntry[]; } interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; @@ -8112,7 +8222,7 @@ declare namespace ts.server.protocol { /** * list of packages to install */ - packages: ReadonlyArray; + packages: readonly string[]; } interface BeginInstallTypesEventBody extends InstallTypesEventBody { } @@ -8133,6 +8243,11 @@ declare namespace ts.server.protocol { Block = "Block", Smart = "Smart" } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorSettings { baseIndentSize?: number; indentSize?: number; @@ -8158,6 +8273,7 @@ declare namespace ts.server.protocol { placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; insertSpaceBeforeTypeAnnotation?: boolean; + semicolons?: SemicolonPreference; } interface UserPreferences { readonly disableSuggestions?: boolean; @@ -8241,6 +8357,7 @@ declare namespace ts.server.protocol { strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; + useDefineForClassFields?: boolean; target?: ScriptTarget | ts.ScriptTarget; traceResolution?: boolean; resolveJsonModule?: boolean; @@ -8441,7 +8558,7 @@ declare namespace ts.server { getCompilerOptions(): CompilerOptions; getNewLine(): string; getProjectVersion(): string; - getProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; getScriptFileNames(): string[]; private getOrCreateScriptInfoAndAttachToProject; getScriptKind(fileName: string): ScriptKind; @@ -8451,7 +8568,7 @@ declare namespace ts.server { getCurrentDirectory(): string; getDefaultLibFileName(): string; useCaseSensitiveFileNames(): boolean; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile(fileName: string): string | undefined; writeFile(fileName: string, content: string): void; fileExists(file: string): boolean; @@ -8466,10 +8583,9 @@ declare namespace ts.server { /** * Get the errors that dont have any file name associated */ - getGlobalProjectErrors(): ReadonlyArray; - getAllProjectErrors(): ReadonlyArray; + getGlobalProjectErrors(): readonly Diagnostic[]; + getAllProjectErrors(): readonly Diagnostic[]; getLanguageService(ensureSynchronized?: boolean): LanguageService; - private shouldEmitFile; getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; /** * Returns true if emit was conducted @@ -8489,7 +8605,7 @@ declare namespace ts.server { getRootFiles(): NormalizedPath[]; getRootScriptInfos(): ScriptInfo[]; getScriptInfos(): ScriptInfo[]; - getExcludedFiles(): ReadonlyArray; + getExcludedFiles(): readonly NormalizedPath[]; getFileNames(excludeFilesFromExternalLibraries?: boolean, excludeConfigFiles?: boolean): NormalizedPath[]; hasConfigFile(configFilePath: NormalizedPath): boolean; containsScriptInfo(info: ScriptInfo): boolean; @@ -8523,6 +8639,7 @@ declare namespace ts.server { 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 watchPackageJsonFile; } /** * If a file is opened and no tsconfig (or jsconfig) is found, @@ -8550,27 +8667,41 @@ declare namespace ts.server { private typeAcquisition; private directoriesWatchedForWildcards; readonly canonicalConfigFilePath: NormalizedPath; + private projectReferenceCallbacks; + private mapOfDeclarationDirectories; /** Ref count to the project when opened from external project */ private externalProjectRefCount; private projectErrors; private projectReferences; protected isInitialLoadPending: () => boolean; + /** + * This implementation of fileExists checks if the file being requested is + * .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that file exists on host + */ + fileExists(file: string): boolean; + /** + * This implementation of directoryExists checks if the directory being requested is + * directory of .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that directory exists on host + */ + directoryExists(path: string): boolean; /** * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph * @returns: true if set of files in the project stays the same and false - otherwise. */ updateGraph(): boolean; getConfigFilePath(): NormalizedPath; - getProjectReferences(): ReadonlyArray | undefined; - updateReferences(refs: ReadonlyArray | undefined): void; + getProjectReferences(): readonly ProjectReference[] | undefined; + updateReferences(refs: readonly ProjectReference[] | undefined): void; /** * Get the errors that dont have any file name associated */ - getGlobalProjectErrors(): ReadonlyArray; + getGlobalProjectErrors(): readonly Diagnostic[]; /** * Get all the project errors */ - getAllProjectErrors(): ReadonlyArray; + getAllProjectErrors(): readonly Diagnostic[]; setProjectErrors(projectErrors: Diagnostic[]): void; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; getTypeAcquisition(): TypeAcquisition; @@ -8584,7 +8715,7 @@ declare namespace ts.server { class ExternalProject extends Project { externalProjectName: string; compileOnSaveEnabled: boolean; - excludedFiles: ReadonlyArray; + excludedFiles: readonly NormalizedPath[]; private typeAcquisition; updateGraph(): boolean; getExcludedFiles(): readonly NormalizedPath[]; @@ -8593,35 +8724,35 @@ declare namespace ts.server { } } declare namespace ts.server { - const maxProgramSizeForNonTsFiles: number; - const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; - const ProjectLoadingStartEvent = "projectLoadingStart"; - const ProjectLoadingFinishEvent = "projectLoadingFinish"; - const LargeFileReferencedEvent = "largeFileReferenced"; - const ConfigFileDiagEvent = "configFileDiag"; - const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; - const ProjectInfoTelemetryEvent = "projectInfo"; - const OpenFileInfoTelemetryEvent = "openFileInfo"; - interface ProjectsUpdatedInBackgroundEvent { + export const maxProgramSizeForNonTsFiles: number; + export const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; + export const ProjectLoadingStartEvent = "projectLoadingStart"; + export const ProjectLoadingFinishEvent = "projectLoadingFinish"; + export const LargeFileReferencedEvent = "largeFileReferenced"; + export const ConfigFileDiagEvent = "configFileDiag"; + export const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; + export const ProjectInfoTelemetryEvent = "projectInfo"; + export const OpenFileInfoTelemetryEvent = "openFileInfo"; + export interface ProjectsUpdatedInBackgroundEvent { eventName: typeof ProjectsUpdatedInBackgroundEvent; data: { openFiles: string[]; }; } - interface ProjectLoadingStartEvent { + export interface ProjectLoadingStartEvent { eventName: typeof ProjectLoadingStartEvent; data: { project: Project; reason: string; }; } - interface ProjectLoadingFinishEvent { + export interface ProjectLoadingFinishEvent { eventName: typeof ProjectLoadingFinishEvent; data: { project: Project; }; } - interface LargeFileReferencedEvent { + export interface LargeFileReferencedEvent { eventName: typeof LargeFileReferencedEvent; data: { file: string; @@ -8629,15 +8760,15 @@ declare namespace ts.server { maxFileSize: number; }; } - interface ConfigFileDiagEvent { + export interface ConfigFileDiagEvent { eventName: typeof ConfigFileDiagEvent; data: { triggerFile: string; configFileName: string; - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; }; } - interface ProjectLanguageServiceStateEvent { + export interface ProjectLanguageServiceStateEvent { eventName: typeof ProjectLanguageServiceStateEvent; data: { project: Project; @@ -8645,11 +8776,11 @@ declare namespace ts.server { }; } /** This will be converted to the payload of a protocol.TelemetryEvent in session.defaultEventHandler. */ - interface ProjectInfoTelemetryEvent { + export interface ProjectInfoTelemetryEvent { readonly eventName: typeof ProjectInfoTelemetryEvent; readonly data: ProjectInfoTelemetryEventData; } - interface ProjectInfoTelemetryEventData { + export interface ProjectInfoTelemetryEventData { /** Cryptographically secure hash of project file location. */ readonly projectId: string; /** Count of file extensions seen in the project. */ @@ -8676,19 +8807,19 @@ declare namespace ts.server { * Info about a file will only be sent once per session, even if the file changes in ways that might affect the info. * Currently this is only sent for '.js' files. */ - interface OpenFileInfoTelemetryEvent { + export interface OpenFileInfoTelemetryEvent { readonly eventName: typeof OpenFileInfoTelemetryEvent; readonly data: OpenFileInfoTelemetryEventData; } - interface OpenFileInfoTelemetryEventData { + export interface OpenFileInfoTelemetryEventData { readonly info: OpenFileInfo; } - interface ProjectInfoTypeAcquisitionData { + export interface ProjectInfoTypeAcquisitionData { readonly enable: boolean | undefined; readonly include: boolean; readonly exclude: boolean; } - interface FileStats { + export interface FileStats { readonly js: number; readonly jsSize?: number; readonly jsx: number; @@ -8702,39 +8833,39 @@ declare namespace ts.server { readonly deferred: number; readonly deferredSize?: number; } - interface OpenFileInfo { + export interface OpenFileInfo { readonly checkJs: boolean; } - type ProjectServiceEvent = LargeFileReferencedEvent | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; - type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void; - interface SafeList { + export type ProjectServiceEvent = LargeFileReferencedEvent | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; + export type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void; + export interface SafeList { [name: string]: { match: RegExp; exclude?: (string | number)[][]; types?: string[]; }; } - interface TypesMapFile { + export interface TypesMapFile { typesMap: SafeList; simpleMap: { [libName: string]: string; }; } - function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; - function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; - function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; - function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown | ScriptKind.JS | ScriptKind.JSX | ScriptKind.TS | ScriptKind.TSX; - interface HostConfiguration { + export function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; + export function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; + export function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; + export function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind.Unknown | ScriptKind.JS | ScriptKind.JSX | ScriptKind.TS | ScriptKind.TSX; + export interface HostConfiguration { formatCodeOptions: FormatCodeSettings; preferences: protocol.UserPreferences; hostInfo: string; extraFileExtensions?: FileExtensionInfo[]; } - interface OpenConfiguredProjectResult { + export interface OpenConfiguredProjectResult { configFileName?: NormalizedPath; - configFileErrors?: ReadonlyArray; + configFileErrors?: readonly Diagnostic[]; } - interface ProjectServiceOptions { + export interface ProjectServiceOptions { host: ServerHost; logger: Logger; cancellationToken: HostCancellationToken; @@ -8744,13 +8875,13 @@ declare namespace ts.server { eventHandler?: ProjectServiceEventHandler; suppressDiagnosticEvents?: boolean; throttleWaitMilliseconds?: number; - globalPlugins?: ReadonlyArray; - pluginProbeLocations?: ReadonlyArray; + globalPlugins?: readonly string[]; + pluginProbeLocations?: readonly string[]; allowLocalPluginLoads?: boolean; typesMapLocation?: string; syntaxOnly?: boolean; } - class ProjectService { + export class ProjectService { private readonly scriptInfoInNodeModulesWatchers; /** * Contains all the deleted script info's version information so that @@ -8814,8 +8945,8 @@ declare namespace ts.server { readonly throttleWaitMilliseconds?: number; private readonly eventHandler?; private readonly suppressDiagnosticEvents?; - readonly globalPlugins: ReadonlyArray; - readonly pluginProbeLocations: ReadonlyArray; + readonly globalPlugins: readonly string[]; + readonly pluginProbeLocations: readonly string[]; readonly allowLocalPluginLoads: boolean; private currentPluginConfigOverrides; readonly typesMapLocation: string | undefined; @@ -9003,6 +9134,7 @@ declare namespace ts.server { hasDeferredExtension(): boolean; configurePlugin(args: protocol.ConfigurePluginRequestArguments): void; } + export {}; } declare namespace ts.server { interface ServerCancellationToken extends HostCancellationToken { @@ -9040,8 +9172,8 @@ declare namespace ts.server { syntaxOnly?: boolean; throttleWaitMilliseconds?: number; noGetErrOnBackgroundUpdate?: boolean; - globalPlugins?: ReadonlyArray; - pluginProbeLocations?: ReadonlyArray; + globalPlugins?: readonly string[]; + pluginProbeLocations?: readonly string[]; allowLocalPluginLoads?: boolean; typesMapLocation?: string; } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index c1f065ea5d23d..14d9b9770f9d5 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -14,6 +14,13 @@ and limitations under the License. ***************************************************************************** */ "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -74,15 +81,17 @@ var __rest = (this && this.__rest) || function (s, e) { for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } return t; }; var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -100,7 +109,7 @@ var ts; ts.emptyArray = []; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -135,7 +144,7 @@ var ts; } ts.createMapFromTemplate = createMapFromTemplate; // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name + // eslint-disable-next-line no-in-operator ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { @@ -199,7 +208,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -296,6 +305,21 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Like `forEach`, but iterates in reverse order. + */ + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ function firstDefined(array, callback) { if (array === undefined) { @@ -792,7 +816,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -849,6 +873,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1239,6 +1264,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1377,6 +1414,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1436,7 +1479,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1470,7 +1513,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1944,11 +1987,33 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2025,8 +2090,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2075,6 +2142,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2090,7 +2158,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2198,6 +2266,9 @@ var ts; Debug.assertNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1 /* Normal */) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -2378,6 +2449,47 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + // require() will throw an exception if the module is not installed + // It may also return undefined if not installed properly + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { // https://semver.org/#spec-item-2 // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative @@ -2776,358 +2888,366 @@ var ts; 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"; + SyntaxKind[SyntaxKind["QuestionDotToken"] = 28] = "QuestionDotToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 29] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 30] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 31] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 32] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 33] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 34] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 35] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 36] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 37] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 38] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 39] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 40] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 41] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 42] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 43] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 44] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 45] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 46] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 47] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 49] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 50] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 51] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 52] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 53] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 54] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 55] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 56] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 57] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 58] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 59] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - SyntaxKind[SyntaxKind["BacktickToken"] = 59] = "BacktickToken"; + SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 60] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 61] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 62] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 63] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 64] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 65] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 66] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 67] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 69] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 70] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 71] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 72] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 74] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 73] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 75] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 74] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 75] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 76] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 77] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 78] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 79] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 80] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 81] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 82] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 83] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 84] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 85] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 86] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 87] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 88] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 89] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 90] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 91] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 92] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 93] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 94] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 95] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 96] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 97] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 98] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 99] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 100] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 101] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 102] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 103] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 104] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 105] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 106] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 107] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 108] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 109] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 76] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 77] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 78] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 79] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 80] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 81] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 82] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 83] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 84] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 85] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 86] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 87] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 88] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 89] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 90] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 91] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 92] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 93] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 94] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 95] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 96] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 97] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 98] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 99] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 100] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 101] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 102] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 103] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 104] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 105] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 106] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 107] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 108] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 109] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 110] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 111] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 110] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 111] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 112] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 113] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 114] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 115] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 116] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 117] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 118] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 112] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 113] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 114] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 115] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 116] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 117] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 118] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 119] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 120] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 119] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 120] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 121] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 122] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 123] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 124] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 125] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 126] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 127] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 128] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 129] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 130] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 131] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 132] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 133] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 134] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 135] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 136] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 137] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 138] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 139] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 140] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 141] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 142] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 143] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 144] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 121] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 122] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 123] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 124] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 125] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 126] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 127] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 128] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 129] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 130] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 131] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 132] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 133] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 134] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 135] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 136] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 137] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 138] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 139] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 140] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 141] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 142] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 143] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 144] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 145] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 146] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 147] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 148] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 149] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 150] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 151] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 152] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 153] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 154] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 155] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 156] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 157] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 158] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 159] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 160] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 161] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 162] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 163] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 164] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 165] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 166] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 167] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 168] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 169] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 170] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 171] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 172] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 173] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 174] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 175] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 176] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 177] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 178] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 179] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 180] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 181] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 182] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 183] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 184] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 185] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 186] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 187] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 188] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 189] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 190] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 191] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 192] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 193] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 194] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 195] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 196] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 197] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 198] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 199] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 200] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 201] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 202] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 203] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 204] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 205] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 206] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 207] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 208] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 209] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 210] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 211] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 212] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 213] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 214] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 215] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 216] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 217] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 218] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 219] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 220] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 221] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 222] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 223] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 224] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 225] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 226] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 227] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 228] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 229] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 230] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 231] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 232] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 233] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 234] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 235] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 236] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 237] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 238] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 239] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 240] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 241] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 242] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 243] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 244] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 245] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 246] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 247] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 248] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 249] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 250] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 251] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 252] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 253] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 254] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 255] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 256] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 257] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 258] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 259] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 260] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 261] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 262] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 263] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 264] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 265] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 266] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 267] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 268] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 269] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 270] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 271] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 272] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 273] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 274] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 275] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 276] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 277] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 278] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 279] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 280] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 281] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 282] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 283] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 284] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 285] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 286] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 287] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 288] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 289] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 290] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 291] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 292] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 293] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 297] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 298] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 299] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 300] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 301] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 302] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 303] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 304] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 305] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 306] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 307] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 308] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 309] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 310] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 311] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 312] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 294] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 295] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 296] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 297] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 298] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 299] = "JSDocVariadicType"; + // https://jsdoc.app/about-namepaths.html + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 300] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 301] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 302] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 303] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 304] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 305] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 306] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 307] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 308] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 309] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 310] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 311] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 312] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 313] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 314] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 315] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 316] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 313] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 317] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 314] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 315] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 316] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 317] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 318] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 318] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 319] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 320] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 321] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 322] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 323] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 319] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 324] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 61] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 72] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 74] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 74] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 76] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 111] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 76] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 151] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 112] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 120] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 167] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 187] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 74] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 151] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 312] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 300] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 312] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 74] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 224] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 240] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 152] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 292] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 316] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 304] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 316] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 121] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 151] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3137,20 +3257,21 @@ var ts; NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain"; + NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 1024] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2048] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4096] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData"; // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid // walking the tree if the flags are not set. However, these flags are just a approximation // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. @@ -3160,23 +3281,23 @@ var ts; // removal, it is likely that users will add the import anyway. // The advantage of this approach is its simplicity. For the case of batch compilation, // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta"; - NodeFlags[NodeFlags["JSDoc"] = 2097152] = "JSDoc"; - /* @internal */ NodeFlags[NodeFlags["Ambient"] = 4194304] = "Ambient"; - /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 8388608] = "InWithStatement"; - NodeFlags[NodeFlags["JsonFile"] = 16777216] = "JsonFile"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta"; + NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc"; + /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient"; + /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement"; + NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 12679168] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags"; // Represents all flags that are potentially set once and // never cleared on SourceFiles which get re-used in between incremental parses. // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. - /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags"; + /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -3215,7 +3336,10 @@ var ts; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; - RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + RelationComparisonResult[RelationComparisonResult["Reported"] = 4] = "Reported"; + RelationComparisonResult[RelationComparisonResult["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable"; + RelationComparisonResult[RelationComparisonResult["ReportsUnreliable"] = 16] = "ReportsUnreliable"; + RelationComparisonResult[RelationComparisonResult["ReportsMask"] = 24] = "ReportsMask"; })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ var GeneratedIdentifierFlags; @@ -3251,6 +3375,8 @@ var ts; /* @internal */ TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator"; /* @internal */ + TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; + /* @internal */ TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; @@ -3266,12 +3392,13 @@ var ts; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; - FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Call"] = 512] = "Call"; + FlowFlags[FlowFlags["Referenced"] = 1024] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 2048] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 4096] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 8192] = "AfterFinally"; /** @internal */ - FlowFlags[FlowFlags["Cached"] = 8192] = "Cached"; + FlowFlags[FlowFlags["Cached"] = 16384] = "Cached"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -3281,6 +3408,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3301,6 +3435,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3366,7 +3502,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3416,27 +3551,40 @@ var ts; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + TypePredicateKind[TypePredicateKind["AssertsThis"] = 2] = "AssertsThis"; + TypePredicateKind[TypePredicateKind["AssertsIdentifier"] = 3] = "AssertsIdentifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3474,32 +3622,32 @@ var ts; SymbolFlags[SymbolFlags["All"] = 67108863] = "All"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 67220415] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 67897832] = "Type"; + SymbolFlags[SymbolFlags["Value"] = 111551] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 788968] = "Type"; SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; // Variables can be redeclared, but can not redeclare a block-scoped declaration with the // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 67220414] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 111550] = "FunctionScopedVariableExcludes"; // Block-scoped declarations are not allowed to be re-declared // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 67220415] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 67220415] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 111551] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 111551] = "ParameterExcludes"; SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 68008959] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 67219887] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 68008383] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 67897736] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 68008191] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 68008831] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 110991] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899503] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 788872] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 110735] = "ValueModuleExcludes"; SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 67212223] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 67154879] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 67187647] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 67635688] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 67897832] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 103359] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 46015] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 78783] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 526824] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 788968] = "TypeAliasExcludes"; SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; @@ -3507,11 +3655,15 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; /* @internal */ + SymbolFlags[SymbolFlags["ExportSupportsDefaultModifier"] = 112] = "ExportSupportsDefaultModifier"; + /* @internal */ + SymbolFlags[SymbolFlags["ExportDoesNotSupportDefaultModifier"] = -113] = "ExportDoesNotSupportDefaultModifier"; + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable"; /* @internal */ - SymbolFlags[SymbolFlags["LateBindingContainer"] = 6240] = "LateBindingContainer"; + SymbolFlags[SymbolFlags["LateBindingContainer"] = 6256] = "LateBindingContainer"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ var EnumKind; @@ -3749,7 +3901,9 @@ var ts; InferencePriority[InferencePriority["LiteralKeyof"] = 32] = "LiteralKeyof"; InferencePriority[InferencePriority["NoConstraints"] = 64] = "NoConstraints"; InferencePriority[InferencePriority["AlwaysStrict"] = 128] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 256] = "MaxValue"; InferencePriority[InferencePriority["PriorityImpliesCombination"] = 56] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ var InferenceFlags; @@ -3827,6 +3981,9 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + // NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind. + // Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES + // module kind). ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); @@ -4411,7 +4568,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -4565,6 +4722,38 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + /* @internal */ + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; /** * Returns true if file status changed */ @@ -4591,6 +4780,8 @@ var ts; ts.getFileWatcherEventKind = getFileWatcherEventKind; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + /*@internal*/ + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4695,6 +4886,32 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + /** + * patch writefile to create folder before writing the file + */ + /*@internal*/ + function patchWriteFileEnsuringDirectory(sys) { + // patch writefile to create folder before writing the file + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -4711,12 +4928,14 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does // not actually work. var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -4728,9 +4947,12 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; + var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); var FileSystemEntryKind; @@ -4741,6 +4963,7 @@ var ts; var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -4807,8 +5030,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -4834,6 +5059,90 @@ var ts; base64encode: function (input) { return bufferFrom(input).toString("base64"); }, }; return nodeSystem; + /** + * Uses the builtin inspector APIs to capture a CPU profile + * See https://nodejs.org/api/inspector.html#inspector_example_usage for details + */ + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + /** + * Strips non-TS paths from the profile, so users with private projects shouldn't + * need to worry about leaking paths by submitting a cpu profile to us + */ + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + // do nothing and ignore fallible fs operation + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + // do nothing and ignore fallible fs operation + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { // See https://github.com/Microsoft/TypeScript/issues/25652 return Buffer.from && Buffer.from !== Int8Array.from @@ -4877,7 +5186,7 @@ var ts; return useNonPollingWatchers ? createNonPollingWatchFile() : // Default to do not use polling interval as it is before this experiment branch - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, /*pollingInterval*/ undefined); }; } function getWatchDirectory() { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows @@ -4951,7 +5260,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -5009,6 +5318,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } /** Watcher for the file system entry depending on whether it is missing or present */ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : @@ -5025,6 +5340,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -5049,7 +5365,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); // Watch the missing file or directory or error presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; @@ -5061,11 +5379,23 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations + // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } /** * Watch the file or directory using fs.watchFile since fs.watch threw exception * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } /** @@ -5098,7 +5428,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -5126,7 +5456,14 @@ var ts; // Default is UTF-8 with no byte order mark return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); // If a BOM is required, emit one if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; @@ -5143,6 +5480,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -5198,6 +5536,7 @@ var ts; return fileSystemEntryExists(path, 1 /* Directory */); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } function realpath(path) { @@ -5275,16 +5614,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -5296,14 +5625,7 @@ var ts; } if (sys) { // patch writefile to create folder before writing the file - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -5322,10 +5644,9 @@ var ts; /* @internal */ var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; } - // tslint:disable-next-line variable-name ts.Diagnostics = { Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), @@ -5388,7 +5709,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -5443,7 +5763,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -5541,6 +5860,7 @@ var ts; A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -5573,7 +5893,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -5587,6 +5907,16 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(1359, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_1359", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(1360, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_1360", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), 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."), @@ -5630,7 +5960,7 @@ var ts; Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), @@ -5878,6 +6208,9 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -6000,6 +6333,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), 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}'."), @@ -6086,6 +6427,9 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -6096,6 +6440,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -6121,6 +6466,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -6308,6 +6654,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + 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}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -6326,9 +6673,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), 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}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -6367,6 +6716,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -6453,6 +6804,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -6482,6 +6835,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6599,6 +6953,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -6609,94 +6971,95 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 73 /* Identifier */; + return token >= 75 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119 /* AbstractKeyword */, - any: 121 /* AnyKeyword */, - as: 120 /* AsKeyword */, - bigint: 147 /* BigIntKeyword */, - boolean: 124 /* BooleanKeyword */, - break: 74 /* BreakKeyword */, - case: 75 /* CaseKeyword */, - catch: 76 /* CatchKeyword */, - class: 77 /* ClassKeyword */, - continue: 79 /* ContinueKeyword */, - const: 78 /* ConstKeyword */ + abstract: 121 /* AbstractKeyword */, + any: 124 /* AnyKeyword */, + as: 122 /* AsKeyword */, + asserts: 123 /* AssertsKeyword */, + bigint: 150 /* BigIntKeyword */, + boolean: 127 /* BooleanKeyword */, + break: 76 /* BreakKeyword */, + case: 77 /* CaseKeyword */, + catch: 78 /* CatchKeyword */, + class: 79 /* ClassKeyword */, + continue: 81 /* ContinueKeyword */, + const: 80 /* ConstKeyword */ }, - _a["" + "constructor"] = 125 /* ConstructorKeyword */, - _a.debugger = 80 /* DebuggerKeyword */, - _a.declare = 126 /* DeclareKeyword */, - _a.default = 81 /* DefaultKeyword */, - _a.delete = 82 /* DeleteKeyword */, - _a.do = 83 /* DoKeyword */, - _a.else = 84 /* ElseKeyword */, - _a.enum = 85 /* EnumKeyword */, - _a.export = 86 /* ExportKeyword */, - _a.extends = 87 /* ExtendsKeyword */, - _a.false = 88 /* FalseKeyword */, - _a.finally = 89 /* FinallyKeyword */, - _a.for = 90 /* ForKeyword */, - _a.from = 145 /* FromKeyword */, - _a.function = 91 /* FunctionKeyword */, - _a.get = 127 /* GetKeyword */, - _a.if = 92 /* IfKeyword */, - _a.implements = 110 /* ImplementsKeyword */, - _a.import = 93 /* ImportKeyword */, - _a.in = 94 /* InKeyword */, - _a.infer = 128 /* InferKeyword */, - _a.instanceof = 95 /* InstanceOfKeyword */, - _a.interface = 111 /* InterfaceKeyword */, - _a.is = 129 /* IsKeyword */, - _a.keyof = 130 /* KeyOfKeyword */, - _a.let = 112 /* LetKeyword */, - _a.module = 131 /* ModuleKeyword */, - _a.namespace = 132 /* NamespaceKeyword */, - _a.never = 133 /* NeverKeyword */, - _a.new = 96 /* NewKeyword */, - _a.null = 97 /* NullKeyword */, - _a.number = 136 /* NumberKeyword */, - _a.object = 137 /* ObjectKeyword */, - _a.package = 113 /* PackageKeyword */, - _a.private = 114 /* PrivateKeyword */, - _a.protected = 115 /* ProtectedKeyword */, - _a.public = 116 /* PublicKeyword */, - _a.readonly = 134 /* ReadonlyKeyword */, - _a.require = 135 /* RequireKeyword */, - _a.global = 146 /* GlobalKeyword */, - _a.return = 98 /* ReturnKeyword */, - _a.set = 138 /* SetKeyword */, - _a.static = 117 /* StaticKeyword */, - _a.string = 139 /* StringKeyword */, - _a.super = 99 /* SuperKeyword */, - _a.switch = 100 /* SwitchKeyword */, - _a.symbol = 140 /* SymbolKeyword */, - _a.this = 101 /* ThisKeyword */, - _a.throw = 102 /* ThrowKeyword */, - _a.true = 103 /* TrueKeyword */, - _a.try = 104 /* TryKeyword */, - _a.type = 141 /* TypeKeyword */, - _a.typeof = 105 /* TypeOfKeyword */, - _a.undefined = 142 /* UndefinedKeyword */, - _a.unique = 143 /* UniqueKeyword */, - _a.unknown = 144 /* UnknownKeyword */, - _a.var = 106 /* VarKeyword */, - _a.void = 107 /* VoidKeyword */, - _a.while = 108 /* WhileKeyword */, - _a.with = 109 /* WithKeyword */, - _a.yield = 118 /* YieldKeyword */, - _a.async = 122 /* AsyncKeyword */, - _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a["" + "constructor"] = 128 /* ConstructorKeyword */, + _a.debugger = 82 /* DebuggerKeyword */, + _a.declare = 129 /* DeclareKeyword */, + _a.default = 83 /* DefaultKeyword */, + _a.delete = 84 /* DeleteKeyword */, + _a.do = 85 /* DoKeyword */, + _a.else = 86 /* ElseKeyword */, + _a.enum = 87 /* EnumKeyword */, + _a.export = 88 /* ExportKeyword */, + _a.extends = 89 /* ExtendsKeyword */, + _a.false = 90 /* FalseKeyword */, + _a.finally = 91 /* FinallyKeyword */, + _a.for = 92 /* ForKeyword */, + _a.from = 148 /* FromKeyword */, + _a.function = 93 /* FunctionKeyword */, + _a.get = 130 /* GetKeyword */, + _a.if = 94 /* IfKeyword */, + _a.implements = 112 /* ImplementsKeyword */, + _a.import = 95 /* ImportKeyword */, + _a.in = 96 /* InKeyword */, + _a.infer = 131 /* InferKeyword */, + _a.instanceof = 97 /* InstanceOfKeyword */, + _a.interface = 113 /* InterfaceKeyword */, + _a.is = 132 /* IsKeyword */, + _a.keyof = 133 /* KeyOfKeyword */, + _a.let = 114 /* LetKeyword */, + _a.module = 134 /* ModuleKeyword */, + _a.namespace = 135 /* NamespaceKeyword */, + _a.never = 136 /* NeverKeyword */, + _a.new = 98 /* NewKeyword */, + _a.null = 99 /* NullKeyword */, + _a.number = 139 /* NumberKeyword */, + _a.object = 140 /* ObjectKeyword */, + _a.package = 115 /* PackageKeyword */, + _a.private = 116 /* PrivateKeyword */, + _a.protected = 117 /* ProtectedKeyword */, + _a.public = 118 /* PublicKeyword */, + _a.readonly = 137 /* ReadonlyKeyword */, + _a.require = 138 /* RequireKeyword */, + _a.global = 149 /* GlobalKeyword */, + _a.return = 100 /* ReturnKeyword */, + _a.set = 141 /* SetKeyword */, + _a.static = 119 /* StaticKeyword */, + _a.string = 142 /* StringKeyword */, + _a.super = 101 /* SuperKeyword */, + _a.switch = 102 /* SwitchKeyword */, + _a.symbol = 143 /* SymbolKeyword */, + _a.this = 103 /* ThisKeyword */, + _a.throw = 104 /* ThrowKeyword */, + _a.true = 105 /* TrueKeyword */, + _a.try = 106 /* TryKeyword */, + _a.type = 144 /* TypeKeyword */, + _a.typeof = 107 /* TypeOfKeyword */, + _a.undefined = 145 /* UndefinedKeyword */, + _a.unique = 146 /* UniqueKeyword */, + _a.unknown = 147 /* UnknownKeyword */, + _a.var = 108 /* VarKeyword */, + _a.void = 109 /* VoidKeyword */, + _a.while = 110 /* WhileKeyword */, + _a.with = 111 /* WithKeyword */, + _a.yield = 120 /* YieldKeyword */, + _a.async = 125 /* AsyncKeyword */, + _a.await = 126 /* AwaitKeyword */, + _a.of = 151 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - 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 */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 74 /* CaretEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6743,6 +7106,14 @@ var ts; */ 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,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 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, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 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, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 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, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 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, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + /** + * Generated by scripts/regenerate-unicode-identifier-parts.js on node v12.4.0 with unicode 12.1 + * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords + * unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and + * unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start + */ + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 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, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 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, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 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, 2809, 2809, 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, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 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, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 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, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 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, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 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, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 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, 43824, 43866, 43868, 43879, 43888, 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, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 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, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -6769,15 +7140,17 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -6950,6 +7323,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7273,11 +7647,12 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -7301,17 +7676,18 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */; }, + isIdentifier: function () { return token === 75 /* Identifier */ || token > 111 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -7321,6 +7697,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -7335,6 +7712,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7434,7 +7820,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -7642,6 +8028,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024 /* UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: @@ -7724,21 +8111,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92 /* backslash */) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024 /* UnicodeEscape */; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters pos += 6; start = pos; @@ -7762,7 +8169,7 @@ var ts; } } } - return token = 73 /* Identifier */; + return token = 75 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -7826,14 +8233,14 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); // Special handling for shebang if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); @@ -7897,12 +8304,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 34 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* ExclamationEqualsToken */; } pos++; - return token = 52 /* ExclamationToken */; + return token = 53 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -7911,19 +8318,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* PercentEqualsToken */; + return pos += 2, token = 68 /* PercentEqualsToken */; } pos++; - return token = 43 /* PercentToken */; + return token = 44 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 54 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* AmpersandEqualsToken */; + return pos += 2, token = 72 /* AmpersandEqualsToken */; } pos++; - return token = 49 /* AmpersandToken */; + return token = 50 /* AmpersandToken */; case 40 /* openParen */: pos++; return token = 20 /* OpenParenToken */; @@ -7932,13 +8339,13 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AsteriskEqualsToken */; + return pos += 2, token = 65 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 41 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -7946,28 +8353,28 @@ var ts; asteriskSeen = true; continue; } - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 44 /* PlusPlusToken */; + return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* PlusEqualsToken */; + return pos += 2, token = 63 /* PlusEqualsToken */; } pos++; - return token = 38 /* PlusToken */; + return token = 39 /* PlusToken */; case 44 /* comma */: pos++; return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 45 /* MinusMinusToken */; + return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* MinusEqualsToken */; + return pos += 2, token = 64 /* MinusEqualsToken */; } pos++; - return token = 39 /* MinusToken */; + return token = 40 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -8028,10 +8435,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* SlashEqualsToken */; + return pos += 2, token = 67 /* SlashEqualsToken */; } pos++; - return token = 42 /* SlashToken */; + return token = 43 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -8089,7 +8496,7 @@ var ts; return token; case 58 /* colon */: pos++; - return token = 57 /* ColonToken */; + return token = 58 /* ColonToken */; case 59 /* semicolon */: pos++; return token = 26 /* SemicolonToken */; @@ -8105,20 +8512,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 46 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 31 /* LessThanEqualsToken */; + return pos += 2, token = 32 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 29 /* LessThanSlashToken */; + return pos += 2, token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8131,15 +8538,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 33 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 37 /* EqualsGreaterThanToken */; + return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8151,10 +8558,18 @@ var ts; } } pos++; - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 56 /* QuestionToken */; + if (text.charCodeAt(pos) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28 /* QuestionDotToken */; + } + if (text.charCodeAt(pos) === 63 /* question */) { + pos++; + return token = 60 /* QuestionQuestionToken */; + } + return token = 57 /* QuestionToken */; case 91 /* openBracket */: pos++; return token = 22 /* OpenBracketToken */; @@ -8163,10 +8578,10 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* CaretEqualsToken */; + return pos += 2, token = 74 /* CaretEqualsToken */; } pos++; - return token = 51 /* CaretToken */; + return token = 52 /* CaretToken */; case 123 /* openBrace */: pos++; return token = 18 /* OpenBraceToken */; @@ -8181,26 +8596,34 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 55 /* BarBarToken */; + return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* BarEqualsToken */; + return pos += 2, token = 73 /* BarEqualsToken */; } pos++; - return token = 50 /* BarToken */; + return token = 51 /* BarToken */; case 125 /* closeBrace */: pos++; return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 53 /* TildeToken */; + return token = 54 /* TildeToken */; case 64 /* at */: pos++; - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 92 /* backslash */: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -8209,9 +8632,9 @@ var ts; return token = 0 /* Unknown */; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { tokenValue += scanIdentifierParts(); @@ -8219,44 +8642,44 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1 /* PrecedingLineBreak */; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0 /* Unknown */; } } } function reScanGreaterToken() { - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 47 /* GreaterThanGreaterThanToken */; + return token = 48 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 32 /* GreaterThanEqualsToken */; + return token = 33 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 42 /* SlashToken */ || token === 65 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -8318,12 +8741,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46 /* LessThanLessThanToken */) { + if (token === 47 /* LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57 /* QuestionToken */; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -8333,10 +8761,10 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 29 /* LessThanSlashToken */; + return token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; @@ -8345,7 +8773,7 @@ var ts; // First non-whitespace character on this line. var firstNonWhitespace = 0; // These initial values are special because the first line is: - // firstNonWhitespace = 0 to indicate that we want leading whitspace, + // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { @@ -8379,17 +8807,22 @@ var ts; // they allow dashes function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; + // An identifier or keyword has already been parsed - check for a `-` and then append it and everything after it to the token + // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token + // Any caller should be expecting this behavior and should only read the pos or token value after calling it. while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45 /* minus */) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -8407,12 +8840,12 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9 /* tab */: case 11 /* verticalTab */: @@ -8423,13 +8856,13 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 123 /* openBrace */: return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: @@ -8439,23 +8872,44 @@ var ts; case 93 /* closeBracket */: return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 62 /* greaterThan */: - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 44 /* comma */: return token = 27 /* CommaToken */; case 46 /* dot */: return token = 24 /* DotToken */; case 96 /* backtick */: - return token = 59 /* BacktickToken */; - } - if (isIdentifierStart(ch, 99 /* Latest */)) { - while (isIdentifierPart(text.charCodeAt(pos), 99 /* Latest */) && pos < end) { + return token = 61 /* BacktickToken */; + case 92 /* backslash */: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0 /* Unknown */; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -8531,13 +8985,40 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; } } ts.createScanner = createScanner; + /* @internal */ + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt + var size = str.length; + // Account for out-of-bounds indices: + if (i < 0 || i >= size) { + return undefined; // String.codePointAt returns `undefined` for OOB indexes + } + // Get the first code unit + var first = str.charCodeAt(i); + // check if it’s the start of a surrogate pair + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { // high surrogate and there is a next code unit + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + /* @internal */ + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -8617,6 +9098,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str += " "; }, @@ -8704,7 +9187,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -8792,28 +9275,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144 /* HasAggregatedChildData */)) { + if (!(node.flags & 524288 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 262144 /* HasAggregatedChildData */; + node.flags |= 524288 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 288 /* SourceFile */) { node = node.parent; } return node; @@ -8821,11 +9304,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return true; } return false; @@ -8910,7 +9393,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -8993,7 +9476,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 === 313 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 317 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9012,7 +9495,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9058,6 +9541,8 @@ var ts; ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } + // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text + // had to include a backslash: `not \${a} substitution`. 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. @@ -9070,15 +9555,21 @@ var ts; return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } case 14 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings - return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings - return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 17 /* TemplateTail */: - return "}" + escapeText(node.text, 96 /* backtick */) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + switch (node.kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + return "`" + rawText + "`"; + case 15 /* TemplateHead */: + return "`" + rawText + "${"; + case 16 /* TemplateMiddle */: + return "}" + rawText + "${"; + case 17 /* TemplateTail */: + return "}" + rawText + "`"; + } + break; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 13 /* RegularExpressionLiteral */: @@ -9104,7 +9595,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 241 /* VariableDeclaration */ && node.parent.kind === 278 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9136,16 +9627,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 248 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 288 /* SourceFile */ || + node.kind === 248 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -9157,9 +9648,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 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9173,24 +9664,61 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /** + * Returns whether the source file will be treated as if it were in strict mode at runtime. + */ + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + // We can only verify strict mode for JS/TS files + switch (node.scriptKind) { + case 1 /* JS */: + case 3 /* TS */: + case 2 /* JSX */: + case 4 /* TSX */: + break; + default: + return false; + } + // Strict mode does not matter for declaration files. + if (node.isDeclarationFile) { + return false; + } + // If `alwaysStrict` is set, then treat the file as strict. + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + // Starting with a "use strict" directive indicates the file is strict. + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + // ECMAScript Modules are always strict. + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + // Other modules are strict unless otherwise specified. + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 278 /* CatchClause */: + case 248 /* ModuleDeclaration */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 219 /* Block */: + case 222 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9200,9 +9728,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 299 /* JSDocSignature */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 303 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9212,25 +9740,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9240,8 +9768,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9250,15 +9778,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 224 /* VariableStatement */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -9288,13 +9816,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -9305,11 +9833,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9354,7 +9882,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 222 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9368,7 +9896,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* 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 @@ -9377,25 +9905,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 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9403,6 +9931,7 @@ var ts; // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9432,7 +9961,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -9444,19 +9973,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 101 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 95 /* ImportKeyword */; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 95 /* ImportKeyword */ + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 225 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9465,11 +10000,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 155 /* Parameter */ || + node.kind === 154 /* TypeParameter */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 201 /* ArrowFunction */ || + node.kind === 199 /* 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 '/**/' @@ -9485,48 +10020,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= node.kind && node.kind <= 187 /* LastTypeNode */) { return true; } switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: return true; - case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + case 109 /* VoidKeyword */: + return node.parent.kind !== 204 /* VoidExpression */; + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 154 /* TypeParameter */: + return node.parent.kind === 185 /* MappedType */ || node.parent.kind === 180 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 73 /* Identifier */: + case 75 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 193 /* 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 === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */ || node.kind === 193 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: - case 101 /* ThisKeyword */: { + case 152 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 103 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 171 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 187 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9535,40 +10070,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 (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= parent.kind && parent.kind <= 187 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return node === parent.constraint; - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9593,23 +10128,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 250 /* CaseBlock */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9619,26 +10154,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* 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 === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* 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); @@ -9661,10 +10196,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 173 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 168 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9674,12 +10209,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 172 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return node.properties; } } @@ -9687,14 +10222,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 282 /* EnumMember */: + case 155 /* Parameter */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 241 /* VariableDeclaration */: return true; } } @@ -9706,8 +10241,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 242 /* VariableDeclarationList */ + && node.parent.parent.kind === 224 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9718,13 +10253,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return true; } return false; @@ -9735,7 +10270,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 237 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9743,17 +10278,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 222 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 160 /* MethodDeclaration */ && node.parent.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 160 /* MethodDeclaration */ && + (node.parent.kind === 192 /* ObjectLiteralExpression */ || + node.parent.kind === 213 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9766,7 +10301,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9807,14 +10342,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 288 /* 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 150 /* ComputedPropertyName */: + case 153 /* 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 @@ -9829,9 +10364,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* 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; @@ -9842,26 +10377,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 248 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 247 /* EnumDeclaration */: + case 288 /* SourceFile */: return node; } } @@ -9871,9 +10406,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return container; } } @@ -9895,27 +10430,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* 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; @@ -9931,21 +10466,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 200 /* FunctionExpression */ || func.kind === 201 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 199 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 195 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 /* SuperKeyword */ + return node.kind === 101 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -9954,8 +10489,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 99 /* SuperKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 101 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -9963,20 +10498,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 101 /* ThisKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 103 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: return node; } return undefined; @@ -9984,10 +10519,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9996,25 +10531,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 244 /* ClassDeclaration */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* 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 === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 244 /* ClassDeclaration */; + case 155 /* 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 === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 161 /* Constructor */ + || parent.kind === 160 /* MethodDeclaration */ + || parent.kind === 163 /* SetAccessor */) + && grandparent.kind === 244 /* ClassDeclaration */; } return false; } @@ -10030,10 +10565,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10042,9 +10577,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 266 /* JsxOpeningElement */ || + parent.kind === 265 /* JsxSelfClosingElement */ || + parent.kind === 267 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10052,57 +10587,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 216 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 212 /* SpreadElement */: + case 210 /* TemplateExpression */: + case 214 /* OmittedExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 211 /* YieldExpression */: + case 205 /* AwaitExpression */: + case 218 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 152 /* QualifiedName */: + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); - case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node); + case 75 /* Identifier */: + if (node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -10112,49 +10647,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 190 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 225 /* ExpressionStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 234 /* ReturnStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 238 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 229 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 156 /* Decorator */: + case 274 /* JsxExpression */: + case 273 /* JsxSpreadAttribute */: + case 281 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10162,7 +10697,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10171,7 +10706,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 263 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10183,15 +10718,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 131072 /* JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 4194304 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10199,15 +10734,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 /* StringKeyword */ || node.typeArguments[0].kind === 136 /* NumberKeyword */); + (node.typeArguments[0].kind === 142 /* StringKeyword */ || node.typeArguments[0].kind === 139 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + if (callExpression.kind !== 195 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 75 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -10238,21 +10773,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - 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 === 60 /* EqualsToken */ && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 /* EqualsToken */ && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -10262,13 +10801,14 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(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 === 55 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -10282,14 +10822,20 @@ var ts; } 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); }); + 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 === 60 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -10315,11 +10861,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 200 /* FunctionExpression */ || e.kind === 201 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 200 /* FunctionExpression */ || + initializer.kind === 213 /* ClassExpression */ || + initializer.kind === 201 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10336,14 +10882,16 @@ 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 === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && 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 === 60 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -10351,8 +10899,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 === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -10371,19 +10919,20 @@ var ts; * my.app = self.my.app || class { } */ function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 /* ThisKeyword */ || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -10398,10 +10947,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { @@ -10416,55 +10968,116 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0]); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */) || + isEntityNameExpression(node.expression) || + isBindableStaticElementAccessExpression(node.expression, /*excludeThisKeyword*/ true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */ || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0 /* None */; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8 /* ObjectDefinePropertyExports */; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9 /* ObjectDefinePrototypeProperty */; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 60 /* EqualsToken */ || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left)) { return 0 /* None */; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } return 6 /* Prototype */; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); + } + /** + * Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions + * throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand) + */ + /* @internal */ + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; + } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101 /* ThisKeyword */) { + if (lhs.expression.kind === 103 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") { // exports.name = expr OR module.exports.name = expr return 1 /* ExportsProperty */; } @@ -10487,7 +11100,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 225 /* ExpressionStatement */ && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10496,7 +11110,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10505,14 +11119,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 186 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10522,12 +11136,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 252 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 263 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 187 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10536,11 +11150,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10548,19 +11162,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 253 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 155 /* Parameter */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 280 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10574,7 +11188,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 /* JSDocTypedefTag */ || node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 315 /* JSDocTypedefTag */ || node.kind === 308 /* JSDocCallbackTag */ || node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10584,7 +11198,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 /* EqualsToken */ + node.expression.operatorToken.kind === 62 /* EqualsToken */ ? node.expression.right : undefined; } @@ -10593,18 +11207,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 /* BarBarToken */ + (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return node.initializer; } } @@ -10615,7 +11229,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 248 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10630,11 +11244,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 154 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10645,12 +11259,12 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 279 /* PropertyAssignment */ || + parent.kind === 258 /* ExportAssignment */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 225 /* ExpressionStatement */ && node.kind === 193 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10661,7 +11275,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10684,7 +11298,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10709,7 +11323,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10719,7 +11333,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 === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10732,31 +11346,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 62 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 191 /* ArrayLiteralExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10783,22 +11397,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 222 /* Block */: + case 224 /* VariableStatement */: + case 235 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return true; } return false; @@ -10815,33 +11429,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 181 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 199 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* 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 !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 202 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10863,11 +11477,12 @@ var ts; var parent = name.parent; switch (name.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -10890,8 +11505,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10899,32 +11514,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 193 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 152 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 171 /* TypeQuery */ || parent.kind === 168 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 190 /* BindingElement */: + case 257 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 261 /* ExportSpecifier */: + case 271 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10940,22 +11555,39 @@ var ts; // export = // export default // module.exports = + // {} + // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); + return node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 251 /* NamespaceExportDeclaration */ || + node.kind === 254 /* ImportClause */ && !!node.name || + node.kind === 255 /* NamespaceImport */ || + node.kind === 257 /* ImportSpecifier */ || + node.kind === 261 /* ExportSpecifier */ || + node.kind === 258 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 280 /* ShorthandPropertyAssignment */ || + node.kind === 279 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 279 /* PropertyAssignment */ ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -10969,24 +11601,24 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 112 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -11013,22 +11645,31 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 76 /* FirstKeyword */ <= token && token <= 151 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 121 /* FirstContextualKeyword */ <= token && token <= 151 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 112 /* FirstFutureReservedWord */ <= token && token <= 120 /* LastFutureReservedWord */; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -11052,14 +11693,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11073,10 +11714,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11089,7 +11730,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 /* PlusToken */ || node.operator === 39 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -11109,10 +11750,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 /* ComputedPropertyName */ || name.kind === 194 /* ElementAccessExpression */)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; /** @@ -11126,12 +11770,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11147,7 +11791,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -11158,11 +11802,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 75 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -11177,7 +11821,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 75 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -11186,11 +11830,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 155 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 190 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11198,15 +11842,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 161 /* Constructor */ + || kind === 200 /* FunctionExpression */ + || kind === 243 /* FunctionDeclaration */ + || kind === 201 /* ArrowFunction */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 248 /* ModuleDeclaration */ + || kind === 288 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11225,38 +11869,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operator) { - case 41 /* AsteriskAsteriskToken */: - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 42 /* AsteriskAsteriskToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 1 /* Right */; } } @@ -11265,15 +11909,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 208 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 206 /* PrefixUnaryExpression */ || expression.kind === 207 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11283,73 +11927,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 197 /* TaggedTemplateExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 19; - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 73 /* Identifier */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 75 /* Identifier */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 210 /* TemplateExpression */: + case 199 /* ParenthesizedExpression */: + case 214 /* OmittedExpression */: return 20; default: return -1; @@ -11358,41 +12002,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: + return 4; + case 56 /* BarBarToken */: return 5; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return 6; - case 50 /* BarToken */: + case 51 /* BarToken */: return 7; - case 51 /* CaretToken */: + case 52 /* CaretToken */: return 8; - case 49 /* AmpersandToken */: + case 50 /* AmpersandToken */: return 9; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return 10; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: return 11; - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 38 /* PlusToken */: - case 39 /* MinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: return 13; - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: return 14; - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -11469,6 +12115,10 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -11476,7 +12126,8 @@ var ts; // There is no reason for this other than that JSON.stringify does not handle it either. var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + // Template strings should be preserved as much as possible + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -11505,22 +12156,23 @@ var ts; } ts.escapeString = escapeString; /** - * Strip off existed single quotes or double quotes from a given string + * Strip off existed surrounding single quotes, double quotes, or backticks from a given string * * @return non-quoted string */ function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 /* singleQuote */ || + charCode === 34 /* doubleQuote */ || + charCode === 96 /* backtick */; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0 /* nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); @@ -11571,6 +12223,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -11582,7 +12235,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -11592,17 +12245,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -11616,6 +12281,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -11635,6 +12301,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -11649,12 +12317,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -11662,7 +12330,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -11718,7 +12386,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -11837,6 +12505,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; /** Get the type annotation for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); @@ -11858,11 +12527,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 75 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101 /* ThisKeyword */; + return id.originalKeywordKind === 103 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -11873,10 +12542,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 163 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11896,10 +12565,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 162 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 163 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11945,7 +12614,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 === 297 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12185,7 +12854,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 73 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 75 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -12193,29 +12862,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117 /* StaticKeyword */: return 32 /* Static */; - case 116 /* PublicKeyword */: return 4 /* Public */; - case 115 /* ProtectedKeyword */: return 16 /* Protected */; - case 114 /* PrivateKeyword */: return 8 /* Private */; - case 119 /* AbstractKeyword */: return 128 /* Abstract */; - case 86 /* ExportKeyword */: return 1 /* Export */; - case 126 /* DeclareKeyword */: return 2 /* Ambient */; - case 78 /* ConstKeyword */: return 2048 /* Const */; - case 81 /* DefaultKeyword */: return 512 /* Default */; - case 122 /* AsyncKeyword */: return 256 /* Async */; - case 134 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 119 /* StaticKeyword */: return 32 /* Static */; + case 118 /* PublicKeyword */: return 4 /* Public */; + case 117 /* ProtectedKeyword */: return 16 /* Protected */; + case 116 /* PrivateKeyword */: return 8 /* Private */; + case 121 /* AbstractKeyword */: return 128 /* Abstract */; + case 88 /* ExportKeyword */: return 1 /* Export */; + case 129 /* DeclareKeyword */: return 2 /* Ambient */; + case 80 /* ConstKeyword */: return 2048 /* Const */; + case 83 /* DefaultKeyword */: return 512 /* Default */; + case 125 /* AsyncKeyword */: return 256 /* Async */; + case 137 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 /* BarBarToken */ - || token === 54 /* AmpersandAmpersandToken */ - || token === 52 /* ExclamationToken */; + return token === 56 /* BarBarToken */ + || token === 55 /* AmpersandAmpersandToken */ + || token === 53 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 /* FirstAssignment */ && token <= 72 /* LastAssignment */; + return token >= 62 /* FirstAssignment */ && token <= 74 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -12228,14 +12897,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 /* EqualsToken */ + ? node.operatorToken.kind === 62 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -12243,8 +12912,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 192 /* ObjectLiteralExpression */ + || kind === 191 /* ArrayLiteralExpression */; } return false; } @@ -12254,9 +12923,15 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function isDottedName(node) { + return node.kind === 75 /* Identifier */ || node.kind === 103 /* ThisKeyword */ || + node.kind === 193 /* PropertyAccessExpression */ && isDottedName(node.expression) || + node.kind === 199 /* ParenthesizedExpression */ && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -12272,21 +12947,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 192 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 191 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12584,8 +13259,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12662,35 +13337,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 208 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 279 /* 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 277 /* ShorthandPropertyAssignment */: + case 280 /* 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 188 /* ArrayLiteralExpression */: + case 191 /* 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 === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12736,8 +13411,8 @@ var ts; /** * Mutates the map with newMap such that keys in map will be same as newMap. */ - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; // Needs update map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); @@ -12751,6 +13426,15 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + /** + * Mutates the map with newMap such that keys in map will be same as newMap. + */ + function mutateMap(map, newMap, options) { + // Needs update + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; // Add new values that are not already present newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { @@ -12760,7 +13444,6 @@ var ts; }); } ts.mutateMap = mutateMap; - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -12845,32 +13528,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) - || kind === 121 /* AnyKeyword */ - || kind === 144 /* UnknownKeyword */ - || kind === 136 /* NumberKeyword */ - || kind === 147 /* BigIntKeyword */ - || kind === 137 /* ObjectKeyword */ - || kind === 124 /* BooleanKeyword */ - || kind === 139 /* StringKeyword */ - || kind === 140 /* SymbolKeyword */ - || kind === 101 /* ThisKeyword */ - || kind === 107 /* VoidKeyword */ - || kind === 142 /* UndefinedKeyword */ - || kind === 97 /* NullKeyword */ - || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + return (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) + || kind === 124 /* AnyKeyword */ + || kind === 147 /* UnknownKeyword */ + || kind === 139 /* NumberKeyword */ + || kind === 150 /* BigIntKeyword */ + || kind === 140 /* ObjectKeyword */ + || kind === 127 /* BooleanKeyword */ + || kind === 142 /* StringKeyword */ + || kind === 143 /* SymbolKeyword */ + || kind === 103 /* ThisKeyword */ + || kind === 109 /* VoidKeyword */ + || kind === 145 /* UndefinedKeyword */ + || kind === 99 /* NullKeyword */ + || kind === 136 /* NeverKeyword */ + || kind === 215 /* ExpressionWithTypeArguments */ + || kind === 293 /* JSDocAllType */ + || kind === 294 /* JSDocUnknownType */ + || kind === 295 /* JSDocNullableType */ + || kind === 296 /* JSDocNonNullableType */ + || kind === 297 /* JSDocOptionalType */ + || kind === 298 /* JSDocFunctionType */ + || kind === 299 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */ || node.kind === 194 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -12883,6 +13566,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -12990,7 +13677,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13107,17 +13794,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 154 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245 /* InterfaceDeclaration */) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 161 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13147,14 +13834,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 241 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 242 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 224 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13218,7 +13905,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13300,27 +13988,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: var expr = hostNode.expression; + if (expr.kind === 208 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + expr = expr.left; + } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13332,6 +14023,17 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + /** @internal */ + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -13344,39 +14046,46 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return declaration; - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: { + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 152 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: case 4 /* ThisProperty */: case 5 /* Property */: case 3 /* PrototypeProperty */: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 309 /* JSDocEnumTag */: + return nameForNamelessJSDocTypedef(declaration); + case 258 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194 /* ElementAccessExpression */: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -13399,8 +14108,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -13578,7 +14287,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 301 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13598,10 +14307,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13646,198 +14354,216 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73 /* Identifier */; + return node.kind === 75 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 152 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 153 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 154 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 155 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 157 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 158 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 159 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 161 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 164 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 165 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 166 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 163 /* SetAccessor */ || node.kind === 162 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 167 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 168 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 169 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 170 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 171 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 172 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 173 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 174 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 177 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 178 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 179 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 180 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 181 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 182 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 183 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 184 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 185 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 186 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 187 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 188 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 189 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 190 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 191 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 194 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 195 /* CallExpression */; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + return isPropertyAccessChain(node) + || isElementAccessChain(node) + || isCallChain(node); + } + ts.isOptionalChain = isOptionalChain; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 196 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 197 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 198 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -13846,376 +14572,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 199 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315 /* PartiallyEmittedExpression */) { + while (node.kind === 319 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 200 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 201 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 202 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 203 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 204 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 205 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 206 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 207 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 208 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 209 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 210 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 211 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 212 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 213 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 214 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 216 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 217 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 218 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 220 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 221 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 222 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 224 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 223 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 225 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 226 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 227 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 228 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 229 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 230 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 231 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 232 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 233 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 233 /* BreakStatement */ || node.kind === 232 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 234 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 235 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 236 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 237 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 238 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 239 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 240 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 241 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 242 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 243 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 244 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 245 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 246 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 247 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 248 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 249 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 250 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 251 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 252 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 253 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 254 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 255 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 256 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 257 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 258 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 259 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 260 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 261 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 262 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 264 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 265 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 266 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 267 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 268 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 269 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 270 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 271 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 272 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 273 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 274 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 275 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 276 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 277 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 278 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 279 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 280 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 281 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 288 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 289 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 290 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 284 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return true; default: return false; @@ -14224,105 +14950,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 283 /* UnparsedPrologue */ || + node.kind === 287 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 292 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 293 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 294 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 295 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 296 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 297 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 298 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 299 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297 /* JSDocComment */; + return node.kind === 301 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302 /* JSDocAuthorTag */; + return node.kind === 306 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301 /* JSDocAugmentsTag */; + return node.kind === 305 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303 /* JSDocClassTag */; + return node.kind === 307 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305 /* JSDocEnumTag */; + return node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308 /* JSDocThisTag */; + return node.kind === 312 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307 /* JSDocReturnTag */; + return node.kind === 311 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309 /* JSDocTypeTag */; + return node.kind === 313 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310 /* JSDocTemplateTag */; + return node.kind === 314 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311 /* JSDocTypedefTag */; + return node.kind === 315 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312 /* JSDocPropertyTag */; + return node.kind === 316 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 /* JSDocPropertyTag */ || node.kind === 306 /* JSDocParameterTag */; + return node.kind === 316 /* JSDocPropertyTag */ || node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298 /* JSDocTypeLiteral */; + return node.kind === 302 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 308 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299 /* JSDocSignature */; + return node.kind === 303 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14333,7 +15059,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 313 /* SyntaxList */; + return n.kind === 317 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14343,7 +15069,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 152 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14352,7 +15078,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 <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 151 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14405,17 +15131,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 81 /* DefaultKeyword */: - case 86 /* ExportKeyword */: - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 117 /* StaticKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 83 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 119 /* StaticKeyword */: return true; } return false; @@ -14428,7 +15154,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 119 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -14437,23 +15163,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ + return kind === 75 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 153 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + return kind === 75 /* Identifier */ + || kind === 188 /* ObjectBindingPattern */ + || kind === 189 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14468,13 +15194,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: return false; @@ -14483,14 +15209,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 170 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14505,29 +15231,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 161 /* Constructor */ + || kind === 158 /* PropertyDeclaration */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 166 /* IndexSignature */ + || kind === 221 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; default: return false; @@ -14537,11 +15263,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 165 /* ConstructSignature */ + || kind === 164 /* CallSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */ + || kind === 166 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14550,12 +15276,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 279 /* PropertyAssignment */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 281 /* SpreadAssignment */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14570,8 +15296,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return true; } return false; @@ -14582,8 +15308,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 189 /* ArrayBindingPattern */ + || kind === 188 /* ObjectBindingPattern */; } return false; } @@ -14591,15 +15317,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 191 /* ArrayLiteralExpression */ + || kind === 192 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 190 /* BindingElement */ + || kind === 214 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14608,9 +15334,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: return true; } return false; @@ -14631,8 +15357,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return true; } return false; @@ -14644,8 +15370,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return true; } return false; @@ -14654,26 +15380,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */ + || kind === 187 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 156 /* Decorator */: return true; default: return false; @@ -14681,12 +15407,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 195 /* CallExpression */ || node.kind === 196 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 210 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14697,34 +15423,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 73 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 197 /* TaggedTemplateExpression */: + case 191 /* ArrayLiteralExpression */: + case 199 /* ParenthesizedExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 75 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 103 /* TrueKeyword */: - case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: - case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 210 /* TemplateExpression */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 105 /* TrueKeyword */: + case 101 /* SuperKeyword */: + case 217 /* NonNullExpression */: + case 218 /* MetaProperty */: + case 95 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -14737,13 +15463,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 198 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14752,11 +15478,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 44 /* PlusPlusToken */ || - expr.operator === 45 /* MinusMinusToken */; + case 206 /* PrefixUnaryExpression */: + return expr.operator === 45 /* PlusPlusToken */ || + expr.operator === 46 /* MinusMinusToken */; default: return false; } @@ -14773,15 +15499,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 316 /* CommaListExpression */: - case 315 /* PartiallyEmittedExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: + case 201 /* ArrowFunction */: + case 208 /* BinaryExpression */: + case 212 /* SpreadElement */: + case 216 /* AsExpression */: + case 214 /* OmittedExpression */: + case 320 /* CommaListExpression */: + case 319 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14789,21 +15515,26 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 198 /* TypeAssertionExpression */ + || kind === 216 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 315 /* PartiallyEmittedExpression */; + return node.kind === 319 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 314 /* NotEmittedStatement */; + return node.kind === 318 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ + function isSyntheticReference(node) { + return node.kind === 323 /* SyntheticReferenceExpression */; + } + ts.isSyntheticReference = isSyntheticReference; + /* @internal */ function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -14811,21 +15542,42 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; /* @internal */ + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + /* @internal */ + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + /* @internal */ + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + /* @internal */ + function isExternalModuleIndicator(result) { + // Exported top-level member indicates moduleness + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; + /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 230 /* ForInStatement */ || node.kind === 231 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14849,113 +15601,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ - || kind === 73 /* Identifier */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */ + || kind === 75 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + return kind === 75 /* Identifier */ + || kind === 248 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 256 /* NamedImports */ + || kind === 255 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 248 /* ModuleDeclaration */ || node.kind === 247 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 311 /* JSDocTypedefTag */ - || kind === 304 /* JSDocCallbackTag */ - || kind === 312 /* JSDocPropertyTag */; + return kind === 201 /* ArrowFunction */ + || kind === 190 /* BindingElement */ + || kind === 244 /* ClassDeclaration */ + || kind === 213 /* ClassExpression */ + || kind === 161 /* Constructor */ + || kind === 247 /* EnumDeclaration */ + || kind === 282 /* EnumMember */ + || kind === 261 /* ExportSpecifier */ + || kind === 243 /* FunctionDeclaration */ + || kind === 200 /* FunctionExpression */ + || kind === 162 /* GetAccessor */ + || kind === 254 /* ImportClause */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 257 /* ImportSpecifier */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 271 /* JsxAttribute */ + || kind === 160 /* MethodDeclaration */ + || kind === 159 /* MethodSignature */ + || kind === 248 /* ModuleDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 255 /* NamespaceImport */ + || kind === 155 /* Parameter */ + || kind === 279 /* PropertyAssignment */ + || kind === 158 /* PropertyDeclaration */ + || kind === 157 /* PropertySignature */ + || kind === 163 /* SetAccessor */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 154 /* TypeParameter */ + || kind === 241 /* VariableDeclaration */ + || kind === 315 /* JSDocTypedefTag */ + || kind === 308 /* JSDocCallbackTag */ + || kind === 316 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 243 /* FunctionDeclaration */ + || kind === 262 /* MissingDeclaration */ + || kind === 244 /* ClassDeclaration */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 247 /* EnumDeclaration */ + || kind === 248 /* ModuleDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 258 /* ExportAssignment */ + || kind === 251 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 314 /* NotEmittedStatement */ - || kind === 318 /* EndOfDeclarationMarker */ - || kind === 317 /* MergeDeclarationMarker */; + return kind === 233 /* BreakStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 227 /* DoStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 223 /* EmptyStatement */ + || kind === 230 /* ForInStatement */ + || kind === 231 /* ForOfStatement */ + || kind === 229 /* ForStatement */ + || kind === 226 /* IfStatement */ + || kind === 237 /* LabeledStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 236 /* SwitchStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 239 /* TryStatement */ + || kind === 224 /* VariableStatement */ + || kind === 228 /* WhileStatement */ + || kind === 235 /* WithStatement */ + || kind === 318 /* NotEmittedStatement */ + || kind === 322 /* EndOfDeclarationMarker */ + || kind === 321 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 310 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 154 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 314 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14982,10 +15734,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 222 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 239 /* TryStatement */ || node.parent.kind === 278 /* CatchClause */) { return false; } } @@ -14995,83 +15747,88 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 263 /* ExternalModuleReference */ + || kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 /* ThisKeyword */ - || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + return kind === 103 /* ThisKeyword */ + || kind === 75 /* Identifier */ + || kind === 193 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 264 /* JsxElement */ + || kind === 274 /* JsxExpression */ + || kind === 265 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 268 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 271 /* JsxAttribute */ + || kind === 273 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 274 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 266 /* JsxOpeningElement */ + || kind === 265 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 275 /* CaseClause */ + || kind === 276 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 312 /* LastJSDocNode */; + return node.kind >= 292 /* FirstJSDocNode */ && node.kind <= 316 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 297 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 /* 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 >= 300 /* FirstJSDocTagNode */ && node.kind <= 312 /* LastJSDocTagNode */; + return node.kind >= 304 /* FirstJSDocTagNode */ && node.kind <= 316 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; + /* @internal */ + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; + } + ts.isOptionalChainRoot = isOptionalChainRoot; /** True if has jsdoc nodes attached to it. */ /* @internal */ // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times @@ -15099,12 +15856,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 271 /* JsxAttribute */ || node.kind === 273 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 168 /* TypeReference */ || node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15140,7 +15897,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 256 /* NamedImports */ || node.kind === 260 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15158,7 +15915,7 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature() { } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15175,6 +15932,7 @@ var ts; this.text = text; this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } + // eslint-disable-next-line prefer-const ts.objectAllocator = { getNodeConstructor: function () { return Node; }, getTokenConstructor: function () { return Node; }, @@ -15621,7 +16379,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } /** * Parse a path into an array containing a root component (at index 0) and zero or more path @@ -15699,6 +16457,37 @@ var ts; return ""; return pathComponents.slice(1).join(ts.directorySeparator); } + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); + } + return result; + } + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); + } + return [getPathFromPathComponents(aParts), getPathFromPathComponents(bParts)]; + } + // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. + // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); + } })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -15721,7 +16510,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -15802,7 +16591,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -16241,14 +17030,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; ts.supportedJSAndJsonExtensions = [".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json" /* Json */]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json" /* Json */]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -16262,7 +17051,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json" /* Json */]); + return __spreadArrays(supportedExtensions, [".json" /* Json */]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -16574,14 +17363,17 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { + function skipTypeChecking(sourceFile, options, host) { // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a // '/// ' directive. - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16685,17 +17477,15 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 288 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73 /* Identifier */) { + else if (kind === 75 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -16744,19 +17534,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 <= 148 /* LastToken */) { + if (!node || node.kind <= 151 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16764,9 +17554,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -16774,7 +17564,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16782,51 +17572,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 157 /* 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 276 /* PropertyAssignment */: + case 279 /* 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 238 /* VariableDeclaration */: + case 241 /* 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 187 /* BindingElement */: + case 190 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -16838,345 +17628,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || + case 167 /* TypePredicate */: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 174 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 180 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 187 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 181 /* ParenthesizedType */: + case 183 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 185 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 156 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* 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 242 /* InterfaceDeclaration */: + case 245 /* 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 243 /* TypeAliasDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 292 /* JSDocTypeExpression */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 297 /* JSDocOptionalType */: + case 299 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297 /* JSDocComment */: + case 301 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302 /* JSDocAuthorTag */: + case 306 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 292 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocSignature */: + case 303 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 300 /* JSDocTag */: - case 303 /* JSDocClassTag */: + case 304 /* JSDocTag */: + case 307 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17185,12 +17980,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100 /* JSON */) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -17228,7 +18025,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -17257,14 +18054,12 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; + var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17274,6 +18069,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; // Flags that dictate what parsing context we're in. For example: // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is // that some tokens that would be considered identifiers may be considered keywords. @@ -17394,18 +18190,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(225 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 39 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -17414,7 +18210,7 @@ var ts; break; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -17430,6 +18226,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17455,10 +18254,10 @@ var ts; switch (scriptKind) { case 1 /* JS */: case 2 /* JSX */: - contextFlags = 65536 /* JavaScriptFile */; + contextFlags = 131072 /* JavaScriptFile */; break; case 6 /* JSON */: - contextFlags = 65536 /* JavaScriptFile */ | 16777216 /* JsonFile */; + contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */; break; default: contextFlags = 0 /* None */; @@ -17481,11 +18280,12 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304 /* Ambient */; + contextFlags |= 8388608 /* Ambient */; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -17550,7 +18350,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(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(288 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17571,16 +18371,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048 /* DisallowInContext */); + setContextFlag(val, 4096 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 4096 /* YieldContext */); + setContextFlag(val, 8192 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 8192 /* DecoratorContext */); + setContextFlag(val, 16384 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 16384 /* AwaitContext */); + setContextFlag(val, 32768 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -17621,40 +18421,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(2048 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(4096 /* YieldContext */, func); + return doInsideOfContext(8192 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384 /* AwaitContext */, func); + return doInsideOfContext(32768 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); + return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096 /* YieldContext */); + return inContext(8192 /* YieldContext */); } function inDisallowInContext() { - return inContext(2048 /* DisallowInContext */); + return inContext(4096 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(8192 /* DecoratorContext */); + return inContext(16384 /* DecoratorContext */); } function inAwaitContext() { - return inContext(16384 /* AwaitContext */); + return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -17690,9 +18490,17 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + // if the keyword had an escape + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + // issue a parse error for the escape + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -17761,20 +18569,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 73 /* Identifier */) { + if (token() === 75 /* 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() === 118 /* YieldKeyword */ && inYieldContext()) { + if (token() === 120 /* 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() === 123 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 126 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 109 /* LastReservedWord */; + return token() > 111 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -17862,7 +18670,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 73 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 75 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -17892,7 +18700,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768 /* ThisNodeHasError */; + node.flags |= 65536 /* ThisNodeHasError */; } return node; } @@ -17904,7 +18712,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73 /* Identifier */) { + if (kind === 75 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -17925,18 +18733,18 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73 /* Identifier */); + var node = createNode(75 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 73 /* Identifier */) { + if (token() !== 75 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(73 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -17967,7 +18775,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(153 /* 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 @@ -17988,20 +18796,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 85 /* EnumKeyword */; - case 86 /* ExportKeyword */: + return nextToken() === 87 /* EnumKeyword */; + case 88 /* ExportKeyword */: nextToken(); - if (token() === 81 /* DefaultKeyword */) { + if (token() === 83 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 /* AsteriskToken */ && token() !== 120 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); - case 81 /* DefaultKeyword */: + return token() !== 41 /* AsteriskToken */ && token() !== 122 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 83 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 117 /* StaticKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + case 119 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -18014,16 +18822,16 @@ var ts; function canFollowModifier() { return token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */ - || token() === 40 /* AsteriskToken */ + || token() === 41 /* AsteriskToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 /* ClassKeyword */ || token() === 91 /* FunctionKeyword */ || - token() === 111 /* InterfaceKeyword */ || - (token() === 119 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 /* ClassKeyword */ || token() === 93 /* FunctionKeyword */ || + token() === 113 /* InterfaceKeyword */ || + (token() === 121 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -18043,7 +18851,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -18059,7 +18867,7 @@ var ts; case 12 /* ObjectLiteralMembers */: switch (token()) { case 22 /* OpenBracketToken */: - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; @@ -18129,7 +18937,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 87 /* ExtendsKeyword */ || next === 110 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 89 /* ExtendsKeyword */ || next === 112 /* ImplementsKeyword */; } return true; } @@ -18146,8 +18954,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 /* ImplementsKeyword */ || - token() === 87 /* ExtendsKeyword */) { + if (token() === 112 /* ImplementsKeyword */ || + token() === 89 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -18177,14 +18985,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -18203,9 +19011,9 @@ var ts; case 22 /* HeritageClauses */: return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; + return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -18225,7 +19033,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() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -18300,7 +19108,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 12679168 /* ContextFlags */; + var nodeContextFlags = node.flags & 25358336 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -18401,20 +19209,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 161 /* Constructor */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 221 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 160 /* 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 === 73 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 125 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 75 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 128 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -18423,8 +19231,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: return true; } } @@ -18433,58 +19241,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 224 /* VariableStatement */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 225 /* ExpressionStatement */: + case 238 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 236 /* SwitchStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 223 /* EmptyStatement */: + case 239 /* TryStatement */: + case 237 /* LabeledStatement */: + case 227 /* DoStatement */: + case 240 /* DebuggerStatement */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 157 /* PropertySignature */: + case 164 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 241 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18505,7 +19313,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 155 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18572,7 +19380,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18610,6 +19418,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18630,7 +19441,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24 /* DotToken */)) { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -18641,7 +19452,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(152 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18672,13 +19483,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(210 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18690,7 +19501,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(220 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -18719,6 +19530,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -18740,24 +19561,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 169 /* FunctionType */: + case 170 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -18765,20 +19586,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(167 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(182 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(293 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(297 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18786,7 +19607,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(296 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18807,63 +19628,80 @@ var ts; if (token() === 27 /* CommaToken */ || token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || - token() === 30 /* GreaterThanToken */ || - token() === 60 /* EqualsToken */ || - token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + token() === 31 /* GreaterThanToken */ || + token() === 62 /* EqualsToken */ || + token() === 51 /* BarToken */) { + var result = createNode(294 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(295 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(298 /* JSDocFunctionType */); nextToken(); - fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(58 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { + var parameter = createNode(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */ || token() === 98 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(134 /* ModuleKeyword */); + if (moduleSpecifier) { + var moduleTag = createNode(300 /* JSDocNamepathType */, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + case 27 /* CommaToken */: + case 5 /* WhitespaceTrivia */: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(299 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + if (token() === 62 /* EqualsToken */) { + return createPostfixType(297 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); - parseExpected(105 /* TypeOfKeyword */); + var node = createNode(171 /* TypeQuery */); + parseExpected(107 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(87 /* ExtendsKeyword */)) { + if (parseOptional(89 /* 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 @@ -18882,18 +19720,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60 /* EqualsToken */)) { + if (parseOptional(62 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (token() === 29 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(57 /* ColonToken */)) { + if (parseOptional(58 /* ColonToken */)) { return parseType(); } return undefined; @@ -18902,12 +19740,12 @@ var ts; return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 /* AtToken */ || + token() === 59 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */) { + var node = createNodeWithJSDoc(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); @@ -18929,7 +19767,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.questionToken = parseOptionalToken(57 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -18951,16 +19789,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(57 /* ColonToken */)) { + else if (parseOptional(58 /* ColonToken */)) { return true; } - else if (isType && token() === 37 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); nextToken(); return true; } @@ -19007,10 +19845,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { - parseExpected(96 /* NewKeyword */); + if (kind === 165 /* ConstructSignature */) { + parseExpected(98 /* NewKeyword */); } - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -19054,21 +19892,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* 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() !== 56 /* QuestionToken */) { + if (token() !== 57 /* 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() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 166 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19076,17 +19914,17 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + node.kind = 159 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 157 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* 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. @@ -19098,7 +19936,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return true; } var idToken = false; @@ -19120,20 +19958,20 @@ var ts; // the start of a member declaration if (idToken) { return token() === 20 /* OpenParenToken */ || - token() === 28 /* LessThanToken */ || - token() === 56 /* QuestionToken */ || - token() === 57 /* ColonToken */ || + token() === 29 /* LessThanToken */ || + token() === 57 /* QuestionToken */ || + token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + return parseSignatureMember(164 /* CallSignature */); } - if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + if (token() === 98 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19144,7 +19982,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; } function nextTokenIsDot() { return nextToken() === 24 /* DotToken */; @@ -19152,14 +19990,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20 /* OpenParenToken */: - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(172 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19176,37 +20014,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { - return nextToken() === 134 /* ReadonlyKeyword */; + if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + return nextToken() === 137 /* ReadonlyKeyword */; } - if (token() === 134 /* ReadonlyKeyword */) { + if (token() === 137 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 96 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(94 /* InKeyword */); + parseExpected(96 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(185 /* MappedType */); parseExpected(18 /* OpenBraceToken */); - if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 137 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { - parseExpectedToken(134 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { + parseExpectedToken(137 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); parseExpected(23 /* CloseBracketToken */); - if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56 /* QuestionToken */) { - parseExpectedToken(56 /* QuestionToken */); + if (node.questionToken.kind !== 57 /* QuestionToken */) { + parseExpectedToken(57 /* QuestionToken */); } } node.type = parseTypeAnnotation(); @@ -19217,23 +20055,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(176 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 4194304 /* JSDoc */) && type.kind === 295 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 175 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(174 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(181 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19241,9 +20079,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(98 /* NewKeyword */) ? 170 /* ConstructorType */ : 169 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(38 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -19251,14 +20089,14 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(186 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 39 /* MinusToken */; + unaryMinusExpression = createNode(206 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 40 /* MinusToken */; nextToken(); } - var expression = token() === 103 /* TrueKeyword */ || token() === 88 /* FalseKeyword */ + var expression = token() === 105 /* TrueKeyword */ || token() === 90 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -19271,23 +20109,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93 /* ImportKeyword */; + return token() === 95 /* ImportKeyword */; } function parseImportType() { - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); - if (parseOptional(105 /* TypeOfKeyword */)) { + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; + var node = createNode(187 /* ImportType */); + if (parseOptional(107 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); node.argument = parseType(); parseExpected(21 /* CloseParenToken */); if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } @@ -19297,50 +20135,54 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 140 /* SymbolKeyword */: - case 124 /* BooleanKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 143 /* SymbolKeyword */: + case 127 /* BooleanKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 63 /* AsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 56 /* QuestionToken */: + case 60 /* QuestionQuestionToken */: + // If there is '??', consider that is prefix '?' in JSDoc type. + scanner.reScanQuestionToken(); + // falls through + case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseLiteralTypeNode(); - case 39 /* MinusToken */: + case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 107 /* VoidKeyword */: - case 97 /* NullKeyword */: + case 109 /* VoidKeyword */: + case 99 /* NullKeyword */: return parseTokenNode(); - case 101 /* ThisKeyword */: { + case 103 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -19348,51 +20190,54 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportType(); + case 123 /* AssertsKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 134 /* ReadonlyKeyword */: - case 140 /* SymbolKeyword */: - case 143 /* UniqueKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 105 /* TypeOfKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 137 /* ReadonlyKeyword */: + case 143 /* SymbolKeyword */: + case 146 /* UniqueKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 107 /* TypeOfKeyword */: + case 136 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: - case 28 /* LessThanToken */: - case 50 /* BarToken */: - case 49 /* AmpersandToken */: - case 96 /* NewKeyword */: + case 29 /* LessThanToken */: + case 51 /* BarToken */: + case 50 /* AmpersandToken */: + case 98 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 137 /* ObjectKeyword */: - case 40 /* AsteriskToken */: - case 56 /* QuestionToken */: - case 52 /* ExclamationToken */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 140 /* ObjectKeyword */: + case 41 /* AsteriskToken */: + case 57 /* QuestionToken */: + case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 128 /* InferKeyword */: - case 93 /* ImportKeyword */: + case 131 /* InferKeyword */: + case 95 /* ImportKeyword */: + case 123 /* AssertsKeyword */: return true; - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return !inStartOfParameter; - case 39 /* MinusToken */: + case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -19410,27 +20255,27 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + case 53 /* ExclamationToken */: + type = createPostfixType(296 /* JSDocNonNullableType */, type); break; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type - if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { + if (!(contextFlags & 4194304 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(295 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(184 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(173 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19449,16 +20294,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(183 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); - parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var node = createNode(180 /* InferType */); + parseExpected(131 /* InferKeyword */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19466,11 +20311,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130 /* KeyOfKeyword */: - case 143 /* UniqueKeyword */: - case 134 /* ReadonlyKeyword */: + case 133 /* KeyOfKeyword */: + case 146 /* UniqueKeyword */: + case 137 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 128 /* InferKeyword */: + case 131 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -19491,13 +20336,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(178 /* IntersectionType */, parseTypeOperatorOrHigher, 50 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(177 /* UnionType */, parseIntersectionTypeOrHigher, 51 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { return true; } return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -19507,7 +20352,7 @@ var ts; // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 101 /* ThisKeyword */) { + if (isIdentifier() || token() === 103 /* ThisKeyword */) { nextToken(); return true; } @@ -19529,8 +20374,8 @@ 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() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 56 /* QuestionToken */ || token() === 60 /* EqualsToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 57 /* QuestionToken */ || token() === 62 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -19539,7 +20384,7 @@ var ts; } if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -19551,7 +20396,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(167 /* TypePredicate */, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19562,45 +20408,52 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167 /* TypePredicate */); + node.assertsModifier = parseExpectedToken(123 /* AssertsKeyword */); + node.parameterName = token() === 103 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132 /* IsKeyword */) ? parseType() : undefined; + return finishNode(node); + } function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 98 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89 /* ExtendsKeyword */)) { + var node = createNode(179 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(56 /* QuestionToken */); + parseExpected(57 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -19609,14 +20462,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 96 /* NewKeyword */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 73 /* Identifier */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 98 /* NewKeyword */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 75 /* Identifier */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -19627,18 +20480,18 @@ var ts; return true; } switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 28 /* LessThanToken */: - case 123 /* AwaitKeyword */: - case 118 /* YieldKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 29 /* LessThanToken */: + case 126 /* AwaitKeyword */: + case 120 /* 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. @@ -19657,9 +20510,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && - token() !== 58 /* AtToken */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && + token() !== 59 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -19682,7 +20535,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -19727,7 +20580,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 === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -19743,7 +20596,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118 /* YieldKeyword */) { + if (token() === 120 /* 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()) { @@ -19772,15 +20625,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(211 /* 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() === 40 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19791,20 +20644,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(201 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(201 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(155 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -19829,8 +20682,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(37 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -19840,10 +20693,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() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 122 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 125 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* 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. @@ -19853,12 +20706,12 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { return 0 /* False */; } } @@ -19872,8 +20725,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 37 /* EqualsGreaterThanToken */: - case 57 /* ColonToken */: + case 38 /* EqualsGreaterThanToken */: + case 58 /* ColonToken */: case 18 /* OpenBraceToken */: return 1 /* True */; default: @@ -19897,30 +20750,30 @@ var ts; // 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 !== 122 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 /* 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 !== 101 /* ThisKeyword */) { + if (!isIdentifier() && second !== 103 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 57 /* ColonToken */: + case 58 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 60 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -19929,7 +20782,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 28 /* LessThanToken */); + ts.Debug.assert(first === 29 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -19939,11 +20792,11 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87 /* ExtendsKeyword */) { + if (third === 89 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 60 /* EqualsToken */: - case 30 /* GreaterThanToken */: + case 62 /* EqualsToken */: + case 31 /* GreaterThanToken */: return false; default: return true; @@ -19964,11 +20817,19 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -19981,23 +20842,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() === 122 /* AsyncKeyword */) { + if (token() === 125 /* 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() === 37 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(201 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20007,7 +20868,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -20020,7 +20881,7 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -20031,8 +20892,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -20057,20 +20918,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(56 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* 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(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(209 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57 /* ColonToken */); + node.colonToken = parseExpectedToken(58 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + : createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -20078,7 +20939,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 96 /* InKeyword */ || t === 151 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20107,16 +20968,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() === 41 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 /* InKeyword */ && inDisallowInContext()) { + if (token() === 96 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -20137,51 +20998,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94 /* InKeyword */) { + if (inDisallowInContext() && token() === 96 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(208 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(216 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(202 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(203 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(204 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123 /* AwaitKeyword */) { + if (token() === 126 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -20191,7 +21052,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(205 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20215,7 +21076,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 /* AsteriskAsteriskToken */ ? + return token() === 42 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -20232,10 +21093,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41 /* AsteriskAsteriskToken */) { + if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 198 /* 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 { @@ -20260,23 +21121,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 82 /* DeleteKeyword */: + case 84 /* DeleteKeyword */: return parseDeleteExpression(); - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return parseVoidExpression(); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 123 /* AwaitKeyword */: + case 126 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -20299,16 +21160,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 123 /* AwaitKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 126 /* AwaitKeyword */: return false; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -20331,21 +21192,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20386,14 +21247,14 @@ 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() === 93 /* ImportKeyword */) { + if (token() === 95 /* ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { @@ -20401,21 +21262,22 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); - node.keywordToken = 93 /* ImportKeyword */; + var node = createNode(218 /* MetaProperty */, fullStart); + node.keywordToken = 95 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; + sourceFile.flags |= 2097152 /* PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 /* 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. + // CallExpression or OptionalExpression. As such, we need to consume the rest + // of it here to be complete. return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { @@ -20467,11 +21329,11 @@ var ts; // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -20483,7 +21345,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(193 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20492,8 +21354,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 266 /* JsxOpeningElement */) { + var node = createNode(264 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20502,15 +21364,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 269 /* JsxOpeningFragment */) { + var node = createNode(268 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 265 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20521,11 +21383,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 28 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(208 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20555,7 +21417,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29 /* LessThanSlashToken */: + case 30 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; case 11 /* JsxText */: @@ -20563,7 +21425,7 @@ var ts; return parseJsxText(); case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -20584,16 +21446,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(272 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28 /* LessThanToken */); - if (token() === 30 /* GreaterThanToken */) { + parseExpected(29 /* LessThanToken */); + if (token() === 31 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(269 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20601,23 +21463,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30 /* GreaterThanToken */) { + if (token() === 31 /* 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(263 /* JsxOpeningElement */, fullStart); + node = createNode(266 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(42 /* SlashToken */); + parseExpected(43 /* SlashToken */); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(265 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20631,10 +21493,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() === 101 /* ThisKeyword */ ? + var expression = token() === 103 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20642,7 +21504,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(274 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -20668,9 +21530,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(271 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -20683,7 +21545,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(273 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -20691,78 +21553,110 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(267 /* JsxClosingElement */); + parseExpected(30 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(270 /* JsxClosingFragment */); + parseExpected(30 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); - parseExpected(28 /* LessThanToken */); + var node = createNode(198 /* TypeAssertionExpression */); + parseExpected(29 /* LessThanToken */); node.type = parseType(); - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 /* OpenBracketToken */ + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 /* QuestionDotToken */ + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + propertyAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23 /* CloseBracketToken */); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + indexedAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24 /* DotToken */); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(217 /* 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(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - if (token() === 23 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23 /* CloseBracketToken */); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, /*typeArguments*/ undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, /*typeArguments*/ undefined); continue; } return expression; @@ -20771,48 +21665,70 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32 /* OptionalChain */) { + tagExpression.flags |= 32 /* OptionalChain */; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); + var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); // handle 'foo<()' - if (token() === 28 /* LessThanToken */ || token() === 46 /* LessThanLessThanToken */) { + if (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the // stack. var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(195 /* CallExpression */, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + // We failed to parse anything, so report a missing identifier here. + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32 /* OptionalChain */; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20 /* OpenParenToken */); @@ -20821,12 +21737,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* LessThanToken */) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(30 /* GreaterThanToken */)) { + if (!parseExpected(31 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -20843,21 +21759,23 @@ var ts; 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. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] - case 57 /* ColonToken */: // foo: + case 58 /* 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 57 /* QuestionToken */: // foo? + case 34 /* EqualsEqualsToken */: // foo == + case 36 /* EqualsEqualsEqualsToken */: // foo === + case 35 /* ExclamationEqualsToken */: // foo != + case 37 /* ExclamationEqualsEqualsToken */: // foo !== + case 55 /* AmpersandAmpersandToken */: // foo && + case 56 /* BarBarToken */: // foo || + case 60 /* QuestionQuestionToken */: // foo ?? + case 52 /* CaretToken */: // foo ^ + case 50 /* AmpersandToken */: // foo & + case 51 /* 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 @@ -20869,6 +21787,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -20881,11 +21800,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -20893,7 +21812,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 122 /* AsyncKeyword */: + case 125 /* 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. @@ -20901,14 +21820,14 @@ var ts; break; } return parseFunctionExpression(); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassExpression(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionExpression(); - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -20919,28 +21838,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(199 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(212 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(214 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(191 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -20952,25 +21871,25 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 281 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(53 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -20978,24 +21897,24 @@ 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() !== 57 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(60 /* EqualsToken */); + node.kind = 280 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(62 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276 /* PropertyAssignment */; - parseExpected(57 /* ColonToken */); + node.kind = 279 /* PropertyAssignment */; + parseExpected(58 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(192 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21014,10 +21933,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(200 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -21025,7 +21944,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -21037,26 +21956,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96 /* NewKeyword */); + parseExpected(98 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); - node_2.keywordToken = 96 /* NewKeyword */; + var node_2 = createNode(218 /* MetaProperty */, fullStart); + node_2.keywordToken = 98 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, /*optionalChain*/ undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(196 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21066,7 +21985,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(222 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21099,25 +22018,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(223 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); - parseExpected(92 /* IfKeyword */); + var node = createNode(226 /* IfStatement */); + parseExpected(94 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); - parseExpected(83 /* DoKeyword */); + var node = createNode(227 /* DoStatement */); + parseExpected(85 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(108 /* WhileKeyword */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21129,8 +22048,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); - parseExpected(108 /* WhileKeyword */); + var node = createNode(228 /* WhileStatement */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21139,12 +22058,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90 /* ForKeyword */); - var awaitToken = parseOptionalToken(123 /* AwaitKeyword */); + parseExpected(92 /* ForKeyword */); + var awaitToken = parseOptionalToken(126 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 106 /* VarKeyword */ || token() === 112 /* LetKeyword */ || token() === 78 /* ConstKeyword */) { + if (token() === 108 /* VarKeyword */ || token() === 114 /* LetKeyword */ || token() === 80 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -21152,23 +22071,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(151 /* OfKeyword */) : parseOptional(151 /* OfKeyword */)) { + var forOfStatement = createNode(231 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + else if (parseOptional(96 /* InKeyword */)) { + var forInStatement = createNode(230 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(229 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21186,7 +22105,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 233 /* BreakStatement */ ? 76 /* BreakKeyword */ : 81 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21194,8 +22113,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); - parseExpected(98 /* ReturnKeyword */); + var node = createNode(234 /* ReturnStatement */); + parseExpected(100 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -21203,39 +22122,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); - parseExpected(109 /* WithKeyword */); + var node = createNode(235 /* WithStatement */); + parseExpected(111 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); + node.statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); - parseExpected(75 /* CaseKeyword */); + var node = createNode(275 /* CaseClause */); + parseExpected(77 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); - parseExpected(81 /* DefaultKeyword */); - parseExpected(57 /* ColonToken */); + var node = createNode(276 /* DefaultClause */); + parseExpected(83 /* DefaultKeyword */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 77 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); - parseExpected(100 /* SwitchKeyword */); + var node = createNode(236 /* SwitchStatement */); + parseExpected(102 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(250 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21250,29 +22169,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); - parseExpected(102 /* ThrowKeyword */); + var node = createNode(238 /* ThrowStatement */); + parseExpected(104 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); - parseExpected(104 /* TryKeyword */); + var node = createNode(239 /* TryStatement */); + parseExpected(106 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 78 /* 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() === 89 /* FinallyKeyword */) { - parseExpected(89 /* FinallyKeyword */); + if (!node.catchClause || token() === 91 /* FinallyKeyword */) { + parseExpected(91 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); - parseExpected(76 /* CatchKeyword */); + var result = createNode(278 /* CatchClause */); + parseExpected(78 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21 /* CloseParenToken */); @@ -21285,8 +22204,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); - parseExpected(80 /* DebuggerKeyword */); + var node = createNode(240 /* DebuggerStatement */); + parseExpected(82 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -21296,13 +22215,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + if (expression.kind === 75 /* Identifier */ && parseOptional(58 /* ColonToken */)) { + node.kind = 237 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 225 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21314,11 +22233,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 79 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 93 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -21327,12 +22246,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* 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 @@ -21355,41 +22274,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146 /* GlobalKeyword */: + case 149 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 73 /* Identifier */ || token() === 86 /* ExportKeyword */; - case 93 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 75 /* Identifier */ || token() === 88 /* ExportKeyword */; + case 95 /* ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); - if (token() === 60 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || token() === 81 /* DefaultKeyword */ || - token() === 120 /* AsKeyword */) { + if (token() === 62 /* EqualsToken */ || token() === 41 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 83 /* DefaultKeyword */ || + token() === 122 /* AsKeyword */) { return true; } continue; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: nextToken(); continue; default: @@ -21402,50 +22321,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 92 /* IfKeyword */: - case 83 /* DoKeyword */: - case 108 /* WhileKeyword */: - case 90 /* ForKeyword */: - case 79 /* ContinueKeyword */: - case 74 /* BreakKeyword */: - case 98 /* ReturnKeyword */: - case 109 /* WithKeyword */: - case 100 /* SwitchKeyword */: - case 102 /* ThrowKeyword */: - case 104 /* TryKeyword */: - case 80 /* DebuggerKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 94 /* IfKeyword */: + case 85 /* DoKeyword */: + case 110 /* WhileKeyword */: + case 92 /* ForKeyword */: + case 81 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 100 /* ReturnKeyword */: + case 111 /* WithKeyword */: + case 102 /* SwitchKeyword */: + case 104 /* ThrowKeyword */: + case 106 /* TryKeyword */: + case 82 /* 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 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78 /* ConstKeyword */: - case 86 /* ExportKeyword */: + case 80 /* ConstKeyword */: + case 88 /* ExportKeyword */: return isStartOfDeclaration(); - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 111 /* InterfaceKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 141 /* TypeKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 113 /* InterfaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 144 /* TypeKeyword */: + case 149 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 119 /* StaticKeyword */: + case 137 /* 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); @@ -21468,63 +22388,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); - case 112 /* LetKeyword */: + case 108 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); + case 114 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); } break; - case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); - case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); - case 92 /* IfKeyword */: + case 93 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(243 /* FunctionDeclaration */)); + case 79 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(244 /* ClassDeclaration */)); + case 94 /* IfKeyword */: return parseIfStatement(); - case 83 /* DoKeyword */: + case 85 /* DoKeyword */: return parseDoStatement(); - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return parseWhileStatement(); - case 90 /* ForKeyword */: + case 92 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); - case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); - case 98 /* ReturnKeyword */: + case 81 /* ContinueKeyword */: + return parseBreakOrContinueStatement(232 /* ContinueStatement */); + case 76 /* BreakKeyword */: + return parseBreakOrContinueStatement(233 /* BreakStatement */); + case 100 /* ReturnKeyword */: return parseReturnStatement(); - case 109 /* WithKeyword */: + case 111 /* WithKeyword */: return parseWithStatement(); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return parseSwitchStatement(); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return parseThrowStatement(); - case 104 /* TryKeyword */: + case 106 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return parseTryStatement(); - case 80 /* DebuggerKeyword */: + case 82 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 58 /* AtToken */: + case 59 /* AtToken */: return parseDeclaration(); - case 122 /* AsyncKeyword */: - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 85 /* EnumKeyword */: - case 86 /* ExportKeyword */: - case 93 /* ImportKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 119 /* AbstractKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 87 /* EnumKeyword */: + case 88 /* ExportKeyword */: + case 95 /* ImportKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 121 /* AbstractKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: + case 149 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -21533,52 +22454,71 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126 /* DeclareKeyword */; + return modifier.kind === 129 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304 /* Ambient */; + m.flags |= 8388608 /* Ambient */; } - return doInsideOfContext(4194304 /* Ambient */, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: return parseVariableStatement(node); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassDeclaration(node); - case 111 /* InterfaceKeyword */: + case 113 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 141 /* TypeKeyword */: + case 144 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 85 /* EnumKeyword */: + case 87 /* EnumKeyword */: return parseEnumDeclaration(node); - case 146 /* GlobalKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 149 /* GlobalKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); switch (token()) { - case 81 /* DefaultKeyword */: - case 60 /* EqualsToken */: + case 83 /* DefaultKeyword */: + case 62 /* EqualsToken */: return parseExportAssignment(node); - case 120 /* AsKeyword */: + case 122 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -21587,7 +22527,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(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21610,24 +22550,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(214 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -21635,14 +22575,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(188 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(189 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -21664,10 +22604,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(241 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 /* Identifier */ && - token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 /* Identifier */ && + token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -21677,14 +22617,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(242 /* VariableDeclarationList */); switch (token()) { - case 106 /* VarKeyword */: + case 108 /* VarKeyword */: break; - case 112 /* LetKeyword */: + case 114 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -21700,7 +22640,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() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -21715,25 +22655,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 224 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + node.kind = 243 /* FunctionDeclaration */; + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* 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(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125 /* ConstructorKeyword */) { - return parseExpected(125 /* ConstructorKeyword */); + if (token() === 128 /* ConstructorKeyword */) { + return parseExpected(128 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -21745,25 +22685,25 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; - fillSignature(57 /* ColonToken */, 0 /* None */, node); + node.kind = 161 /* Constructor */; + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 160 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; - if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 158 /* PropertyDeclaration */; + if (!node.questionToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -21778,17 +22718,17 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. node.initializer = ts.hasModifier(node, 32 /* Static */) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseInitializer); + : doOutsideOfContext(8192 /* YieldContext */ | 4096 /* DisallowInContext */, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* 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(56 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -21796,13 +22736,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57 /* ColonToken */, 0 /* None */, node); + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58 /* AtToken */) { + if (token() === 59 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -21819,7 +22759,7 @@ var ts; } nextToken(); } - if (token() === 40 /* AsteriskToken */) { + if (token() === 41 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -21835,18 +22775,18 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 138 /* SetKeyword */ || idToken === 127 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 141 /* SetKeyword */ || idToken === 130 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { case 20 /* OpenParenToken */: // Method declaration - case 28 /* LessThanToken */: // Generic Method declaration - case 52 /* ExclamationToken */: // Non-null assertion on property name - case 57 /* ColonToken */: // Type Annotation for declaration - case 60 /* EqualsToken */: // Initializer for declaration - case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 29 /* LessThanToken */: // Generic Method declaration + case 53 /* ExclamationToken */: // Non-null assertion on property name + case 58 /* ColonToken */: // Type Annotation for declaration + case 62 /* EqualsToken */: // Initializer for declaration + case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -21864,10 +22804,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58 /* AtToken */)) { + if (!parseOptional(59 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(156 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -21887,7 +22827,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 80 /* 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)) { @@ -21906,7 +22846,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -21917,20 +22857,20 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(221 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 128 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -21944,27 +22884,37 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 40 /* AsteriskToken */ || + token() === 41 /* AsteriskToken */ || token() === 22 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608 /* Ambient */; + } + return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75 /* 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 */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 213 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 244 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77 /* ClassKeyword */); + parseExpected(79 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -21990,7 +22940,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -22002,33 +22952,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + ts.Debug.assert(tok === 89 /* ExtendsKeyword */ || tok === 112 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(277 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 29 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; - parseExpected(111 /* InterfaceKeyword */); + node.kind = 245 /* InterfaceDeclaration */; + parseExpected(113 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22036,11 +22985,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; - parseExpected(141 /* TypeKeyword */); + node.kind = 246 /* TypeAliasDeclaration */; + parseExpected(144 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -22050,14 +22999,14 @@ 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(279 /* EnumMember */); + var node = createNodeWithJSDoc(282 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; - parseExpected(85 /* EnumKeyword */); + node.kind = 247 /* EnumDeclaration */; + parseExpected(87 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -22069,7 +23018,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(249 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22080,7 +23029,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 248 /* 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 */; @@ -22092,11 +23041,11 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; - if (token() === 146 /* GlobalKeyword */) { + node.kind = 248 /* ModuleDeclaration */; + if (token() === 149 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 512 /* GlobalAugmentation */; + node.flags |= 1024 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(); @@ -22112,15 +23061,15 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146 /* GlobalKeyword */) { + if (token() === 149 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132 /* NamespaceKeyword */)) { + else if (parseOptional(135 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(131 /* ModuleKeyword */); + parseExpected(134 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } @@ -22128,52 +23077,52 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 /* RequireKeyword */ && + return token() === 138 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 42 /* SlashToken */; + return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; - parseExpected(120 /* AsKeyword */); - parseExpected(132 /* NamespaceKeyword */); + node.kind = 251 /* NamespaceExportDeclaration */; + parseExpected(122 /* AsKeyword */); + parseExpected(135 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 /* CommaToken */ && token() !== 145 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 148 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 253 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 40 /* AsteriskToken */ || // import * + token() === 41 /* AsteriskToken */ || // import * token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145 /* FromKeyword */); + parseExpected(148 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 252 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -22185,7 +23134,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(254 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22195,7 +23144,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(256 /* NamedImports */); } return finishNode(importClause); } @@ -22205,8 +23154,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); - parseExpected(135 /* RequireKeyword */); + var node = createNode(263 /* ExternalModuleReference */); + parseExpected(138 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -22228,9 +23177,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); - parseExpected(40 /* AsteriskToken */); - parseExpected(120 /* AsKeyword */); + var namespaceImport = createNode(255 /* NamespaceImport */); + parseExpected(41 /* AsteriskToken */); + parseExpected(122 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -22243,14 +23192,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 256 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(261 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(257 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22264,9 +23213,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(120 /* AsKeyword */); + parseExpected(122 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -22275,24 +23224,24 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 257 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; - if (parseOptional(40 /* AsteriskToken */)) { - parseExpected(145 /* FromKeyword */); + node.kind = 259 /* ExportDeclaration */; + if (parseOptional(41 /* AsteriskToken */)) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(260 /* 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() === 145 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(145 /* FromKeyword */); + if (token() === 148 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -22300,12 +23249,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; - if (parseOptional(60 /* EqualsToken */)) { + node.kind = 258 /* ExportAssignment */; + if (parseOptional(62 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(81 /* DefaultKeyword */); + parseExpected(83 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -22320,15 +23269,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */ + || node.kind === 253 /* ImportDeclaration */ + || node.kind === 258 /* ExportAssignment */ + || node.kind === 259 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -22336,7 +23283,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -22387,9 +23334,9 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(292 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); + result.type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -22399,8 +23346,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = parseJSDocCommentWorker(start, length); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22411,11 +23358,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536 /* JavaScriptFile */) { + if (contextFlags & 131072 /* JavaScriptFile */) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -22480,7 +23427,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -22499,7 +23446,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 40 /* AsteriskToken */: + case 41 /* 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 @@ -22550,7 +23497,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297 /* JSDocComment */, start); + var result = createNode(301 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22586,14 +23533,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { indentText += scanner.getTokenText(); if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40 /* AsteriskToken */) { + else if (token() === 41 /* AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -22601,7 +23548,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -22685,7 +23632,7 @@ var ts; } indent = 0; break; - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 3 /* SavingBackticks */) { comments.push(scanner.getTokenText()); break; @@ -22710,7 +23657,7 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -22718,7 +23665,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59 /* BacktickToken */: + case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { state = 2 /* SavingComments */; } @@ -22727,7 +23674,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -22750,7 +23697,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300 /* JSDocTag */, start); + var result = createNode(304 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22778,15 +23725,15 @@ var ts; skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(59 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(60 /* EqualsToken */)) { + if (parseOptionalToken(62 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -22795,9 +23742,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -22813,8 +23760,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(312 /* JSDocPropertyTag */, start) : - createNode(306 /* JSDocParameterTag */, start); + createNode(316 /* JSDocPropertyTag */, start) : + createNode(310 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22831,20 +23778,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) { + if (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -22856,7 +23803,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307 /* JSDocReturnTag */, start); + var result = createNode(311 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -22865,13 +23812,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309 /* JSDocTypeTag */, start); + var result = createNode(313 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302 /* JSDocAuthorTag */, start); + var result = createNode(306 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -22893,20 +23840,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 5 /* WhitespaceTrivia */: case 24 /* DotToken */: - case 58 /* AtToken */: + case 59 /* AtToken */: comments.push(scanner.getTokenText()); break; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (!seenLessThan || seenGreaterThan) { return; } @@ -22925,14 +23872,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301 /* JSDocAugmentsTag */, start); + var result = createNode(305 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -22944,7 +23891,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(193 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -22952,19 +23899,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303 /* JSDocClassTag */, start); + var tag = createNode(307 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308 /* JSDocThisTag */, start); + var tag = createNode(312 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305 /* JSDocEnumTag */, start); + var tag = createNode(309 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22973,7 +23920,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311 /* JSDocTypedefTag */, start); + var typedefTag = createNode(315 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22987,9 +23934,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start); } - if (child.kind === 309 /* JSDocTypeTag */) { + if (child.kind === 313 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -23002,7 +23949,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23021,7 +23968,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(248 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23035,22 +23982,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304 /* JSDocCallbackTag */, start); + var callbackTag = createNode(308 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299 /* JSDocSignature */, start); + var jsdocSignature = createNode(303 /* 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(58 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 307 /* JSDocReturnTag */) { + if (tag && tag.kind === 311 /* JSDocReturnTag */) { return tag; } } @@ -23092,10 +24039,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) && + if (child && (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23108,13 +24055,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -23123,7 +24070,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -23159,13 +24106,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(154 /* 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(27 /* CommaToken */)); - var result = createNode(310 /* JSDocTemplateTag */, start); + var result = createNode(314 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23198,18 +24145,21 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73 /* Identifier */, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + var result = createNode(75 /* Identifier */, pos); + if (token() !== 75 /* Identifier */) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -23330,7 +24280,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return true; } return false; @@ -23896,10 +24846,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73 /* Identifier */) { + if (lhs.kind === 75 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101 /* ThisKeyword */) { + if (lhs.kind === 103 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -24049,12 +24999,21 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -24064,7 +25023,7 @@ var ts; }, ]; /* @internal */ - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -24166,7 +25125,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -24203,6 +25163,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -24211,6 +25172,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -24218,6 +25180,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -24236,6 +25199,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -24263,6 +25227,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -24272,6 +25237,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -24288,6 +25254,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -24307,7 +25274,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, // Strict Type Checks { @@ -24441,7 +25409,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { // this option can only be specified in tsconfig.json @@ -24456,7 +25425,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -24480,7 +25450,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -24577,6 +25548,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -24626,14 +25598,20 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + transpileOptionValue: true }, { name: "stripInternal", @@ -24649,6 +25627,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -24669,6 +25653,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -24684,7 +25669,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -24742,6 +25728,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -24771,7 +25764,11 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + /* @internal */ + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -24835,7 +25832,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; /* @internal */ @@ -25335,7 +26333,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 !== 276 /* PropertyAssignment */) { + if (element.kind !== 279 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25391,15 +26389,15 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97 /* NullKeyword */: + case 99 /* 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 + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25417,13 +26415,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 206 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25440,7 +26438,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25491,13 +26489,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), 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 config = __assign(__assign({ compilerOptions: __assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? 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 }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -25722,8 +26720,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -25889,7 +26886,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -26578,8 +27575,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -26838,7 +27836,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27022,6 +28020,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -27032,6 +28031,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -27241,7 +28243,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); @@ -27277,7 +28279,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; @@ -27298,7 +28300,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -27778,35 +28780,67 @@ var ts; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1 /* Instantiated */; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0 /* NonInstantiated */; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; - // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case 259 /* ExportDeclaration */: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0 /* NonInstantiated */; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1 /* Instantiated */) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. + case 249 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0 /* NonInstantiated */: // child is non-instantiated - continue searching @@ -27825,9 +28859,9 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: - return getModuleInstanceState(node); - case 73 /* Identifier */: + case 248 /* ModuleDeclaration */: + return getModuleInstanceState(node, visited); + case 75 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -27836,6 +28870,36 @@ var ts; } return 1 /* Instantiated */; } + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1 /* Instantiated */) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + } var ContainerFlags; (function (ContainerFlags) { // The current node is not a container, and no container manipulation should happen before @@ -27864,7 +28928,9 @@ var ts; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -27898,7 +28964,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -27966,7 +29032,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -27977,7 +29043,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { setValueDeclaration(symbol, node); } } @@ -27993,7 +29059,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 === 255 /* ExportAssignment */) { + if (node.kind === 258 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -28002,7 +29068,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28014,39 +29080,42 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: + case 169 /* FunctionType */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 155 /* 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 === 295 /* 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 === 298 /* 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; @@ -28146,7 +29215,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 === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 258 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28164,7 +29233,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0 /* None */, name); } } @@ -28181,7 +29250,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 261 /* ExportSpecifier */ || (node.kind === 252 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28205,11 +29274,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { + if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 67220415 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -28248,7 +29317,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 !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28276,12 +29345,12 @@ var ts; if (!isIIFE) { currentFlow = { flags: 2 /* Start */ }; if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { - currentFlow.container = node; + currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -28289,19 +29358,20 @@ var ts; flowNodeCreated = ts.identity; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~1408 /* ReachabilityAndEmitFlags */; + node.flags &= ~2816 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 128 /* HasImplicitReturn */; + node.flags |= 256 /* HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 256 /* HasExplicitReturn */; + node.flags |= 512 /* HasExplicitReturn */; + node.endFlowNode = currentFlow; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28318,7 +29388,7 @@ var ts; else if (containerFlags & 64 /* IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 /* ContainsThis */ : node.flags & ~64 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; } else { bindChildren(node); @@ -28345,8 +29415,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28378,79 +29448,93 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 /* FirstStatement */ && node.kind <= 240 /* LastStatement */ && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 225 /* ExpressionStatement */: + bindExpressionStatement(node); + break; + case 237 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + bindAccessExpressionFlow(node); + break; + case 195 /* CallExpression */: bindCallExpressionFlow(node); break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; + case 307 /* JSDocClassTag */: + bindJSDocClassTag(node); + break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 288 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28461,29 +29545,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: - return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 203 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || + return expr.kind === 75 /* Identifier */ || expr.kind === 103 /* ThisKeyword */ || expr.kind === 101 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && + ts.isElementAccessExpression(expr) && + ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { @@ -28495,7 +29579,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 193 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28509,17 +29593,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableReference(expr.left); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -28528,11 +29612,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -28541,20 +29625,14 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4 /* BranchLabel */, - antecedents: undefined - }; + return { flags: 4 /* BranchLabel */, antecedents: undefined }; } function createLoopLabel() { - return { - flags: 8 /* LoopLabel */, - antecedents: undefined - }; + return { flags: 8 /* LoopLabel */, antecedents: undefined }; } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; + flow.flags |= flow.flags & 1024 /* Referenced */ ? 2048 /* Shared */ : 1024 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -28569,31 +29647,36 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 103 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 88 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { - return unreachableFlow; + if (expression.kind === 105 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 90 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (!ts.isOptionalChainRoot(expression.parent)) { + return unreachableFlow; + } } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16 /* Assignment */, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -28608,47 +29691,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 229 /* ForStatement */: + case 209 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 206 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 55 /* BarBarToken */); + return node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* BarBarToken */ || + node.operatorToken.kind === 60 /* QuestionQuestionToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && - node.parent.operator === 52 /* ExclamationToken */) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); } @@ -28676,7 +29764,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 237 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -28708,15 +29796,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 231 /* ForOfStatement */) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 242 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -28738,7 +29826,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 234 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -28758,7 +29846,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -28850,7 +29938,7 @@ var ts; // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. - var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = { flags: 4096 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -28868,7 +29956,7 @@ var ts; } } if (!(currentFlow.flags & 1 /* Unreachable */)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096 /* AfterFinally */, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192 /* AfterFinally */, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -28886,9 +29974,10 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276 /* 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). + // case clauses have unreachable end points (e.g. they all return). Note, we no longer need + // this property in control flow analysis, it's there only for backwards compatibility. node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -28942,6 +30031,17 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + // A top level call expression with a dotted function name and at least one argument + // is potentially an assertion and is therefore included in the control flow. + if (node.expression.kind === 195 /* CallExpression */) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -28953,14 +30053,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 227 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -28971,10 +30071,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 191 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 212 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -28982,16 +30082,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 279 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 280 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 281 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -28999,7 +30099,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -29010,7 +30110,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52 /* ExclamationToken */) { + if (node.operator === 53 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -29020,20 +30120,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -29047,7 +30147,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 62 /* EqualsToken */ && node.left.kind === 194 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29058,7 +30158,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 193 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29097,27 +30197,102 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 309 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - // If the target of the call expression is a function expression or arrow function we have - // 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 === 196 /* ParenthesizedExpression */) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193 /* PropertyAccessExpression */: + bind(node.name); + break; + case 194 /* ElementAccessExpression */: + bind(node.argumentExpression); + break; + case 195 /* CallExpression */: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + // For an optional chain, we emulate the behavior of a logical expression: + // + // a?.b -> a && a.b + // a?.b.c -> a && a.b.c + // a?.b?.c -> a && a.b && a.b.c + // a?.[x = 1] -> a && a[x = 1] + // + // To do this we descend through the chain until we reach the root of a chain (the expression with a `?.`) + // and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest + // of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost + // chain node. We then treat the entire node as the right side of the expression. + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + // If the target of the call expression is a function expression or arrow function we have + // an immediately invoked function expression (IIFE). Initialize the flowNode property to + // the current control flow (which includes evaluation of the IIFE arguments). + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 /* FunctionExpression */ || expr.kind === 201 /* ArrowFunction */) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29126,54 +30301,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 272 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 298 /* JSDocFunctionType */: + case 169 /* FunctionType */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 170 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 278 /* CatchClause */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 250 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 222 /* 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 @@ -29206,45 +30381,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 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 192 /* ObjectLiteralExpression */: + case 245 /* InterfaceDeclaration */: + case 272 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 299 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 303 /* JSDocSignature */: + case 166 /* IndexSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 298 /* JSDocFunctionType */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 246 /* TypeAliasDeclaration */: + case 185 /* 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 @@ -29271,11 +30446,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 4194304 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 32 /* ExportContext */; + if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* ExportContext */; } else { - node.flags &= ~32 /* ExportContext */; + node.flags &= ~64 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -29345,7 +30520,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 === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 281 /* SpreadAssignment */ || prop.name.kind !== 75 /* Identifier */) { continue; } var identifier = prop.name; @@ -29357,7 +30532,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 === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 279 /* PropertyAssignment */ || prop.kind === 280 /* ShorthandPropertyAssignment */ || prop.kind === 160 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29389,10 +30564,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29423,9 +30598,37 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + container = file; + break; + case 4 /* ThisProperty */: + container = declName.parent.expression; + break; + case 3 /* PrototypeProperty */: + container = declName.parent.expression.name; + break; + case 5 /* Property */: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0 /* None */: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75 /* Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -29441,10 +30644,11 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 112 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 120 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */)) { + !(node.flags & 8388608 /* Ambient */) && + !(node.flags & 4194304 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29478,7 +30682,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 73 /* Identifier */) { + if (inStrictMode && node.expression.kind === 75 /* 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); @@ -29489,7 +30693,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73 /* Identifier */) { + if (name && name.kind === 75 /* 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 @@ -29530,8 +30734,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 288 /* SourceFile */ && + blockScopeContainer.kind !== 248 /* 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. @@ -29557,7 +30761,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -29592,7 +30796,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -29626,7 +30830,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 > 148 /* LastToken */) { + if (node.kind > 151 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -29666,8 +30870,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -29688,7 +30892,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 73 /* Identifier */: + case 75 /* 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. @@ -29697,31 +30901,32 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); break; } // falls through - case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + case 103 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -29749,76 +30954,76 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 182 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 282 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* 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 240 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); + case 243 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 162 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); + case 163 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: + case 170 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 185 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -29837,64 +31042,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); + case 246 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + case 247 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 288 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 222 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 306 /* JSDocParameterTag */: - if (node.parent.kind === 299 /* JSDocSignature */) { + case 310 /* JSDocParameterTag */: + if (node.parent.kind === 303 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 298 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 302 /* JSDocTypeLiteral */) { break; } // falls through - case 312 /* JSDocPropertyTag */: + case 316 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30002,8 +31208,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); } @@ -30013,7 +31218,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 /* Property */ | 1048576 /* ExportValue */ | 32 /* Class */ : 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, lhs, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); } } function bindModuleExportsAssignment(node) { @@ -30038,13 +31243,13 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 === 60 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } @@ -30052,38 +31257,59 @@ var ts; // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } break; default: ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4 /* Property */, "__computed" /* Computed */); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101 /* ThisKeyword */) { + if (node.expression.kind === 103 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30096,8 +31322,7 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.left.expression, node.left, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -30116,32 +31341,38 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 288 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { // This can be an alias for the 'exports' or 'module.exports' names, e.g. // var util = module.exports; // util.property = function ... bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -30150,10 +31381,10 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; @@ -30169,6 +31400,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30179,17 +31413,47 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var includes = 0 /* None */; + var excludes = 0 /* None */; + // Method-like + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192 /* Method */; + excludes = 103359 /* MethodExcludes */; + } + // Maybe accessor-like + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this + // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) + includes |= 65536 /* SetAccessor */ | 4 /* Property */; + excludes |= 78783 /* SetAccessorExcludes */; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 /* GetAccessor */ | 4 /* Property */; + excludes |= 46015 /* GetAccessorExcludes */; + } + } + if (includes === 0 /* None */) { + includes = 4 /* Property */; + excludes = 0 /* PropertyExcludes */; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 /* SourceFile */ + : propertyAccess.parent.parent.kind === 288 /* SourceFile */; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30218,7 +31482,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 === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -30235,7 +31499,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -30247,7 +31511,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -30258,8 +31522,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); + if (node.kind === 244 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; @@ -30292,19 +31556,16 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 /* RegularEnum */ : 0 /* None */); - var enumExcludes = (isEnum ? 68008191 /* RegularEnumExcludes */ : 0 /* None */); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */ | enumFlags, 67220415 /* BlockScopedVariableExcludes */ | enumExcludes); + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -30316,18 +31577,18 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */ | enumFlags, 67220414 /* FunctionScopedVariableExcludes */ | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 306 /* JSDocParameterTag */ && container.kind !== 299 /* JSDocSignature */) { + if (node.kind === 310 /* JSDocParameterTag */ && container.kind !== 303 /* JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { + if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); @@ -30336,34 +31597,34 @@ var ts; bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -30374,8 +31635,8 @@ var ts; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -30395,26 +31656,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 180 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } // reachability checks @@ -30429,11 +31690,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 223 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 248 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30447,7 +31708,7 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 8388608 /* Ambient */) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -30477,12 +31738,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30494,7 +31755,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -30531,58 +31792,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 155 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 161 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -30593,6 +31854,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } if (node.typeArguments) { transformFlags |= 1 /* AssertTypeScript */; } @@ -30604,7 +31868,7 @@ var ts; transformFlags |= 2048 /* ContainsLexicalThis */; } } - if (expression.kind === 93 /* ImportKeyword */) { + if (expression.kind === 95 /* ImportKeyword */) { transformFlags |= 524288 /* ContainsDynamicImport */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -30627,17 +31891,20 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* QuestionQuestionToken */) { + transformFlags |= 4 /* AssertESNext */; + } + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 192 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 191 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ - || operatorTokenKind === 64 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 42 /* AsteriskAsteriskToken */ + || operatorTokenKind === 66 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 64 /* AssertES2016 */; } @@ -30680,8 +31947,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 === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 216 /* AsExpression */ + || expressionKind === 198 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -30721,11 +31988,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87 /* ExtendsKeyword */: + case 89 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; - case 110 /* ImplementsKeyword */: + case 112 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; @@ -30916,9 +32183,12 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -30928,9 +32198,12 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If an ElementAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31018,43 +32291,43 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { - case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 125 /* AsyncKeyword */: + case 205 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; break; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 217 /* NonNullExpression */: + case 137 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 267 /* JsxClosingElement */: + case 268 /* JsxFragment */: + case 269 /* JsxOpeningFragment */: + case 270 /* JsxClosingFragment */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 274 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31062,11 +32335,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: - case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 280 /* ShorthandPropertyAssignment */: + case 119 /* StaticKeyword */: + case 218 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31083,103 +32356,103 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; break; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 167 /* TypePredicate */: + case 168 /* TypeReference */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 171 /* TypeQuery */: + case 172 /* TypeLiteral */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 180 /* InferType */: + case 181 /* ParenthesizedType */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: + case 251 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 153 /* 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. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; excludeFlags = 536870912 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31192,26 +32465,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31229,67 +32502,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 191 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 155 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 161 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 139 /* StringKeyword */: - case 137 /* ObjectKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 142 /* StringKeyword */: + case 140 /* ObjectKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 278 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: - case 99 /* SuperKeyword */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: + case 199 /* ParenthesizedExpression */: + case 101 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31308,7 +32581,7 @@ var ts; /** @internal */ var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -31381,7 +32654,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -31464,7 +32737,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 === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 171 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -31515,6 +32788,180 @@ var ts; WideningKind[WideningKind["Normal"] = 0] = "Normal"; WideningKind[WideningKind["GeneratorYield"] = 1] = "GeneratorYield"; })(WideningKind || (WideningKind = {})); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + 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"] = 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 */, + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ + }); + var typeofNEFacts = ts.createMapFromTemplate({ + 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 TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; + TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; + TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; + CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; + CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; + })(CheckMode || (CheckMode = {})); + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + ContextFlags[ContextFlags["NoConstraints"] = 2] = "NoConstraints"; + })(ContextFlags || (ContextFlags = {})); + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; + })(AccessFlags || (AccessFlags = {})); + var CallbackCheck; + (function (CallbackCheck) { + CallbackCheck[CallbackCheck["None"] = 0] = "None"; + CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; + CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; + })(CallbackCheck || (CallbackCheck = {})); + var MappedTypeModifiers; + (function (MappedTypeModifiers) { + MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; + })(MappedTypeModifiers || (MappedTypeModifiers = {})); + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var MembersOrExportsResolutionKind; + (function (MembersOrExportsResolutionKind) { + MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; + MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; + })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); + var UnusedKind; + (function (UnusedKind) { + UnusedKind[UnusedKind["Local"] = 0] = "Local"; + UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; + })(UnusedKind || (UnusedKind = {})); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); + var DeclarationMeaning; + (function (DeclarationMeaning) { + DeclarationMeaning[DeclarationMeaning["GetAccessor"] = 1] = "GetAccessor"; + DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; + DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; + })(DeclarationMeaning || (DeclarationMeaning = {})); + var DeclarationSpaces; + (function (DeclarationSpaces) { + DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; + DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; + DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; + DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; + })(DeclarationSpaces || (DeclarationSpaces = {})); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -31562,11 +33009,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -31600,6 +33045,9 @@ var ts; var requireSymbol = createSymbol(4 /* Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; + // This object is reused for `checkOptionalExpression` return values to avoid frequent GC due to nursery object allocations. + // This object represents a pool-size of 1. + var pooledOptionalTypeResult = { isOptional: false, type: undefined }; // for public members that accept a Node or one of its subtypes, we must guard against // synthetic nodes created during transformations by calling `getParseTreeNode`. // for most of these, we perform the guard only on `checker` to avoid any possible @@ -31648,8 +33096,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -31766,7 +33217,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -31782,6 +33233,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -31800,6 +33254,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -31828,7 +33283,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -31840,7 +33295,7 @@ var ts; // Ensure file is type checked checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { addUnusedDiagnostics(); } @@ -31852,7 +33307,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -31892,6 +33347,7 @@ var ts; var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 262144 /* ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); var nullType = createIntrinsicType(65536 /* Null */, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 262144 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); @@ -31921,6 +33377,7 @@ var ts; var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 1048576 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -31944,7 +33401,7 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); + var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 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); @@ -32041,6 +33498,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -32053,113 +33513,18 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - // Suggestion diagnostics must have a file. Keyed by source file name. - var suggestionDiagnostics = ts.createMultiMap(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - 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"] = 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 */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ - }); - var typeofNEFacts = ts.createMapFromTemplate({ - 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 suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -32177,71 +33542,8 @@ var ts; var comparableRelation = ts.createMap(); var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; - TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; - TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); - var CheckMode; - (function (CheckMode) { - CheckMode[CheckMode["Normal"] = 0] = "Normal"; - CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; - CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; - CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; - CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; - CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; - })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - })(AccessFlags || (AccessFlags = {})); - var CallbackCheck; - (function (CallbackCheck) { - CallbackCheck[CallbackCheck["None"] = 0] = "None"; - CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; - CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; - })(CallbackCheck || (CallbackCheck = {})); - var MappedTypeModifiers; - (function (MappedTypeModifiers) { - MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; - })(MappedTypeModifiers || (MappedTypeModifiers = {})); - var ExpandingFlags; - (function (ExpandingFlags) { - ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; - ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; - ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; - ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; - })(ExpandingFlags || (ExpandingFlags = {})); - var MembersOrExportsResolutionKind; - (function (MembersOrExportsResolutionKind) { - MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; - MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; - })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); - var UnusedKind; - (function (UnusedKind) { - UnusedKind[UnusedKind["Local"] = 0] = "Local"; - UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; - })(UnusedKind || (UnusedKind = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -32253,7 +33555,7 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; @@ -32306,11 +33608,11 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32332,35 +33634,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= 67220415 /* BlockScopedVariableExcludes */; + result |= 111551 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= 67220414 /* FunctionScopedVariableExcludes */; + result |= 111550 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) result |= 0 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= 68008959 /* EnumMemberExcludes */; + result |= 900095 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= 67219887 /* FunctionExcludes */; + result |= 110991 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 68008383 /* ClassExcludes */; + result |= 899503 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 67897736 /* InterfaceExcludes */; + result |= 788872 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 68008191 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 68008831 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 110735 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) - result |= 67212223 /* MethodExcludes */; + result |= 103359 /* MethodExcludes */; if (flags & 32768 /* GetAccessor */) - result |= 67154879 /* GetAccessorExcludes */; + result |= 46015 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) - result |= 67187647 /* SetAccessorExcludes */; + result |= 78783 /* SetAccessorExcludes */; if (flags & 262144 /* TypeParameter */) - result |= 67635688 /* TypeParameterExcludes */; + result |= 526824 /* TypeParameterExcludes */; if (flags & 524288 /* TypeAlias */) - result |= 67897832 /* TypeAliasExcludes */; + result |= 788968 /* TypeAliasExcludes */; if (flags & 2097152 /* Alias */) result |= 2097152 /* AliasExcludes */; return result; @@ -32395,7 +33697,11 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* Assignment */) { - ts.Debug.assert(source !== target); + if (source === target) { + // This can happen when an export assigned namespace exports something also erroneously exported at the top level + // See `declarationFileNoCrashOnExtraExportModifier` for an example + return target; + } if (!(target.flags & 33554432 /* Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -32524,7 +33830,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -32534,7 +33840,7 @@ var ts; // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); if (mainModule_1.flags & 1920 /* Namespace */) { - // If we’re merging an augmentation to a pattern ambient module, we want to + // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you // all the exports both from the pattern and from the augmentation, but @@ -32583,7 +33889,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32613,8 +33919,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -32627,7 +33933,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304 /* Ambient */) { + declaration.flags & 8388608 /* Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -32641,17 +33947,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 190 /* 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, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 190 /* 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, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 241 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -32674,22 +33980,22 @@ 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 === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 /* ExportSpecifier */ || (usage.parent.kind === 258 /* 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 === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 258 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 224 /* VariableStatement */: + case 229 /* ForStatement */: + case 231 /* 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)) { @@ -32710,16 +34016,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 158 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 160 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -32740,14 +34046,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 201 /* ArrowFunction */: + case 158 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 222 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return true; default: return false; @@ -32793,12 +34099,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 !== 297 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 301 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 155 /* Parameter */ || + lastLocation.kind === 154 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -32815,13 +34121,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 === 152 /* Parameter */ || + lastLocation.kind === 155 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 179 /* 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; @@ -32836,14 +34142,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + case 248 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -32867,7 +34173,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 261 /* ExportSpecifier */)) { break; } } @@ -32881,12 +34187,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -32896,20 +34202,20 @@ var ts; if (!ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -32924,7 +34230,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 213 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -32932,11 +34238,11 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 89 /* ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -32952,34 +34258,34 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -32992,7 +34298,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -33001,7 +34307,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 === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 155 /* Parameter */) { location = location.parent; } // @@ -33016,24 +34322,25 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244 /* ClassDeclaration */)) { location = location.parent; } break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 155 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 155 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33053,7 +34360,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 288 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33119,21 +34426,21 @@ var ts; // we want to check for block-scoped if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 67220415 /* Value */) === 67220415 /* Value */))) { + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415 /* Value */) === 67220415 /* Value */) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -33149,10 +34456,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 201 /* ArrowFunction */ && location.kind !== 200 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -33165,12 +34472,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33182,7 +34489,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 === 151 /* TypeParameter */) { + if (decl.kind === 154 /* 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 @@ -33237,10 +34544,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33250,9 +34557,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -33271,8 +34578,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 /* Type */ & 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1920 /* Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -33281,12 +34588,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later @@ -33310,15 +34617,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */ & ~67897832 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 /* Type */ & ~1024 /* NamespaceModule */ & ~67220415 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~67897832 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -33328,11 +34635,15 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); + if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + // constructor functions aren't block scoped + return; + } // 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 === 244 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { @@ -33364,13 +34675,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33380,7 +34691,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33445,7 +34756,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -33457,7 +34773,7 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -33481,7 +34797,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -33511,9 +34827,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -33548,7 +34865,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default" /* Default */)) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -33568,34 +34890,56 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; } - var aliasLike = resolveEntityName(expression, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 261 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); + case 258 /* ExportAssignment */: + case 208 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280 /* ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 279 /* PropertyAssignment */: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193 /* PropertyAccessExpression */: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -33605,7 +34949,7 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); @@ -33639,7 +34983,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -33655,17 +34999,15 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 258 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); + // We defer checking of the reference of an `import =` until the import itself is referenced, + // This way a chain of imports can be elided if ultimately the final input is only used in a type + // position. + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // import foo = + checkExpressionCached(node.moduleReference); + } } } } @@ -33677,18 +35019,18 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 73 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 75 /* Identifier */ || entityName.parent.kind === 152 /* 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 === 249 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 252 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -33701,9 +35043,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); @@ -33711,9 +35053,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 152 /* QualifiedName */ || name.kind === 193 /* PropertyAccessExpression */) { + var left = name.kind === 152 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 152 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -33765,7 +35107,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -33804,6 +35146,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -33815,9 +35171,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -33848,7 +35201,7 @@ var ts; if (patternAmbientModules) { var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference); if (pattern) { - // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // If the module reference matched a pattern ambient module ('*.foo') but there's also a // module augmentation by the specific name requested ('a.foo'), we store the merged symbol // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports // from a.foo. @@ -33919,7 +35272,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -33928,9 +35281,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* ValueModule */; if (merged.exports === undefined) { - merged.flags = merged.flags | 512 /* ValueModule */; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -33938,15 +35295,16 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 288 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34020,7 +35378,7 @@ var ts; return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -34157,7 +35515,8 @@ var ts; */ function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + // Type parameters end up in the `members` lists but are not externally visible + if (container && !(symbol.flags & 262144 /* TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { @@ -34166,7 +35525,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -34174,7 +35544,7 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { @@ -34182,33 +35552,42 @@ var ts; // fast path, `symbol` is either already the alias or isn't aliased return symbol; } + // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return + // the container itself as the alias for the symbol + var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + /** + * Checks if two symbols, through aliasing and/or merging, refer to the same thing + */ + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 67220415 /* Value */); + return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34286,31 +35665,61 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + case 248 /* ModuleDeclaration */: + var sym = getSymbolOfNode(location); + // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten + // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred + // to one another anyway) + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + // Type parameters are bound into `members` lists so they can merge across declarations + // This is troublesome, since in all other respects, they behave like locals :cries: + // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol + // lookup logic in terms of `resolveName` would be nice + // 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! + var table_1; + // TODO: Should this filtered table be cached in some way? + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 67220415 /* Value */ ? 67220415 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -34341,12 +35750,12 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { // If symbol is directly available by its name in the symbol table @@ -34363,7 +35772,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, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34399,7 +35808,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, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34414,10 +35823,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: continue; default: return false; @@ -34428,11 +35837,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -34475,7 +35884,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -34534,14 +35943,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -34584,21 +35993,21 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 171 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 153 /* ComputedPropertyName */) { // Typeof value - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 152 /* QualifiedName */ || entityName.kind === 193 /* PropertyAccessExpression */ || + entityName.parent.kind === 252 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 67897832 /* Type */; + meaning = 788968 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -34640,15 +36049,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructorType */ : 169 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 165 /* ConstructSignature */ : 164 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -34671,14 +36080,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -34709,6 +36121,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -34719,7 +36134,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -34747,37 +36163,37 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(144 /* UnknownKeyword */); + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139 /* StringKeyword */); + return ts.createKeywordTypeNode(142 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136 /* NumberKeyword */); + return ts.createKeywordTypeNode(139 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147 /* BigIntKeyword */); + return ts.createKeywordTypeNode(150 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124 /* BooleanKeyword */); + return ts.createKeywordTypeNode(127 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); return enumLiteralName; } if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* Type */); } if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); @@ -34786,7 +36202,7 @@ var ts; if (type.flags & 256 /* NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048 /* BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -34800,38 +36216,38 @@ var ts; if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143 /* UniqueKeyword */, ts.createKeywordTypeNode(140 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(146 /* UniqueKeyword */, ts.createKeywordTypeNode(143 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107 /* VoidKeyword */); + return ts.createKeywordTypeNode(109 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(145 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97 /* NullKeyword */); + return ts.createKeywordTypeNode(99 /* NullKeyword */); } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133 /* NeverKeyword */); + return ts.createKeywordTypeNode(136 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140 /* SymbolKeyword */); + return ts.createKeywordTypeNode(143 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* ObjectKeyword */); + return ts.createKeywordTypeNode(140 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -34845,10 +36261,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { @@ -34856,6 +36278,7 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; @@ -34863,15 +36286,9 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832 /* Type */) + ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); - } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -34879,7 +36296,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 177 /* UnionType */ : 178 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -34943,51 +36360,31 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 /* Type */ : 67220415 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; 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 === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415 /* Value */); + return symbolToTypeNode(symbol, context, 111551 /* Value */); } 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) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 67897832 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* Type */); } else { return createElidedInformationPlaceholder(context); } } 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.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -35000,15 +36397,45 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 288 /* SourceFile */ || declaration.parent.kind === 249 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions 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 + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; + var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + // 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.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -35021,12 +36448,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170 /* ConstructorType */, context); return signatureNode; } } @@ -35039,7 +36466,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2 /* WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -35047,7 +36474,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { @@ -35061,12 +36488,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -35074,6 +36501,8 @@ var ts; else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && + // Use `import` types for refs to other scopes, only anonymize something defined in the same scope + ts.findAncestor(type.symbol.valueDeclaration, function (d) { return d === ts.getSourceFileOfNode(context.enclosingDeclaration); }) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return createAnonymousTypeNode(type); } @@ -35096,7 +36525,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 67897832 /* Type */, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -35109,7 +36538,7 @@ var ts; } var flags = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832 /* Type */, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -35161,11 +36590,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35212,7 +36641,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); @@ -35223,25 +36652,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } - var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); + var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -35252,20 +36685,30 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { // Copy comments to node for declaration emit - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + ts.setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -35306,7 +36749,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 139 /* StringKeyword */ : 136 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 142 /* StringKeyword */ : 139 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -35319,7 +36762,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -35330,7 +36773,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 === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35338,23 +36781,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 /* Identifier */ ? + var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? + ts.createToken(123 /* AssertsKeyword */) : + undefined; + var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 121 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 124 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(124 /* 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); @@ -35374,9 +36820,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35386,15 +36832,14 @@ var ts; 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) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 152 /* 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) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(57 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -35404,29 +36849,32 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 190 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; // get symbol of the first identifier of the entityName - var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var firstIdentifier = getFirstIdentifier(accessExpression); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; @@ -35459,6 +36907,13 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent + // No need to lookup an alias for the symbol in itself + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -35539,7 +36994,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 288 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35575,7 +37030,7 @@ var ts; // using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -35584,7 +37039,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 67220415 /* Value */; + var isTypeOf = meaning === 111551 /* Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -35631,16 +37086,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216 /* InInitialEntityName */; } - var parent = chain[index - 1]; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { @@ -35663,7 +37134,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); } function typeParameterToName(type, context) { if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { @@ -35672,7 +37143,10 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ true); + var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 75 /* Identifier */)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -35718,9 +37192,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -35729,6 +37200,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -35756,12 +37230,1072 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + // See getNameForSymbolFromNameType for a stringy equivalent + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384 /* StringOrNumberLiteral */) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192 /* UniqueESSymbol */) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + // Make type parameters created within this context not consume the name outside this context + // The symbol serializer ends up creating many sibling scopes that all need "separate" contexts when + // it comes to naming things - within a normal `typeToTypeNode` call, the node builder only ever descends + // through the type tree, so the only cases where we could have used distinct sibling scopes was when there + // were multiple generic overloads with similar generated type parameter names + // The effect: + // When we write out + // export const x: (x: T) => T + // export const y: (x: T) => T + // we write it out like that, rather than as + // export const x: (x: T) => T + // export const y: (x: T_1) => T_1 + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159 /* MethodSignature */, /*useAcessors*/ false); + // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of + // declaration mapping + // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration + // emit codepaths which want to apply more specific contexts (so we can still refer to the root real declaration + // we're trying to emit from later on) + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.mapMap(symbolTable, function (_symbol, name) { return [ts.unescapeLeadingUnderscores(name), true]; }), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false); + if (accessibleResult.accessibility === 0 /* Accessible */) { + // Lookup the root symbol of the chain of refs we'll use to access it and serialize it + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4 /* Property */)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export=" /* ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + symbolTable = ts.createSymbolTable(); + // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) + symbolTable.set("export=" /* ExportEquals */, exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75 /* Identifier */; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from + // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1 /* Export */); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(/*alias*/ undefined, id); })), + /*moduleSpecifier*/ undefined)])); + } + // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + // Pass 2: Combine all `export {}` declarations + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), + /*moduleSpecifier*/ undefined)]); + } + // Pass 2b: Also combine all `export {} from "..."` declarations as needed + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + // remove group members from statements and then merge group members and add back to statements + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + // Pass 3: Move all `export {}`'s to `export` modifiers where possible + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + // all clauses removed, filter the export declaration + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + // some items filtered, others not - update the export declaration + // (mutating because why not, we're building a whole new tree here anyway) + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + // Not a cleanup, but as a final step: If there is a mix of `export` and non-`export` declarations, but no `export =` or `export {}` add a `export {};` so + // declaration privacy is respected. + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1 /* Export */) & ~2 /* Ambient */; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + // deferredPrivates will be filled up by visiting the symbol table + // And will continue to iterate as elements are added while visited `deferredPrivates` + // (As that's how a map iterator is defined to work) + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + // cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but + // still skip reserializing it if we encounter the merged product later on + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; // Already printed + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + // Only actually serialize symbols within the correct enclosing declaration, otherwise do nothing with the out-of-context symbol + var skipMembershipCheck = !isPrivate; // We only call this on exported symbols when we know they're in the correct scope + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias + // or a merge of some number of those. + // An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping + // each symbol in only one of the representations + // Also, synthesizing a default export of some kind + // If it's an alias: emit `export default ref` + // If it's a property: emit `export default _default` with a `_default` prop + // If it's a class/interface/function: emit a class/interface/function with a `default` modifier + // These forms can merge, eg (`export default 12; export default interface A {}`) + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default" /* Default */; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( + context.encounteredError = true; + // TODO: Issue error via symbol tracker? + return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); + if (symbol.flags & 16 /* Function */) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288 /* TypeAlias */) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + // Need to skip over export= symbols below - json source files get a single `Property` flagged + // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. + if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) + && symbol.escapedName !== "export=" /* ExportEquals */ + && !(symbol.flags & 4194304 /* Prototype */) + && !(symbol.flags & 32 /* Class */)) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384 /* Enum */) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 4 /* Property */) { + // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, + // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property + // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if (symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */)) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64 /* Interface */) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152 /* Alias */) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608 /* ExportStar */) { + // synthesize export * from "moduleReference" + // Straightforward - only one thing to do - make an export declaration + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*exportClause*/ undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + } + } + function includePrivateSymbol(symbol) { + ts.Debug.assertDefined(deferredPrivates); + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` + // Note: This _mutates_ `node` without using `updateNode` - the assumption being that all nodes should be manufactured fresh by the node builder + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0 /* None */; + if (additionalModifierFlags & 1 /* Export */ && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private + newModifierFlags |= 1 /* Export */; + } + if (addingDeclare && !(newModifierFlags & 1 /* Export */) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope + newModifierFlags |= 2 /* Ambient */; + } + if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* Default */; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; // Reset computed flags cache + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608 /* InTypeAlias */; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 164 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 165 /* ConstructSignature */); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather + // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, + // so we don't even have placeholders to fill in. + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, /*suppressNewPrivateContext*/ false); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + ts.forEach(mergedMembers, includePrivateSymbol); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + return ts.createExportSpecifier(name === localName ? undefined : localName, name); + })))]); + addResult(ts.createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ + // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` + var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined + : isConstVariable(symbol) ? 2 /* Const */ + : 1 /* Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a seperate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0 /* None */); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0 /* Call */); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + // Each overload becomes a separate function declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, 243 /* FunctionDeclaration */, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + // Module symbol emit will take care of module-y members, provided it has exports + if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + // handle remote props first - we need to make an `import` declaration that points at the module containing each remote + // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) + // Example: + // import Foo_1 = require("./exporter"); + // export namespace ns { + // import Foo = Foo_1.Foo; + // export { Foo }; + // export const c: number; + // } + // This is needed because in JS, statements like `const x = require("./f")` support both type and value lookup, even if they're + // normally just value lookup (so it functions kinda like an alias even when it's not an alias) + // _Usually_, we'll simply print the top-level as an alias instead of a `var` in such situations, however is is theoretically + // possible to encounter a situation where a type has members from both the current file and other files - in those situations, + // emit akin to the above would be needed. + // Add a namespace + var fakespace = ts.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16 /* Namespace */); + fakespace.flags ^= 8 /* Synthesized */; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + // TODO: implement handling for the localVsRemoteMap.get("remote") - should be difficult to trigger (see comment above), as only interesting cross-file js merges should make this possible + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, /*propertyAsAlias*/ true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8 /* Synthesized */; // reset synthesized + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); // namespaces can never be default exported + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); + // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics + var staticMembers = symbol.flags & (16 /* Function */ | 512 /* ValueModule */) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var constructors = serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 161 /* Constructor */); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + // A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration + // `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + // synthesize an alias, eg `export { symbolName as Name }` + // need to mark the alias `symbol` points + // at as something we need to serialize as a private declaration as well + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" /* ExportEquals */ && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match + verbatimTargetName = "default" /* Default */; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first + switch (node.kind) { + case 252 /* ImportEqualsDeclaration */: + // Could be a local `import localName = ns.member` or + // an external `import localName = require("whatever")` + var isLocalImport = !(target.flags & 512 /* ValueModule */); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0 /* None */); + break; + case 251 /* NamespaceExportDeclaration */: + // export as namespace foo + // TODO: Not part of a file's local or export symbol tables + // Is bound into file.symbol.globalExports instead, which we don't currently traverse + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + break; + case 254 /* ImportClause */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(ts.createIdentifier(localName), /*namedBindings*/ undefined), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0 /* None */); + break; + case 255 /* NamespaceImport */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + break; + case 257 /* ImportSpecifier */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0 /* None */); + break; + case 261 /* ExportSpecifier */: + // does not use localName because the symbol name in this case refers to the name in the exports table, + // which we must exactly preserve + var specifier = node.parent.parent.moduleSpecifier; + // targetName is only used when the target is local, as otherwise the target is an alias that points at + // another file + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258 /* ExportAssignment */: + serializeMaybeAliasAssignment(symbol); + break; + case 208 /* BinaryExpression */: + // Could be best encoded as though an export specifier or as though an export assignment + // If name is default or export=, do an export assignment + // Otherwise do an export specifier + if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + case 193 /* PropertyAccessExpression */: + // A PAE alias is _always_ going to exist as an append to a top-level export, where our top level + // handling should always be sufficient to encode the export action itself + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304 /* Prototype */) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export=" /* ExportEquals */; + var isDefault = name === "default" /* Default */; + var isExportAssignment = isExportEquals || isDefault; + // synthesize export = ref + // ref should refer to either be a locally scoped symbol which we need to emit, or + // a reference to another namespace/module which we may need to emit an `import` statement for + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + // serialize what the alias points to, preserve the declaration's initializer + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + if (target) { + // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it + // eg, `namespace A { export class B {} }; exports = A.B;` + // Technically, this is all that's required in the case where the assignment is an entity name expression + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + // We disable the context's symbol traker for the duration of this name serialization + // as, by virtue of being here, the name is required to print something, and we don't want to + // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue + // a visibility error here (as they're not visible within any scope), but we want to hoist them + // into the containing scope anyway, so we want to skip the visibility checks. + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + } + else { + if (first_1 === expr) { + // serialize as `export {target as name}` + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + // serialize as `import _Ref = t.arg.et; export { _Ref as name }` + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + // serialize as an anonymous property declaration + var varName = getUnusedName(name, symbol); + // We have to use `getWidenedType` here since the object within a json file is unwidened within the file + // (Unwidened types can only exist in expression contexts and should never be serialized) + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); + } + else { + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2 /* Const */)); + addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + // Only object types which are not constructable, or indexable, whose members all come from the + // context source file, and whose property names are all valid identifiers and not late-bound, _and_ + // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + !getIndexInfoOfType(typeToSerialize, 0 /* String */) && + !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols + // need to be merged namespace members + return []; + } + if (p.flags & 4194304 /* Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 /* Static */ : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 /* Accessor */ && useAccessors) { + var result = []; + if (p.flags & 65536 /* SetAccessor */) { + result.push(ts.setTextRange(ts.createSetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "arg", + /*questionToken*/ undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], + /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768 /* GetAccessor */) { + result.push(ts.setTextRange(ts.createGetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + // This is an else/if as accessors and properties can't merge in TS, but might in JS + // If this happens, we assume the accessor takes priority, as it imposes more constraints + else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { + return ts.setTextRange(createProperty( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | staticFlag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), + // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 + // interface members can't have initializers, however class members _can_ + /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0 /* Call */); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + // Each overload becomes a separate method declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; // TODO: Clone + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216 /* Optional */) { + decl.questionToken = ts.createToken(57 /* QuestionToken */); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 /* UniqueESSymbol */ && + type.symbol === symbol) { + context.flags |= 1048576 /* AllowUniqueESSymbolType */; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124 /* AnyKeyword */); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99 /* NullKeyword */)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, "x", + /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144 /* TypeParameter */) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1 /* Construct */) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // No base type, every constructor is empty - elide the extraneous `constructor()` + } + if (baseType) { + // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations + var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; // Every signature was identical - elide constructor list as it is inherited + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + // Each overload becomes a separate constructor declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0 /* String */, 1 /* Number */]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2 /* Const */)); + addResult(statement, 0 /* None */); + return ts.createExpressionWithTypeArguments(/*typeArgs*/ undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + // We don't use `isValueSymbolAccessible` below. since that considers alternative containers (like modules) + // which we can't write out in a syntactically valid way as an expression + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (input === "default" /* Default */) { + input = "_default"; + } + else if (input === "export=" /* ExportEquals */) { + input = "_exports"; + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + var flags = context.flags; + context.flags |= 16777216 /* InInitialEntityName */; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = ts.isIdentifierText(nameCandidate, languageVersion) && !ts.isStringANonContextualKeyword(nameCandidate) ? nameCandidate : getUnusedName("_default", symbol); + } + // The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createToken(123 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); @@ -35806,8 +38340,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 !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181 /* ParenthesizedType */; }); + if (node.kind === 246 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -35815,11 +38349,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 249 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 288 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35857,9 +38391,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -35872,17 +38406,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 241 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -35899,27 +38436,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 241 /* 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 247 /* EnumDeclaration */: + case 252 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -35927,53 +38465,54 @@ 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 !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 252 /* ImportEqualsDeclaration */ && parent.kind !== 288 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* 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 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 161 /* Constructor */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 155 /* Parameter */: + case 249 /* ModuleBlock */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 168 /* TypeReference */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 181 /* 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 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 288 /* SourceFile */: + case 251 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return false; default: return false; @@ -35982,14 +38521,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 258 /* ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 261 /* ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -36007,8 +38549,10 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); - if (importSymbol) { + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -36071,8 +38615,10 @@ var ts; } return ts.Debug.assertNever(propertyName); } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. + /** + * Pop an entry from the type resolution stack and return its associated result value. The result value will + * be true if no circularities were detected, or false if a circularity was found. + */ function popTypeResolution() { resolutionTargets.pop(); resolutionPropertyNames.pop(); @@ -36081,12 +38627,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 241 /* VariableDeclaration */: + case 242 /* VariableDeclarationList */: + case 257 /* ImportSpecifier */: + case 256 /* NamedImports */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: return false; default: return true; @@ -36119,7 +38665,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36171,7 +38717,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(194 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36186,23 +38732,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 190 /* BindingElement */ && parent.kind === 188 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 279 /* PropertyAssignment */ || node.kind === 280 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36220,11 +38766,11 @@ var ts; 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)) { + if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 188 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36292,30 +38838,30 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 /* NullKeyword */ || expr.kind === 73 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 /* NullKeyword */ || expr.kind === 75 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 191 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 155 /* Parameter */ && + (node.parent.kind === 200 /* FunctionExpression */ || node.parent.kind === 201 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration 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 === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230 /* 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 === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231 /* 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, @@ -36334,8 +38880,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { + declaration.kind === 241 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -36348,11 +38894,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 155 /* 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 === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 163 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36419,12 +38965,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4 /* ThisProperty */) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -36442,6 +38990,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { @@ -36467,9 +39018,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -36562,9 +39113,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 === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 /* Constructor */ || + thisContainer.kind === 243 /* FunctionDeclaration */ || + (thisContainer.kind === 200 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -36639,7 +39190,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -36662,7 +39213,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -36701,7 +39252,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 155 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -36763,16 +39314,20 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 258 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -36813,6 +39368,9 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } @@ -36827,7 +39385,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -36854,59 +39412,65 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 163 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return errorType; - } - var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { // If there are no specified types, try to infer it from the body of the get accessor if it exists. if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } // Otherwise, fall back to 'any'. else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* 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)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -36914,19 +39478,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -36938,8 +39493,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 208 /* BinaryExpression */ || + (declaration.kind === 193 /* PropertyAccessExpression */ || declaration.kind === 194 /* ElementAccessExpression */) && + declaration.parent.kind === 208 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -36978,7 +39534,7 @@ var ts; // type symbol, call getDeclaredTypeOfSymbol. // This check is important because without it, a call to getTypeOfSymbol could end // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 67220415 /* Value */ + links.type = targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -37006,7 +39562,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -37087,39 +39643,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 185 /* MappedType */: + case 179 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 185 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 179 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */ || node.kind === 245 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37127,7 +39694,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, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37136,9 +39703,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || + node.kind === 213 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37157,19 +39725,19 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37262,24 +39830,18 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37317,14 +39879,21 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } - // A valid base type is `any`, any non-generic object type or intersection of non-generic - // object types. + // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { + if (type.flags & 262144 /* TypeParameter */) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } + // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? + // There's no reason a `T` should be allowed while a `Readonly` should not. return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } @@ -37332,7 +39901,7 @@ var ts; 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 === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37368,8 +39937,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { - if (declaration.flags & 64 /* ContainsThis */) { + if (declaration.kind === 245 /* InterfaceDeclaration */) { + if (declaration.flags & 128 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -37377,7 +39946,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832 /* Type */, /*ignoreErrors*/ true); + var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -37390,9 +39959,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37408,7 +39983,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -37424,9 +39999,10 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243 /* TypeAliasDeclaration */; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("Type alias symbol with no valid declaration found"); + } var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -37442,17 +40018,17 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 208 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37460,18 +40036,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304 /* Ambient */); + return !(member.flags & 8388608 /* Ambient */); } switch (expr.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 39 /* MinusToken */ && + case 206 /* PrefixUnaryExpression */: + return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37485,10 +40062,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -37512,7 +40089,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -37584,23 +40161,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: + case 186 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -37626,7 +40203,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -37642,14 +40219,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -37704,9 +40281,12 @@ var ts; * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 /* _ */ && @@ -37759,7 +40339,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -37800,7 +40380,8 @@ var ts; // In the event we attempt to resolve the late-bound name of this member recursively, // fall back to the early-bound name of this member. links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -37816,9 +40397,9 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); } lateSymbol.nameType = type; @@ -37859,6 +40440,21 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + || assignmentKind === 4 /* ThisProperty */ + || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; @@ -37869,7 +40465,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 /* LateBindingContainer */ + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) : symbol.members || emptySymbols; } @@ -37899,7 +40495,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4 /* Reference */) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -37962,9 +40558,9 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { var sig = new Signature(checker); @@ -37995,13 +40591,18 @@ var ts; result.mapper = undefined; return result; } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.isOptionalCall = true; + return result; + } function getExpandedParameters(sig) { if (sig.hasRestParameter) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -38021,7 +40622,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38065,8 +40666,9 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true); + // Allow matching non-generic signatures to have excess parameters and different return types. + // Prefer matching this types if possible. + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -38090,7 +40692,7 @@ var ts; for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true)) { + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -38099,7 +40701,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -38117,7 +40719,7 @@ var ts; // signatures from the type, whose ordering would be non-obvious) var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -38129,8 +40731,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -38143,8 +40745,8 @@ var ts; } // A signature `this` type might be a read or a write position... It's very possible that it should be invariant // and we should refuse to merge signatures if there are `this` types and they do not match. However, so as to be - // permissive when calling, for now, we'll union the `this` types just like the overlapping-union-signature check does - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2 /* Subtype */); + // permissive when calling, for now, we'll intersect the `this` types just like we do for param types in union signatures. + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -38255,7 +40857,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -38278,19 +40880,19 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } @@ -38298,7 +40900,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38354,14 +40956,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38504,8 +41110,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && - constraintDeclaration.operator === 130 /* KeyOfKeyword */; + return constraintDeclaration.kind === 183 /* TypeOperator */ && + constraintDeclaration.operator === 133 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -38518,7 +41124,7 @@ var ts; else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T', - // the modifiers type is T. Otherwise, the modifiers type is {}. + // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; @@ -38529,8 +41135,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - 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); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -38746,11 +41352,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; 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). @@ -38760,6 +41366,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908 /* DisjointDomains */) { @@ -38772,8 +41381,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -38859,8 +41468,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -39208,10 +41817,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 === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 297 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39245,13 +41854,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; - } - function createThisTypePredicate(type) { - return { kind: 0 /* This */, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } /** * Gets the minimum number of type arguments needed to satisfy all non-optional type @@ -39317,7 +41923,7 @@ var ts; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415 /* Value */, undefined, undefined, /*isUse*/ false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this" /* This */) { @@ -39327,7 +41933,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { + if (type && type.kind === 186 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -39341,16 +41947,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 === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 162 /* GetAccessor */ || declaration.kind === 163 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 161 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -39408,13 +42014,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return node.name.kind === 153 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39457,9 +42063,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -39488,13 +42091,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73 /* Identifier */) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 /* ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -39504,8 +42104,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signature.isOptionalCall) { + type = propagateOptionalTypeMarker(type, /*wasOptional*/ true); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -39530,7 +42132,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 161 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39540,12 +42142,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39635,7 +42237,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 161 /* Constructor */ || kind === 165 /* ConstructSignature */ || kind === 170 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -39649,7 +42251,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 136 /* NumberKeyword */ : 139 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 139 /* NumberKeyword */ : 142 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -39676,21 +42278,20 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 180 /* 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 === 165 /* TypeReference */) { + if (grandParent.kind === 168 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -39715,7 +42316,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 === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -39739,7 +42340,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -39772,8 +42373,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -39788,7 +42389,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -39797,16 +42398,38 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; + return type; + } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4 /* Reference */, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; return type; } + function getTypeArguments(type) { + if (!type.resolvedTypeArguments) { + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -39816,13 +42439,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -39830,10 +42453,13 @@ var ts; return errorType; } } + if (node.kind === 168 /* TypeReference */ && isAliasedType(node)) { + return createDeferredTypeReference(type, node, /*mapper*/ undefined); + } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -39854,27 +42480,27 @@ var ts; * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -39885,34 +42511,22 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); } - // JS enums are 'string' or 'number', not an enum type. - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5 /* EnumTagType */)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -39921,55 +42535,31 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 67897832 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value imported from commonjs. + * These should really be aliases, but this special-case code fakes alias resolution + * by producing a type from a value. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); - } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && // Make sure this is a commonjs export by checking that symbol -> type -> symbol doesn't roundtrip. + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } } function getSubstitutionType(typeVariable, substitute) { @@ -39988,7 +42578,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 174 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -39997,9 +42587,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 301 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 179 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40010,7 +42600,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 168 /* TypeReference */ || node.kind === 187 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40047,10 +42637,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40062,7 +42652,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40075,10 +42665,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832 /* Type */; + var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -40111,9 +42710,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return declaration; } } @@ -40133,10 +42732,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { // Don't track references for global symbols anyway, so value if `isReference` is arbitrary @@ -40205,7 +42804,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -40232,15 +42831,55 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 /* ArrayType */ || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176 /* RestType */) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 /* OptionalType */ && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); + } + // Return true when the given node is transitively contained in type constructs that eagerly + // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments + // of type aliases are eagerly resolved. + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181 /* ParenthesizedType */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 184 /* IndexedAccessType */: + case 179 /* ConditionalType */: + case 183 /* TypeOperator */: + return isAliasedType(parent); + case 246 /* TypeAliasDeclaration */: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 /* TupleType */ && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, /*mapper*/ undefined); + } + else { + var elementTypes = node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 137 /* ReadonlyKeyword */; } // We represent tuple types as type references to synthesized generic interface types created by // this function. The types are of the form: @@ -40277,7 +42916,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -40311,27 +42950,13 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* 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; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { // don't slice off rest element index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -40380,8 +43005,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -40410,8 +43035,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -40496,10 +43121,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { continue; } if (first) { @@ -40518,14 +43143,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } // This function assumes the constituent type list is sorted and deduplicated. function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { @@ -40592,8 +43213,8 @@ var ts; // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -40631,6 +43252,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } // If the given list of types contains more than one union of primitive types, replace the // first with a union containing an intersection of those primitive types, then remove the // other unions and return true. Otherwise, do nothing and return false. @@ -40749,6 +43379,12 @@ var ts; // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768 /* Undefined */)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536 /* Null */)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } else { // 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. @@ -40853,20 +43489,22 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130 /* KeyOfKeyword */: + case 133 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 140 /* SymbolKeyword */ + case 146 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 143 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -40902,7 +43540,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -40913,13 +43551,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 103 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -41050,13 +43688,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 184 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 153 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41181,7 +43816,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 !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41393,7 +44028,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 67220415 /* Value */ | 67897832 /* Type */ : 67897832 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41416,14 +44051,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 /* Value */ + var errorMessage = targetMeaning === 111551 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -41432,16 +44067,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + if (meaning === 111551 /* Value */) { + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41465,7 +44100,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -41654,12 +44293,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -41672,89 +44325,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 124 /* AnyKeyword */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return anyType; - case 144 /* UnknownKeyword */: + case 147 /* UnknownKeyword */: return unknownType; - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return stringType; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return numberType; - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return bigintType; - case 124 /* BooleanKeyword */: + case 127 /* BooleanKeyword */: return booleanType; - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return esSymbolType; - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return voidType; - case 142 /* UndefinedKeyword */: + case 145 /* UndefinedKeyword */: return undefinedType; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullType; - case 133 /* NeverKeyword */: + case 136 /* NeverKeyword */: return neverType; - case 137 /* ObjectKeyword */: - return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 140 /* ObjectKeyword */: + return node.flags & 131072 /* JavaScriptFile */ ? anyType : nonPrimitiveType; + case 182 /* ThisType */: + case 103 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: - return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 167 /* TypePredicate */: + return node.assertsModifier ? voidType : booleanType; + case 215 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + return getTypeFromArrayOrTupleTypeNode(node); + case 175 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 181 /* ParenthesizedType */: + case 296 /* JSDocNonNullableType */: + case 292 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 180 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 187 /* 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 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -41843,20 +44496,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1 /* Identifier */, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0 /* This */, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -41910,17 +44550,17 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -41936,7 +44576,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -41949,13 +44589,14 @@ var ts; // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -41963,8 +44604,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 152 /* QualifiedName */ || + node.parent.kind === 168 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -41973,7 +44615,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 /* Block */ || n.kind === 179 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -41982,12 +44624,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 182 /* ThisType */: return !!tp.isThisType; - case 73 /* Identifier */: + case 75 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42041,7 +44683,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -42137,15 +44779,18 @@ var ts; // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32 /* Mapped */) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4 /* Reference */) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -42209,35 +44854,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: - return node.operatorToken.kind === 55 /* BarBarToken */ && + case 208 /* BinaryExpression */: + return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 271 /* 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 271 /* JsxExpression */: { + case 274 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42257,7 +44902,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* 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); @@ -42269,7 +44914,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42372,23 +45017,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 274 /* JsxExpression */: + case 199 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -42560,7 +45205,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -42569,9 +45214,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -42645,7 +45290,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -42713,11 +45358,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 163 /* SetAccessor */: return [3 /*break*/, 2]; + case 162 /* GetAccessor */: return [3 /*break*/, 2]; + case 160 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 280 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 279 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -42752,7 +45397,7 @@ var ts; } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { return compareSignaturesRelated(source, target, 0 /* None */, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -42765,7 +45410,7 @@ var ts; /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -42789,8 +45434,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 /* MethodDeclaration */ && + kind !== 159 /* MethodSignature */ && kind !== 161 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -42823,11 +45468,11 @@ var ts; // with respect to T. var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (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) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -42838,15 +45483,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -42867,6 +45514,9 @@ var ts; // wouldn't be co-variant for T without this rule. result &= callbackCheck === 1 /* Bivariant */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -42879,7 +45529,7 @@ var ts; } return 0 /* False */; } - if (source.kind === 1 /* Identifier */) { + if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -42888,7 +45538,9 @@ var ts; return 0 /* False */; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -42934,12 +45586,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { - return relation === 1 /* Succeeded */; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { + return !!(entry & 1 /* Succeeded */); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -42950,7 +45602,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); } else { enumRelation.set(id, 2 /* Failed */); @@ -43029,7 +45681,7 @@ var ts; if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { - return related === 1 /* Succeeded */; + return !!(related & 1 /* Succeeded */); } } if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { @@ -43061,9 +45713,14 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -43093,7 +45750,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -43106,8 +45763,131 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0 /* False */; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; // Suppress the next relation error + lastSkippedInfo = undefined; // Reset skipped info cache + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + return; + } + // The first error will be the innermost, while the last will be the outermost - so by popping off the end, + // we can build from left to right + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + // Parenthesize a `new` if there is one + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + // If leading, just print back the arg (irrespective of if it's a valid identifier) + if (path.length === 0) { + path = "" + str; + } + // Otherwise write a dotted name if possible + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + // Failing that, check if the name is already a computed name + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + // And finally write out a computed name as a last resort + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + // Don't flatten signature compatability errors at the start of a chain - instead prefer + // to unify (the with no arguments bit is excessive for printback) and print them back + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + // Remove the innermost secondary error as it will duplicate the error already reported by `reportRelationError` on entry + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; // Teporarily override elision to ensure error is reported + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -43120,6 +45900,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 /* TypeParameter */ && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -43138,8 +45920,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43232,7 +46014,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -43242,11 +46024,11 @@ var ts; return 0 /* False */; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = 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, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -43261,23 +46043,23 @@ var ts; return 0 /* False */; } var result = 0 /* False */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); 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 & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { if (target.flags & 1048576 /* Union */) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined, isIntersectionConstituent)) { return 0 /* False */; } } @@ -43285,9 +46067,9 @@ var ts; else if (target.flags & 2097152 /* Intersection */) { isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, /*isIntersectionConstituent*/ false)) { return 0 /* False */; } } @@ -43306,15 +46088,15 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); } if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152 /* Intersection */) { + if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) { // 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 @@ -43324,21 +46106,30 @@ 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 & 1048576 /* Union */)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) { + if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { @@ -43358,6 +46149,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } @@ -43394,7 +46186,7 @@ var ts; // check excess properties against discriminant type only, not the entire union return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -43409,6 +46201,11 @@ var ts; // 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) + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + // Note that extraneous children (as in `extra`) don't pass this check, + // since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute. + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -43437,9 +46234,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -43575,14 +46372,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { return related; } @@ -43602,7 +46399,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -43629,10 +46426,10 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t); } else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 3 /* Bivariant */) { // In the bivariant case we first compare contravariantly without reporting @@ -43641,16 +46438,16 @@ var ts; // which is generally easier to reason about. related = isRelatedTo(t, s, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } if (!related) { @@ -43661,17 +46458,6 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8 /* Unmeasurable */) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16 /* Unreliable */) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -43682,24 +46468,24 @@ var ts; return 0 /* False */; } var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2 /* Failed */) { + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24 /* ReportsMask */; + if (saved & 8 /* ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16 /* ReportsUnreliable */) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; } } if (!maybeKeys) { @@ -43730,14 +46516,26 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 /* True */ || depth === 0) { // If result is definitely true, record all maybe keys as having succeeded for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */); + relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); } maybeCount = maybeStart; } @@ -43745,7 +46543,7 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); + relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -43785,7 +46583,7 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); // 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. @@ -43793,7 +46591,7 @@ var ts; source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43875,7 +46673,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -43886,7 +46684,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43895,25 +46693,25 @@ var ts; if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43922,13 +46720,23 @@ var ts; // 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. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43937,14 +46745,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43958,7 +46766,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43977,7 +46785,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); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -44004,8 +46812,8 @@ var ts; // relates to X. Thus, we include intersection types on the source side here. 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, /*excludedProperties*/ undefined); + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; + result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); if (result) { @@ -44019,7 +46827,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; // Use variance error (there is no structural one) and return false } else if (result) { return result; @@ -44040,8 +46848,8 @@ var ts; } } return 0 /* False */; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { @@ -44050,7 +46858,7 @@ var ts; // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially // be assuming identity of the type parameter. originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -44078,7 +46886,7 @@ var ts; // comparison unexpectedly succeeds. This can happen when the structural comparison result // is a Ternary.Maybe for example caused by the recursion depth limiter. originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44154,11 +46962,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) @@ -44166,7 +46974,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -44174,8 +46982,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -44188,15 +46996,15 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, /*isIntersectionConstituent*/ false); if (result) { result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); if (result) { @@ -44231,7 +47039,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { @@ -44271,10 +47079,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -44312,10 +47120,10 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0 /* False */; } @@ -44335,7 +47143,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -44351,12 +47159,12 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) { @@ -44366,8 +47174,8 @@ var ts; 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(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined) @@ -44379,7 +47187,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -44404,8 +47212,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -44419,12 +47228,14 @@ var ts; // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members var properties = target.flags & 1048576 /* Union */ ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304 /* Prototype */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0 /* False */; } @@ -44487,14 +47298,15 @@ var ts; } } var result = -1 /* True */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 /* Instantiated */ && ts.getObjectFlags(target) & 64 /* Instantiated */ && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters // as they are known to always be the same. for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0 /* False */; } @@ -44508,7 +47320,7 @@ var ts; // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -44517,10 +47329,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -44533,11 +47345,23 @@ var ts; } return result; } + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } /** * See signatureAssignableTo, compareSignaturesIdentical */ - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -44603,7 +47427,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -44659,23 +47483,27 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + // undefined=unknown, true=discriminated, false=not discriminated + // The state of each type progresses from left to right. Discriminated types stop at 'true'. + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; // Finding multiple fields which discriminate to the same type is fine - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; + } + else { + discriminable[i] = false; } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(/*searchElement*/ true); + // make sure exactly 1 matches before returning it + return match === -1 || discriminable.indexOf(/*searchElement*/ true, match + 1) !== -1 ? defaultValue : target.types[match]; } /** * A type is 'weak' if it is an object type with at least one optional property @@ -44731,7 +47559,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -44763,7 +47591,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -44789,8 +47617,11 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -44799,7 +47630,7 @@ var ts; function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -44878,6 +47709,9 @@ var ts; // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 // levels, but unequal at some level beyond that. + // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially + // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives + // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`). 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 & 524288 /* Object */) { @@ -44894,8 +47728,30 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608 /* IndexedAccess */) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + /** + * Gets the leftmost object type in a chain of indexed accesses, eg, in A[P][Q], returns A + */ + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608 /* IndexedAccess */) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -45003,20 +47859,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - // If they're both type predicates their return types will both be `boolean`, so no need to compare those. - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : + source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type) : + 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -45055,7 +47913,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, @@ -45063,7 +47921,7 @@ var ts; return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -45147,7 +48005,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -45162,8 +48020,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -45228,6 +48086,41 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, function (t) { return t !== optionalType; }) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function createPooledOptionalTypeResult(isOptional, type) { + pooledOptionalTypeResult.isOptional = isOptional; + pooledOptionalTypeResult.type = type; + return pooledOptionalTypeResult; + } + function checkOptionalExpression(parent, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + var isOptional = false; + var type = checkExpression(expression); + if (ts.isOptionalChain(parent)) { + if (parent.questionDotToken) { + // If we have a questionDotToken then we are an OptionalExpression and should remove `null` and + // `undefined` from the type and add the optionalType to the result, if needed. + isOptional = isNullableType(type); + return createPooledOptionalTypeResult(isOptional, isOptional ? getNonNullableType(type) : type); + } + // If we do not have a questionDotToken, then we are an OptionalChain and we remove the optionalType and + // indicate whether we need to add optionalType back into the result. + var nonOptionalType = removeOptionalTypeMarker(type); + if (nonOptionalType !== type) { + isOptional = true; + type = nonOptionalType; + } + } + type = checkNonNullType(type, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + return createPooledOptionalTypeResult(isOptional, type); + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -45257,8 +48150,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45410,7 +48303,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -45447,7 +48340,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -45477,17 +48370,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 208 /* BinaryExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* 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 152 /* Parameter */: + case 155 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -45497,23 +48390,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -45527,7 +48420,7 @@ var ts; wideningKind === 1 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182 /* MappedType */: + case 185 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -45569,8 +48462,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 /* This */ || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -45639,6 +48531,12 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } @@ -45648,10 +48546,10 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & 32 /* Mapped */ || - type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -45717,10 +48615,10 @@ 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, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), 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.readonly, source.target.associatedNames); @@ -45806,8 +48704,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256 /* MaxValue */; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -45830,50 +48727,57 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - 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) { - for (var _i = 0, _a = source.types; _i < _a.length; _i++) { - var t = _a[_i]; - inferFromTypes(t, t); - } - return; - } - // Find each source constituent type that has an identically matching target constituent - // type, and for each such type infer from the type to itself. When inferring from a - // type to itself we effectively find all type parameter occurrences within that type - // and infer themselves as their type arguments. We have special handling for numeric - // and string literals because the number and string types are not represented as unions - // of all their possible values. - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } - } - // Next, to improve the quality of inferences, reduce the source and target types by - // removing the identically matched constituents. For example, when inferring from - // 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'. - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + // When source and target are the same union or intersection type, just relate each constituent + // type to itself. + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } + return; } - else if (target.flags & 1048576 /* Union */ && !(target.flags & 1024 /* EnumLiteral */) || target.flags & 2097152 /* Intersection */) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); + if (target.flags & 1048576 /* Union */) { + // First, infer between identically matching source and target constituents and remove the + // matching types. + var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + // Next, infer between closely matching source and target constituents and remove + // the matching types. Types closely match when they are instantiations of the same + // object type or instantiations of the same type alias. + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { + return; + } + target = getUnionType(targets); + if (sources.length === 0) { + // All source constituents have been matched and there is nothing further to infer from. + // However, simply making no inferences is undesirable because it could ultimately mean + // inferring a type parameter constraint. Instead, make a lower priority inference from + // the full source to whatever remains in the target. For example, when inferring from + // string to 'string | T', make a lower priority inference of string for T. + var savePriority = priority; + priority |= 1 /* NakedTypeVariable */; + inferFromTypes(source, target); + priority = savePriority; return; } + source = getUnionType(sources); + } + else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + // We reduce intersection types only when they contain naked type parameters. For example, when + // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and + // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the + // string[] on the source side and infer string for T. + // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" + // in such scenarios. + if (!(source.flags & 1048576 /* Union */)) { + // Infer between identically matching source and target constituents and remove the matching types. + var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); + } } else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { target = getActualTypeVariable(target); @@ -45918,7 +48822,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -45940,9 +48844,10 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; @@ -45978,8 +48883,8 @@ var ts; else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -46009,15 +48914,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1 /* Circularity */); + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -46057,31 +48983,34 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; + var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we - // track whether inferences were made from that particular type to some target. - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + // track whether inferences were made from that particular type to some target with + // equal priority (i.e. of equal quality) to what we would infer for a naked type + // parameter. + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - // If the target has a single naked type variable and inference completed (meaning we - // explored the types fully), create a union of the source types from which no inferences - // have been made so far and infer from that union to the naked type variable. - if (typeVariableCount === 1 && inferenceComplete) { + // If the target has a single naked type variable and no inference circularities were + // encountered above (meaning we explored the types fully), create a union of the source + // types from which no inferences have been made so far and infer from that union to the + // naked type variable. + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -46093,8 +49022,8 @@ var ts; // We infer from types that are not naked type variables first so that inferences we // make from nested naked type variables and given slightly higher priority by virtue // of being first in the candidates array. - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -46110,8 +49039,8 @@ var ts; if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1 /* NakedTypeVariable */; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -46185,7 +49114,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1 /* Circularity */; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -46197,6 +49126,11 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + // If source and target are references to the same generic type, infer from type arguments + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } 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 // from S to T and from X to Y. @@ -46226,10 +49160,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -46269,7 +49203,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 === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 160 /* MethodDeclaration */ || kind === 159 /* MethodSignature */ || kind === 161 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46295,46 +49229,12 @@ var ts; } } } - function isMatchableType(type) { - // We exclude non-anonymous object types because some frameworks (e.g. Ember) rely on the ability to - // infer between types that don't witness their type variables. Such types would otherwise be eliminated - // because they appear identical. - return !(type.flags & 524288 /* Object */) || !!(ts.getObjectFlags(type) & 16 /* Anonymous */); + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */) && target.flags & 1048576 /* Union */) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; - } - /** - * Return a new union or intersection type computed by removing a given set of types - * from a given union or intersection type. - */ - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -46473,7 +49373,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46485,7 +49385,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; @@ -46494,7 +49394,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 === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 /* TypeQuery */ ? true : n.kind === 75 /* Identifier */ || n.kind === 152 /* 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 @@ -46504,16 +49404,16 @@ var ts; // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46524,24 +49424,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73 /* Identifier */: - return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + case 75 /* Identifier */: + return target.kind === 75 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 /* VariableDeclaration */ || target.kind === 190 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 101 /* ThisKeyword */: - return target.kind === 101 /* ThisKeyword */; - case 99 /* SuperKeyword */: - return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 103 /* ThisKeyword */: + return target.kind === 103 /* ThisKeyword */; + case 101 /* SuperKeyword */: + return target.kind === 101 /* SuperKeyword */; + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -46549,8 +49449,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 /* PropertyAccessExpression */ ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -46574,7 +49474,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73 /* Identifier */) { + if (expr.kind === 75 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -46605,7 +49505,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -46633,14 +49533,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 193 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -46682,8 +49582,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -46788,15 +49688,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 208 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 231 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -46813,21 +49713,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -46835,7 +49735,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -46853,37 +49753,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 230 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 231 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 241 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 241 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 190 /* BindingElement */ && node.parent.kind === 208 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -46893,13 +49788,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 199 /* ParenthesizedExpression */ || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -46921,8 +49816,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { - if (clause.expression.kind === 10 /* StringLiteral */) { + if (clause.kind === 275 /* CaseClause */) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -47005,8 +49900,7 @@ var ts; return mapType(typeWithPrimitives, function (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; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47058,8 +49952,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47082,33 +49976,78 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 193 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 195 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 60 /* EqualsToken */ && + parent.parent.kind === 208 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 /* VariableDeclaration */ || declaration.kind === 155 /* Parameter */ || + declaration.kind === 158 /* PropertyDeclaration */ || declaration.kind === 157 /* PropertySignature */) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99 /* SuperKeyword */) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + // We require the dotted function name in an assertion expression to be comprised of identifiers + // that reference function, method, class or value module symbols; or variable, property or + // parameter symbols with declarations that have explicit type annotations. Such references are + // resolvable with no possibility of triggering circularities in control flow analysis. + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216 /* InWithStatement */)) { + switch (node.kind) { + case 75 /* Identifier */: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 103 /* ThisKeyword */: + return getExplicitThisType(node); + case 193 /* PropertyAccessExpression */: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199 /* ParenthesizedExpression */: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + // A call expression parented by an expression statement is a potential assertion. Other call + // expressions are potential type predicate function calls. In order to avoid triggering + // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call + // target expression of an assertion. + var funcType = node.parent.kind === 225 /* ExpressionStatement */ ? getTypeOfDottedName(node.expression, /*diagnostic*/ undefined) : + node.expression.kind !== 101 /* SuperKeyword */ ? checkOptionalExpression(node, node.expression).type : + undefined; + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -47116,6 +50055,68 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 /* PreFinally */ && flow.lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048 /* Shared */) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + } + noCacheCheck = false; + } + if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 4096 /* PreFinally */)) { + flow = flow.antecedent; + } + else if (flags & 512 /* Call */) { + var signature = getEffectsSignature(flow.node); + if (signature && getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 4 /* BranchLabel */) { + // A branching point is reachable if any branch is reachable. + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8 /* LoopLabel */) { + // A loop is reachable if the control flow path that leads to the top is reachable. + flow = flow.antecedents[0]; + } + else if (flags & 128 /* SwitchClause */) { + // The control flow path representing an unmatched value in a switch statement with + // no default clause is unreachable if the switch statement is exhaustive. + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192 /* AfterFinally */) { + // Cache is unreliable once we start locking nodes + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, /*skipCacheCheck*/ false); + flow.locked = false; + return result; + } + else { + return !(flags & 1 /* Unreachable */); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -47127,6 +50128,7 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; @@ -47135,7 +50137,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47157,16 +50159,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192 /* Cached */) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -47178,13 +50171,13 @@ var ts; } } var type = void 0; - if (flags & 4096 /* AfterFinally */) { + if (flags & 8192 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048 /* PreFinally */) { + else if (flags & 4096 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; @@ -47196,14 +50189,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192 /* Cached */; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512 /* Call */) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96 /* Condition */) { @@ -47230,11 +50221,11 @@ var ts; } else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && - reference.kind !== 101 /* ThisKeyword */) { + reference.kind !== 193 /* PropertyAccessExpression */ && + reference.kind !== 194 /* ElementAccessExpression */ && + reference.kind !== 103 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -47246,7 +50237,7 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // Record visited node and the associated type in the cache. sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; @@ -47256,11 +50247,34 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384 /* Cached */) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */ ? + getInitialType(node) : + getAssignedType(node), reference); + // We cache the assigned type when getFlowTypeOfReference was recursively invoked in the + // resolution of the assigned type and we're not within loop analysis. + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384 /* Cached */; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -47269,11 +50283,11 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } @@ -47282,27 +50296,60 @@ var ts; // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } // A matching dotted name might also be an expando property on a function *expression*, // 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 === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 200 /* FunctionExpression */ || init.kind === 201 /* 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 === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 208 /* BinaryExpression */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56 /* BarBarToken */) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, /*assumeTrue*/ true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : + predicate.kind === 3 /* AssertsIdentifier */ ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 195 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47310,7 +50357,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47345,7 +50392,7 @@ var ts; // *only* place a silent never type is ever generated. var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -47363,12 +50410,15 @@ 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 === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { type = declaredType; } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } return createFlowType(type, isIncomplete(flowType)); } function getTypeAtFlowBranchLabel(flow) { @@ -47377,7 +50427,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + if (antecedent.flags & 4096 /* PreFinally */ && antecedent.lock.locked) { // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. @@ -47437,25 +50487,32 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + // The first antecedent of a loop junction is always the non-looping control + // flow path that leads to the top. + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - // If we see a value appear in the cache it is a sign that control flow analysis - // was restarted and completed by checkExpressionCached. We can simply pick up - // the resulting type and bail out. - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + // All but the first antecedent are the looping control flow paths that lead + // back to the loop junction. We track these on the flow loop stack. + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + // If we see a value appear in the cache it is a sign that control flow analysis + // was restarted and completed by checkExpressionCached. We can simply pick up + // the resulting type and bail out. + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control @@ -47529,19 +50586,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -47560,9 +50617,9 @@ var ts; return declaredType; } break; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94 /* InKeyword */: + case 96 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -47577,11 +50634,11 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && (operator === 35 /* EqualsEqualsEqualsToken */) && assumeTrue) { + if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { return valueType; } @@ -47594,7 +50651,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? @@ -47606,7 +50663,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* EqualsEqualsToken */ ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -47619,7 +50676,7 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // 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 @@ -47629,7 +50686,7 @@ var ts; } return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (type.flags & 1 /* Any */ && literal.text === "function") { @@ -47856,22 +50913,24 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { return type; } - if (ts.isIdentifierTypePredicate(predicate)) { + if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { var predicateArgument = callExpression.arguments[predicate.parameterIndex]; - if (predicateArgument) { + if (predicateArgument && predicate.type) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } @@ -47882,7 +50941,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { + if (ts.isAccessExpression(invokedExpression) && predicate.type) { var possibleReference = ts.skipParentheses(invokedExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -47897,27 +50956,44 @@ var ts; // Narrow the given type based on the given expression having the assumed boolean value. The returned type // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { + // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` + if (ts.isOptionalChainRoot(expr.parent) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 195 /* CallExpression */: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: - if (expr.operator === 52 /* ExclamationToken */) { + case 206 /* PrefixUnaryExpression */: + if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; @@ -47925,7 +51001,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 === 73 /* Identifier */) { + if (location.kind === 75 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -47946,9 +51022,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 249 /* ModuleBlock */ || + node.kind === 288 /* SourceFile */ || + node.kind === 158 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -47967,10 +51043,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 === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155 /* Parameter */) { symbol.isAssigned = true; } } @@ -47985,7 +51061,7 @@ 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 === 152 /* Parameter */ && + declaration.kind === 155 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -47993,10 +51069,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 193 /* PropertyAccessExpression */ || + parent.kind === 195 /* CallExpression */ && parent.expression === node || + parent.kind === 194 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 190 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48011,8 +51087,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -48030,7 +51109,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* 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 */)) { @@ -48051,7 +51130,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 === 241 /* ClassDeclaration */ + if (declaration.kind === 244 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48063,14 +51142,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 213 /* 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 !== 285 /* SourceFile */) { + while (container.kind !== 288 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 158 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48119,7 +51198,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 === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 155 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48128,8 +51207,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 === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 /* FunctionExpression */ || + flowContainer.kind === 201 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48137,11 +51216,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 4194304 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261 /* ExportSpecifier */) || + node.parent.kind === 217 /* NonNullExpression */ || + declaration.kind === 241 /* VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -48175,7 +51254,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 278 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48198,7 +51277,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, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48216,8 +51295,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 === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 229 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48235,7 +51314,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 199 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48243,9 +51322,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 206 /* PrefixUnaryExpression */ || current.parent.kind === 207 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -48256,7 +51335,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 158 /* PropertyDeclaration */ || container.kind === 161 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48324,37 +51403,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 161 /* 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 === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* 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 244 /* EnumDeclaration */: + case 247 /* 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 158 /* Constructor */: + case 161 /* 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 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* 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 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48393,10 +51472,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48404,12 +51481,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 200 /* FunctionExpression */ || container.kind === 243 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48438,9 +51513,22 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 200 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48450,16 +51538,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 160 /* MethodDeclaration */ && + container.parent.kind === 192 /* 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 === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && + container.parent.kind === 279 /* PropertyAssignment */ && + container.parent.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48467,7 +51555,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 197 /* FunctionExpression */ && + else if (container.kind === 200 /* 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") && @@ -48492,7 +51580,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 298 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48506,15 +51594,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 /* 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 === 198 /* ArrowFunction */) { + while (container && container.kind === 201 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48527,14 +51615,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153 /* ComputedPropertyName */; }); + if (current && current.kind === 153 /* 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 === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -48542,7 +51630,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 161 /* 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) { @@ -48611,7 +51699,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 === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 160 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -48625,7 +51713,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 192 /* 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; @@ -48646,7 +51734,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 /* 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; @@ -48661,7 +51749,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 === 158 /* Constructor */; + return container.kind === 161 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -48669,21 +51757,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 === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */ || + container.kind === 158 /* PropertyDeclaration */ || + container.kind === 157 /* PropertySignature */ || + container.kind === 161 /* Constructor */; } } } @@ -48691,14 +51779,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 160 /* MethodDeclaration */ || + func.kind === 162 /* GetAccessor */ || + func.kind === 163 /* SetAccessor */) && func.parent.kind === 192 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 200 /* FunctionExpression */ && func.parent.kind === 279 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -48706,7 +51794,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -48733,7 +51821,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 279 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -48747,9 +51835,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 === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 193 /* PropertyAccessExpression */ || target.kind === 194 /* 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)) { @@ -48813,9 +51901,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 155 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -48905,6 +51993,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -48936,7 +52033,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 197 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -48945,7 +52042,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: if (node !== right) { return undefined; } @@ -48954,7 +52051,8 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -48963,7 +52061,7 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -48991,19 +52089,22 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -49025,12 +52126,13 @@ var ts; } if (kind === 2 /* ModuleExports */) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -49074,7 +52176,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49163,32 +52265,35 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 73 /* Identifier */: - case 142 /* UndefinedKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 75 /* Identifier */: + case 145 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 199 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 274 /* 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 === 276 /* 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 === 279 /* 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 === 268 /* 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 === 271 /* 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, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, /*noReductions*/ true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -49255,7 +52360,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49264,58 +52369,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 190 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 201 /* ArrowFunction */: + case 234 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: - if (parent.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (parent.expression.kind === 95 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: + case 196 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 191 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 220 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 210 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 199 /* 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, contextFlags); } - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49470,7 +52575,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 200 /* FunctionExpression */ || node.kind === 201 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49484,14 +52589,12 @@ 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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1 /* Signature */) : - getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* Signature */); if (!type) { return undefined; } @@ -49500,8 +52603,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -49531,8 +52634,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 190 /* BindingElement */ && !!node.initializer) || + (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -49544,7 +52647,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 212 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -49569,12 +52672,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 212 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212 /* 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] = []". @@ -49616,9 +52719,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return isNumericComputedName(name); - case 73 /* Identifier */: + case 75 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -49706,7 +52809,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 188 /* ObjectBindingPattern */ || contextualType.pattern.kind === 192 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -49721,13 +52824,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 === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 279 /* PropertyAssignment */ || + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -49750,8 +52853,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 === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -49776,7 +52879,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 281 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -49802,7 +52905,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 162 /* GetAccessor */ || memberDecl.kind === 163 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -49862,7 +52965,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -49910,7 +53019,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 === 73 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -49955,7 +53064,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 273 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -49978,7 +53087,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 /* 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); @@ -50052,7 +53161,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -50126,7 +53235,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -50150,7 +53259,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -50302,13 +53411,13 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted reactSym.isReferenced = 67108863 /* All */; - // If react symbol is alias, mark it as referenced - if (reactSym.flags & 2097152 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 2097152 /* Alias */) { markAliasSymbolAsReferenced(reactSym); } } @@ -50397,7 +53506,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 152 /* QualifiedName */ ? node.right : node.kind === 187 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* 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)); @@ -50495,12 +53604,11 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); + } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (strictNullChecks && type.flags & 2 /* Unknown */) { @@ -50532,14 +53640,13 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + var _a = checkOptionalExpression(node, left), isOptional = _a.isOptional, leftType = _a.type; var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -50553,6 +53660,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0 /* String */) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -50580,9 +53688,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 103 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -50591,14 +53699,14 @@ var ts; } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return propagateOptionalTypeMarker(getFlowTypeOfAccessExpression(node, prop, propType, right), isOptional); } function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { // 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. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 194 /* ElementAccessExpression */ && node.kind !== 193 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -50608,11 +53716,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 && node.expression.kind === 101 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -50633,7 +53741,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -50643,9 +53751,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && - !(valueDeclaration.flags & 4194304 /* Ambient */) && + else if (valueDeclaration.kind === 244 /* ClassDeclaration */ && + node.parent.kind !== 168 /* TypeReference */ && + !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -50656,22 +53764,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 279 /* PropertyAssignment */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 281 /* SpreadAssignment */: + case 153 /* ComputedPropertyName */: + case 220 /* TemplateSpan */: + case 274 /* JsxExpression */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 266 /* JsxOpeningElement */: + case 215 /* ExpressionWithTypeArguments */: + case 277 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -50711,7 +53819,7 @@ var ts; 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)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -50749,7 +53857,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415 /* Value */); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -50844,16 +53952,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 101 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 152 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 187 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 /* PropertyAccessExpression */ && node.expression.kind === 101 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -50870,13 +53978,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 242 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73 /* Identifier */) { + else if (initializer.kind === 75 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -50893,13 +54001,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73 /* Identifier */) { + if (e.kind === 75 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 230 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -50913,28 +54021,14 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + var _a = checkOptionalExpression(node, node.expression), isOptional = _a.isOptional, exprType = _a.type; var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* 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); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -50943,7 +54037,7 @@ var ts; 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); + return propagateOptionalTypeMarker(checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node), isOptional); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === errorType) { @@ -50989,13 +54083,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 156 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51014,7 +54108,7 @@ var ts; // interface B extends A { (x: 'foo'): string } // const b: B; // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -51022,8 +54116,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -51055,11 +54149,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? createOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 212 /* SpreadElement */ || arg.kind === 219 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51073,9 +54167,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 210 /* 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. @@ -51090,7 +54184,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 156 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51105,7 +54199,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 196 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51198,7 +54292,7 @@ var ts; // 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 !== 153 /* Decorator */) { + if (node.kind !== 156 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51228,7 +54322,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -51241,7 +54335,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51265,7 +54359,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 219 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51340,12 +54434,12 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 196 /* 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. @@ -51355,7 +54449,7 @@ var ts; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -51363,7 +54457,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -51373,7 +54467,7 @@ var ts; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -51383,7 +54477,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -51404,15 +54498,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 193 /* PropertyAccessExpression */ || callee.kind === 194 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(219 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51422,17 +54516,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 156 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51447,7 +54541,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, /*isSpread*/ i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -51462,30 +54556,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* 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 152 /* Parameter */: + case 155 /* 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 === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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 !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 158 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51499,17 +54593,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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 152 /* Parameter */: + case 155 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -51547,8 +54641,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -51617,8 +54711,8 @@ var ts; // Overloads exist var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -51633,22 +54727,22 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 156 /* 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 !== 99 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -51697,7 +54791,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 195 /* 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 @@ -51750,7 +54844,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -51768,7 +54862,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -51902,7 +54996,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { + var _loop_15 = function (i) { var symbols = ts.mapDefined(candidates, function (_a) { var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; return hasRestParameter ? @@ -51913,7 +55007,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); var hasRestParameter = restParameterSymbols.length !== 0; @@ -51991,7 +55085,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -52006,12 +55100,12 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var _b = checkOptionalExpression(node, node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined), isOptional = _b.isOptional, funcType = _b.type; if (funcType === silentNeverType) { return silentNeverSignature; } @@ -52077,7 +55171,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -52140,7 +55234,7 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time @@ -52148,7 +55242,7 @@ var ts; // operation is Any. It is an error to have a Void this type. var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -52233,8 +55327,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var constituent = types_16[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52325,23 +55419,23 @@ var ts; invocationError(node.tag, apparentType, 0 /* Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52378,16 +55472,16 @@ var ts; invocationErrorRecovery(apparentType, 0 /* Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, 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(121 /* AnyKeyword */)); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* 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(124 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -52418,7 +55512,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -52434,16 +55528,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 156 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52494,57 +55588,52 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); - } - return false; - } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 193 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -52559,15 +55648,15 @@ var ts; // returns a function type. We defer checking and return nonInferrableType. return nonInferrableType; } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 196 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 161 /* Constructor */ && + declaration.kind !== 165 /* ConstructSignature */ && + declaration.kind !== 170 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -52587,18 +55676,28 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 /* CallExpression */ && node.parent.kind === 225 /* ExpressionStatement */ && + returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -52615,7 +55714,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -52636,7 +55735,7 @@ var ts; // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -52675,7 +55774,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -52684,19 +55783,20 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 243 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 241 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 4194304 /* Ambient */); + return !!decl && !!(decl.flags & 8388608 /* Ambient */); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 131072 /* MakeTemplateObject */); } @@ -52711,20 +55811,20 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || + op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -52760,10 +55860,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96 /* NewKeyword */) { + if (node.keywordToken === 98 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93 /* ImportKeyword */) { + if (node.keywordToken === 95 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -52774,7 +55874,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 === 158 /* Constructor */) { + else if (container.kind === 161 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -52784,11 +55884,11 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 /* ESNext */ || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -52830,7 +55930,7 @@ var ts; // otherwise would return the type 'undefined'). var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -52862,7 +55962,7 @@ var ts; if (signature.hasRestParameter) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; @@ -52960,7 +56060,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 === 73 /* Identifier */) { + if (element.name.kind === 75 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -52974,8 +56074,8 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73 /* Identifier */) { - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + if (decl.name.kind !== 75 /* Identifier */) { + // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -53029,7 +56129,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 222 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -53101,7 +56201,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -53212,17 +56312,18 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200 /* TypeOfExpression */) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203 /* 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 & 131072 /* Never */); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -53235,13 +56336,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128 /* HasImplicitReturn */)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */ function checkAndAggregateReturnExpressionTypes(func, checkMode) { @@ -53281,11 +56376,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 160 /* MethodDeclaration */: + return func.parent.kind === 192 /* ObjectLiteralExpression */; default: return false; } @@ -53311,10 +56406,10 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 159 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 222 /* Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; if (type && type.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -53344,7 +56439,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -53364,7 +56459,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 200 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53418,7 +56513,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53431,7 +56526,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 222 /* Block */) { checkSourceElement(node.body); } else { @@ -53512,11 +56607,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && - expr.expression.kind === 101 /* ThisKeyword */) { + (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) && + expr.expression.kind === 103 /* 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 === 158 /* Constructor */)) { + if (!(func && func.kind === 161 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -53529,31 +56624,35 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 255 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 75 /* Identifier */ && node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32 /* OptionalChain */) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 193 /* PropertyAccessExpression */ && expr.kind !== 194 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -53575,14 +56674,14 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 16384 /* AwaitContext */)) { + if (!(node.flags & 32768 /* AwaitContext */)) { // use of 'await' in non-async function var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -53595,7 +56694,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) { + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -53605,14 +56708,14 @@ var ts; switch (node.operand.kind) { case 8 /* NumericLiteral */: switch (node.operator) { - case 39 /* MinusToken */: + case 40 /* MinusToken */: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38 /* PlusToken */: + case 39 /* PlusToken */: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9 /* BigIntLiteral */: - if (node.operator === 39 /* MinusToken */) { + if (node.operator === 40 /* MinusToken */) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -53620,32 +56723,32 @@ var ts; } } switch (node.operator) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38 /* PlusToken */) { + if (node.operator === 39 /* 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)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 45 /* PlusPlusToken */: + case 46 /* 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -53659,7 +56762,7 @@ var ts; 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -53680,8 +56783,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -53770,7 +56873,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */ || property.kind === 280 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -53783,9 +56886,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 281 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -53828,8 +56931,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 214 /* OmittedExpression */) { + if (element.kind !== 212 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -53847,7 +56950,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 208 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -53863,7 +56966,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 280 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -53879,24 +56982,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 208 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 192 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 191 /* 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 === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 281 /* 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)) { + var optionalError = target.parent.kind === 281 /* SpreadAssignment */ ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -53912,53 +57018,53 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 145 /* UndefinedKeyword */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 203 /* TypeOfExpression */: + case 217 /* NonNullExpression */: + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 52 /* ExclamationToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 53 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 204 /* VoidExpression */: // Explicit opt-out + case 198 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 216 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -53970,15 +57076,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60 /* QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); + if (operator === 62 /* EqualsToken */ && (left.kind === 192 /* ObjectLiteralExpression */ || left.kind === 191 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103 /* ThisKeyword */); } var leftType; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -53986,28 +57104,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40 /* AsteriskToken */: - case 41 /* AsteriskAsteriskToken */: - case 63 /* AsteriskEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 43 /* PercentToken */: - case 66 /* PercentEqualsToken */: - case 39 /* MinusToken */: - case 62 /* MinusEqualsToken */: - case 46 /* LessThanLessThanToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: + case 41 /* AsteriskToken */: + case 42 /* AsteriskAsteriskToken */: + case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 44 /* PercentToken */: + case 68 /* PercentEqualsToken */: + case 40 /* MinusToken */: + case 64 /* MinusEqualsToken */: + case 47 /* LessThanLessThanToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54034,17 +57152,17 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); } resultType_1 = bigintType; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54052,8 +57170,8 @@ var ts; } return resultType_1; } - case 38 /* PlusToken */: - case 61 /* PlusEqualsToken */: + case 39 /* PlusToken */: + case 63 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54086,24 +57204,24 @@ var ts; } if (!resultType) { // Types that have a reasonably good chance of being a valid operand type. - // If both types have an awaited type of one of these, we’ll assume the user + // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61 /* PlusEqualsToken */) { + if (operator === 63 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -54112,25 +57230,29 @@ var ts; }); } return booleanType; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 60 /* EqualsToken */: + case 60 /* QuestionQuestionToken */: + return getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + leftType; + case 62 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -54157,6 +57279,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54164,7 +57289,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -54174,7 +57299,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 75 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -54189,15 +57314,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - return 55 /* BarBarToken */; - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - return 36 /* ExclamationEqualsEqualsToken */; - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: - return 54 /* AmpersandAmpersandToken */; + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + return 56 /* BarBarToken */; + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + return 37 /* ExclamationEqualsEqualsToken */; + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: + return 55 /* AmpersandAmpersandToken */; default: return undefined; } @@ -54210,7 +57335,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non-compound operation to be assignable to the type of VarExpr. - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); @@ -54244,17 +57369,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); + } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54262,12 +57393,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: typeName = "false"; break; - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -54276,6 +57407,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54294,7 +57436,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -54343,12 +57485,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2 /* Next */, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -54370,7 +57507,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 /* 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; @@ -54409,12 +57546,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 198 /* TypeAssertionExpression */ || node.kind === 216 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54436,10 +57573,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54491,7 +57628,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54502,7 +57639,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54514,8 +57651,8 @@ var ts; var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8 /* SkipGenericFunctions */) { @@ -54645,11 +57782,11 @@ 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 === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + var _a = checkOptionalExpression(expr, expr.expression), isOptional = _a.isOptional, funcType = _a.type; var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -54695,17 +57832,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 261 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 8388608 /* Ambient */)); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304 /* Ambient */) { + if (constEnumDeclaration.flags & 8388608 /* Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -54718,14 +57856,25 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { - case 73 /* Identifier */: + var kind = node.kind; + if (cancellationToken) { + // 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 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 75 /* Identifier */: return checkIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return checkThisExpression(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkSuperExpression(node); - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -54736,82 +57885,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: return trueType; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: - if (node.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (node.expression.kind === 95 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 196 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 219 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -54848,7 +57997,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -54859,10 +58008,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 === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 161 /* Constructor */ || func.kind === 165 /* ConstructSignature */ || func.kind === 170 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -54886,7 +58035,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -54895,9 +58044,11 @@ var ts; error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, - /*headMessage*/ undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, + /*headMessage*/ undefined, leadingError); + } } } else if (parameterName) { @@ -54918,13 +58069,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 201 /* ArrowFunction */: + case 164 /* CallSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 169 /* FunctionType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -54938,11 +58089,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 75 /* 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 === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 189 /* ArrayBindingPattern */ || name.kind === 188 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -54951,13 +58102,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* 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 === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 169 /* FunctionType */ || node.kind === 243 /* FunctionDeclaration */ || node.kind === 170 /* ConstructorType */ || + node.kind === 164 /* CallSignature */ || node.kind === 161 /* Constructor */ || + node.kind === 165 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -54987,10 +58138,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55020,28 +58171,21 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 166 /* IndexSignature */ && node.kind !== 298 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } } function checkClassForDuplicateDeclarations(node) { - var Declaration; - (function (Declaration) { - Declaration[Declaration["Getter"] = 1] = "Getter"; - Declaration[Declaration["Setter"] = 2] = "Setter"; - Declaration[Declaration["Method"] = 4] = "Method"; - Declaration[Declaration["Property"] = 3] = "Property"; - })(Declaration || (Declaration = {})); var instanceNames = ts.createUnderscoreEscapedMap(); var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 161 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* Property */); + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { + addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } } @@ -55052,17 +58196,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: - addName(names, name, memberName, 1 /* Getter */); + case 162 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: - addName(names, name, memberName, 2 /* Setter */); + case 163 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* Property */); + case 158 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: - addName(names, name, memberName, 4 /* Method */); + case 160 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */); break; } } @@ -55071,8 +58215,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4 /* Method */) { - if (meaning !== 4 /* Method */) { + if (prev & 8 /* Method */) { + if (meaning !== 8 /* Method */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -55124,7 +58268,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 157 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55132,7 +58276,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 73 /* Identifier */: + case 75 /* Identifier */: memberName = ts.idText(name); break; default: @@ -55149,7 +58293,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* 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 @@ -55169,7 +58313,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -55177,7 +58321,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -55204,7 +58348,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 === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 160 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55229,7 +58373,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55257,9 +58401,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55284,9 +58428,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { - if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { - if (!(node.flags & 256 /* HasExplicitReturn */)) { + if (node.kind === 162 /* GetAccessor */) { + if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { + if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -55294,13 +58438,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* 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 === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55318,7 +58462,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55366,19 +58510,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { @@ -55414,16 +58555,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 176 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 175 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55444,7 +58585,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 /* 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)); } @@ -55495,7 +58636,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 /* 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); @@ -55506,16 +58647,16 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 4194304 /* Ambient */); + return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && - n.flags & 4194304 /* Ambient */) { + if (n.parent.kind !== 245 /* InterfaceDeclaration */ && + n.parent.kind !== 244 /* ClassDeclaration */ && + n.parent.kind !== 213 /* ClassExpression */ && + n.flags & 8388608 /* 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 flags |= 1 /* Export */; @@ -55605,7 +58746,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 === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* 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 @@ -55640,11 +58781,12 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent.kind === 245 /* InterfaceDeclaration */ || node.parent.kind === 172 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -55655,7 +58797,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if ((node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 243 /* FunctionDeclaration */ || node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */ || node.kind === 161 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -55696,6 +58841,15 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { + // A non-ambient class cannot be an implementation for a non-constructor function/class merge + // TODO: The below just replicates our older error from when classes and functions were + // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" + // might be warranted. :shrug: + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { @@ -55707,8 +58861,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -55717,13 +58871,6 @@ var ts; } } } - var DeclarationSpaces; - (function (DeclarationSpaces) { - DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; - DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; - DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; - DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; - })(DeclarationSpaces || (DeclarationSpaces = {})); function checkExportsOnMergedDeclarations(node) { if (!produceDiagnostics) { return; @@ -55784,40 +58931,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 258 /* 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 */; } 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 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 243 /* FunctionDeclaration */: + case 257 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -55851,7 +59000,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { @@ -55886,9 +59035,6 @@ var ts; */ function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3 /* AnyOrUnknown */)) { - addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -56047,10 +59193,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 75 /* 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 { @@ -56070,7 +59216,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -56089,24 +59235,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 155 /* 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 155 /* PropertyDeclaration */: + case 158 /* 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 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56127,7 +59273,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 75 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56152,29 +59298,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var typeNode = types_18[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* 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); @@ -56220,14 +59366,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* 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 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56236,23 +59382,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 160 /* 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 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 155 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56315,7 +59461,7 @@ var ts; 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 === 149 /* 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 === 152 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56348,9 +59494,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56363,7 +59509,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 === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56379,7 +59525,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -56392,7 +59538,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 159 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56418,7 +59564,7 @@ var ts; } function registerForUnusedIdentifiersCheck(node) { // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`. - if (produceDiagnostics && !(node.flags & 4194304 /* Ambient */)) { + if (produceDiagnostics && !(node.flags & 8388608 /* Ambient */)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -56434,42 +59580,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 288 /* SourceFile */: + case 248 /* ModuleDeclaration */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 180 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56489,11 +59635,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 160 /* MethodDeclaration */: + case 158 /* PropertyDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + if (member.kind === 163 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56502,7 +59648,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 158 /* Constructor */: + case 161 /* 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 */)) { @@ -56510,8 +59656,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 166 /* IndexSignature */: + case 221 /* SemicolonClassElement */: // Can't be private break; default: @@ -56538,7 +59684,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -56573,7 +59719,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304 /* Ambient */) + if (nodeWithLocals.flags & 8388608 /* Ambient */) return; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); @@ -56608,7 +59754,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -56623,7 +59769,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -56641,7 +59787,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 === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 242 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -56662,7 +59808,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -56674,24 +59820,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 254 /* ImportClause */ || node.kind === 257 /* ImportSpecifier */ || node.kind === 255 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 254 /* ImportClause */ ? decl : decl.kind === 255 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 222 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -56708,7 +59854,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -56721,21 +59867,21 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 158 /* PropertyDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 160 /* MethodDeclaration */ || + node.kind === 159 /* MethodSignature */ || + node.kind === 162 /* GetAccessor */ || + node.kind === 163 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // ambient context - no codegen impact return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -56745,7 +59891,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 73 /* Identifier */; + var isDeclaration_1 = node.kind !== 75 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -56760,7 +59906,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 73 /* Identifier */; + var isDeclaration_2 = node.kind !== 75 /* 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); } @@ -56786,7 +59932,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 /* 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)); } @@ -56801,7 +59947,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* 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)); } @@ -56836,7 +59982,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 === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 241 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -56848,17 +59994,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 224 /* 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 === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 222 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 249 /* ModuleBlock */ || + container.kind === 248 /* ModuleDeclaration */ || + container.kind === 288 /* 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 @@ -56888,18 +60034,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 190 /* BindingElement */) { + if (node.parent.kind === 188 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -56913,26 +60059,26 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 /* 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 === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 /* 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)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -56969,7 +60115,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -56995,10 +60141,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -57007,7 +60153,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 158 /* PropertyDeclaration */ || nextDeclaration.kind === 157 /* PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -57017,8 +60163,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 155 /* Parameter */ && right.kind === 241 /* VariableDeclaration */) || + (left.kind === 241 /* VariableDeclaration */ && right.kind === 155 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57055,13 +60201,56 @@ var ts; function checkIfStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 223 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + // While it technically should be invalid for any known-truthy value + // to be tested, we de-scope to functions unrefenced in the block as a + // heuristic to identify the most common bugs. There are too many + // false positives for values sourced from type definitions without + // strictNullChecks otherwise. + var callSignatures = getSignaturesOfType(type, 0 /* Call */); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -57084,12 +60273,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 242 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57123,14 +60312,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* 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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* 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. @@ -57138,7 +60327,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -57162,7 +60351,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* 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); @@ -57176,7 +60365,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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* 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)) { @@ -57184,7 +60373,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved @@ -57537,7 +60726,7 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use @@ -57549,7 +60738,7 @@ var ts; // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -57628,7 +60817,7 @@ var ts; // - `Generator` or `AsyncGenerator` var globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `IterableIterator` and `AsyncIterableIterator` are defined by the // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. @@ -57639,7 +60828,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(/*reportErrors*/ false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -57675,11 +60864,11 @@ var ts; // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` // or `IteratorReturnResult` types, then just grab its type argument. if (isReferenceToType(type, getGlobalIteratorYieldResultType(/*reportErrors*/ false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, /*returnType*/ undefined, /*nextType*/ undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(/*reportErrors*/ false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(/*yieldType*/ undefined, returnType_1, /*nextType*/ undefined); } // Choose any constituents that can produce the requested iteration type. @@ -57743,11 +60932,13 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + // The value of `next(value)` is *not* awaited by async generators + nextType = methodParameterType; } else if (methodName === "return") { + // The value of `return(value)` *is* awaited by async generators + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -57840,12 +61031,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160 /* SetAccessor */) { + if (func.kind === 163 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 161 /* 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); } @@ -57863,7 +61054,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -57871,7 +61062,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384 /* AwaitContext */) { + if (node.flags & 32768 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -57892,7 +61083,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 === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 276 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -57904,7 +61095,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 275 /* 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. @@ -57933,7 +61124,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58040,8 +61231,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 === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 208 /* BinaryExpression */ || + name.kind === 153 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58118,7 +61309,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 168 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58178,11 +61369,10 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - // relax check if later interface augmentation has no constraint - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + // relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with + // a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill) + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } // If the type parameter node has a default and it is not identical to the default // for the type parameter at this position, we report an error. @@ -58219,7 +61409,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassNameCollisionWithObject(node.name); } } @@ -58232,11 +61422,12 @@ var ts; checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } @@ -58274,12 +61465,9 @@ var ts; } 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 - // that the base type is a class or interface type (and not, for example, an anonymous object type). - // (Javascript constructor functions have this property trivially true since their return type is ignored.) + // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -58322,7 +61510,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -58341,7 +61529,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -58367,7 +61555,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 244 /* ClassDeclaration */ || d.kind === 245 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58386,7 +61574,7 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304 /* Prototype */) { @@ -58395,53 +61583,104 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overridden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 210 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + // In order to resolve whether the inherited method was overridden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { + // Searches other base types for a declaration that would satisfy the inherited abstract member. + // (The class may have more than one base type via declaration merging with an interface with the + // same name.) + for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { + var otherBaseType = _b[_a]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } + if (derivedClassDecl.kind === 213 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } - else { - // derived overrides base. - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { - // either base or derived property is private - not override, skip it + } + else { + // derived overrides base. + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + // either base or derived property is private - not override, skip it + continue; + } + var errorMessage = void 0; + var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + if (basePropertyFlags && derivedPropertyFlags) { + // property/accessor is overridden with property/accessor + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 /* InterfaceDeclaration */ + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { + // when the base property is abstract or from an interface, base/derived flags don't need to match + // same when the derived property is from an assignment continue; } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; + if (basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + else if (basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 /* PropertyDeclaration */ && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432 /* Transient */) + && !(baseDeclarationFlags & 128 /* Abstract */) + && !(derivedDeclarationFlags & 128 /* Abstract */) + && !derived.declarations.some(function (d) { return d.flags & 8388608 /* Ambient */; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } } + // correct case + continue; + } + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived)) { + // method is overridden with method -- correct case + continue; } - else if (base.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + else if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -58478,12 +61717,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2 /* Ambient */) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -58498,7 +61740,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -58522,7 +61764,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -58585,7 +61827,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -58617,7 +61859,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304 /* Ambient */) { + else if (member.parent.flags & 8388608 /* Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -58627,66 +61869,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38 /* PlusToken */: return value_2; - case 39 /* MinusToken */: return -value_2; - case 53 /* TildeToken */: return ~value_2; + case 39 /* PlusToken */: return value_2; + case 40 /* MinusToken */: return -value_2; + case 54 /* TildeToken */: return ~value_2; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - 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 === 38 /* PlusToken */) { + case 51 /* BarToken */: return left | right; + case 50 /* AmpersandToken */: return left & right; + case 48 /* GreaterThanGreaterThanToken */: return left >> right; + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* LessThanLessThanToken */: return left << right; + case 52 /* CaretToken */: return left ^ right; + case 41 /* AsteriskToken */: return left * right; + case 43 /* SlashToken */: return left / right; + case 39 /* PlusToken */: return left + right; + case 40 /* MinusToken */: return left - right; + case 44 /* PercentToken */: return left % right; + case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { return left + right; } break; case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 73 /* Identifier */: + case 75 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* 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 === 190 /* PropertyAccessExpression */) { + if (ex.kind === 193 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -58711,10 +61952,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10 /* StringLiteral */; + return node.kind === 75 /* Identifier */ || + node.kind === 193 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 194 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -58748,7 +61989,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 !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 247 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -58771,9 +62012,9 @@ 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 === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304 /* Ambient */)) { + if ((declaration.kind === 244 /* ClassDeclaration */ || + (declaration.kind === 243 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } } @@ -58796,7 +62037,7 @@ var ts; if (produceDiagnostics) { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304 /* Ambient */; + var inAmbientContext = node.flags & 8388608 /* Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -58835,7 +62076,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, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 244 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -58885,23 +62126,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* 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 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 241 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -58912,12 +62153,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -58938,17 +62179,36 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); + return node; + } + } + function getFirstNonModuleExportsIdentifier(node) { + switch (node.kind) { + case 75 /* Identifier */: + return node; + case 152 /* QualifiedName */: + do { + node = node.left; + } while (node.kind !== 75 /* Identifier */); + return node; + case 193 /* PropertyAccessExpression */: + do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } + node = node.expression; + } while (node.kind !== 75 /* Identifier */); return node; } } @@ -58962,9 +62222,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -58986,27 +62246,29 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - // For external modules symbol represent local symbol for an alias. + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864 /* Assignment */; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + // For external modules symbol represents local symbol for an alias. // This local symbol will merge any other local declarations (excluding other aliases) // and symbol.flags will contains combined representation for all merged declaration. // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). - var excludedMeanings = (symbol.flags & (67220415 /* Value */ | 1048576 /* ExportValue */) ? 67220415 /* Value */ : 0) | - (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | + symbol = getMergedSymbol(symbol.exportSymbol || symbol); + var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | + (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 261 /* 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 === 258 /* ExportSpecifier */ - && !(target.flags & 67220415 /* Value */) - && !(node.flags & 4194304 /* Ambient */)) { + && node.kind === 261 /* ExportSpecifier */ + && !(target.flags & 111551 /* Value */) + && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -59031,7 +62293,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59055,23 +62317,23 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 263 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415 /* Value */) { + if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832 /* Type */) { + if (target.flags & 788968 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608 /* Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -59091,10 +62353,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 /* ModuleBlock */ && + !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59111,7 +62373,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 288 /* SourceFile */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 248 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59125,13 +62387,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -59140,8 +62406,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 === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59154,8 +62420,18 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73 /* Identifier */) { - markExportAsReferenced(node); + if (node.expression.kind === 75 /* Identifier */) { + var id = node.expression; + var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + if (sym) { + markAliasReferenced(sym, id); + // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) + var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // However if it is a value, we need to check it's being used correctly + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); } @@ -59164,10 +62440,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -59193,9 +62469,9 @@ var ts; } } // Checks for export * conflicts - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -59224,14 +62500,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -59253,158 +62521,162 @@ 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 /* FirstStatement */ && kind <= 240 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 181 /* ParenthesizedType */: + case 175 /* OptionalType */: + case 176 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 182 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return checkImportType(node); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 306 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 298 /* JSDocTypeLiteral */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: + case 302 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 292 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 223 /* EmptyStatement */: + case 240 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -59499,23 +62771,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 264 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -59544,7 +62816,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } // Grammar checking @@ -59630,7 +62902,7 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608 /* InWithStatement */) { + if (location.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } @@ -59645,35 +62917,35 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // 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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -59715,17 +62987,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 /* Identifier */ && + return name.kind === 75 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 154 /* TypeParameter */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -59733,16 +63005,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 168 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 193 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 215 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -59770,13 +63042,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 152 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 252 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 258 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -59802,7 +63074,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 187 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -59812,7 +63084,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 193 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -59820,17 +63092,17 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 258 /* 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); + /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } 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, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 252 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -59848,11 +63120,11 @@ 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 === 212 /* ExpressionWithTypeArguments */) { - meaning = 67897832 /* Type */; + if (entityName.parent.kind === 215 /* ExpressionWithTypeArguments */) { + meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415 /* Value */; + meaning |= 111551 /* Value */; } } else { @@ -59864,10 +63136,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306 /* JSDocParameterTag */) { + if (entityName.parent.kind === 310 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 310 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 154 /* TypeParameter */ && entityName.parent.parent.kind === 314 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -59877,19 +63149,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 73 /* Identifier */) { + if (entityName.kind === 75 /* 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); + return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 193 /* PropertyAccessExpression */ || entityName.kind === 152 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 193 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -59899,22 +63171,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 168 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 167 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -59928,12 +63200,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 190 /* BindingElement */ && + grandParent.kind === 188 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -59943,11 +63215,11 @@ var ts; } } switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -59959,14 +63231,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 182 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkExpression(node).symbol; - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 161 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -59977,7 +63249,7 @@ var ts; // 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 === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 /* ImportDeclaration */ || node.parent.kind === 259 /* 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); @@ -59994,22 +63266,22 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81 /* DefaultKeyword */: - case 91 /* FunctionKeyword */: - case 37 /* EqualsGreaterThanToken */: - case 77 /* ClassKeyword */: + case 83 /* DefaultKeyword */: + case 93 /* FunctionKeyword */: + case 38 /* EqualsGreaterThanToken */: + case 79 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 280 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; } @@ -60017,10 +63289,10 @@ var ts; function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -60076,27 +63348,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 192 /* ObjectLiteralExpression */ || expr.kind === 191 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 231 /* 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 === 205 /* BinaryExpression */) { + if (expr.parent.kind === 208 /* 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 === 276 /* PropertyAssignment */) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60135,17 +63407,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } // Return the list of properties of the given type, augmented with properties from Function @@ -60197,7 +63468,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60218,13 +63489,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415 /* Value */); + return s && !!(s.flags & 111551 /* Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -60253,7 +63524,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 288 /* 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. @@ -60273,7 +63544,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -60281,7 +63552,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60290,7 +63561,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -60312,7 +63583,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 === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 222 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60353,26 +63624,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258 /* ExportAssignment */: + return node.expression && node.expression.kind === 75 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60386,7 +63656,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 67220415 /* Value */) && + return !!(target.flags & 111551 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -60400,7 +63670,7 @@ var ts; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && - target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -60454,7 +63724,7 @@ var ts; if (!symbol || !(symbol.flags & 16 /* Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 /* Value */ && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -60473,15 +63743,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 282 /* EnumMember */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 282 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -60508,9 +63778,9 @@ var ts; return ts.TypeReferenceSerializationKind.Unknown; } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 67220415 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 67897832 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -60566,7 +63836,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -60585,7 +63855,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -60593,7 +63863,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -60615,7 +63885,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -60636,7 +63906,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -60717,12 +63987,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 === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 163 /* SetAccessor */ ? 162 /* GetAccessor */ : 163 /* 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 === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -60735,10 +64005,19 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 215 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 277 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -60749,9 +64028,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* Type */ | 1920 /* Namespace */; + if ((node.kind === 75 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 193 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -60801,7 +64080,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -60829,12 +64108,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 /* 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, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 288 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -60967,16 +64246,16 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1 /* FirstEmitHelper */; helper <= 131072 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -61023,14 +64302,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 /* 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 === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* 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); @@ -61047,23 +64326,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 !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (modifier.kind !== 137 /* ReadonlyKeyword */) { + if (node.kind === 157 /* PropertySignature */ || node.kind === 159 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); + case 80 /* ConstKeyword */: + if (node.kind !== 247 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80 /* ConstKeyword */)); } break; - case 116 /* PublicKeyword */: - case 115 /* ProtectedKeyword */: - case 114 /* PrivateKeyword */: + case 118 /* PublicKeyword */: + case 117 /* ProtectedKeyword */: + case 116 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -61077,11 +64356,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* 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 === 114 /* PrivateKeyword */) { + if (modifier.kind === 116 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -61090,7 +64369,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -61100,10 +64379,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61112,18 +64391,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */ && node.kind !== 166 /* IndexSignature */ && node.kind !== 155 /* 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 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -61136,52 +64415,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 === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 83 /* DefaultKeyword */: + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* 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 126 /* DeclareKeyword */: + case 129 /* 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 === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 249 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 119 /* AbstractKeyword */: + case 121 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 244 /* ClassDeclaration */) { + if (node.kind !== 160 /* MethodDeclaration */ && + node.kind !== 158 /* PropertyDeclaration */ && + node.kind !== 162 /* GetAccessor */ && + node.kind !== 163 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 244 /* 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 */) { @@ -61193,14 +64472,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 122 /* AsyncKeyword */: + case 125 /* 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 */) { + else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61208,7 +64487,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61223,13 +64502,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 253 /* ImportDeclaration */ || node.kind === 252 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 /* 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 === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 155 /* 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 */) { @@ -61250,38 +64529,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 248 /* ModuleDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 155 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 125 /* AsyncKeyword */); + case 244 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AbstractKeyword */); + case 245 /* InterfaceDeclaration */: + case 224 /* VariableStatement */: + case 246 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); + case 247 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 80 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -61293,10 +64572,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61325,7 +64604,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -61359,7 +64638,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -61411,7 +64690,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 /* StringKeyword */ && parameter.type.kind !== 136 /* NumberKeyword */) { + if (parameter.type.kind !== 142 /* StringKeyword */ && parameter.type.kind !== 139 /* 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(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -61443,11 +64722,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211 /* OmittedExpression */) { + if (arg.kind === 214 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61477,7 +64762,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 === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -61490,7 +64775,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -61506,14 +64791,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -61524,21 +64809,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 153 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 208 /* 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 === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); - if (node.flags & 4194304 /* Ambient */) { + ts.Debug.assert(node.kind === 243 /* FunctionDeclaration */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 160 /* MethodDeclaration */); + if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -61553,17 +64838,10 @@ var ts; return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var Flags; - (function (Flags) { - Flags[Flags["Property"] = 1] = "Property"; - Flags[Flags["GetAccessor"] = 2] = "GetAccessor"; - Flags[Flags["SetAccessor"] = 4] = "SetAccessor"; - Flags[Flags["GetOrSetAccessor"] = 6] = "GetOrSetAccessor"; - })(Flags || (Flags = {})); var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 281 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -61574,20 +64852,21 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 /* 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); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 125 /* AsyncKeyword */ || prop.kind !== 160 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -61602,24 +64881,25 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 279 /* 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 157 /* MethodDeclaration */: - currentKind = 1 /* Property */; + currentKind = 4 /* PropertyAssignment */; + break; + case 160 /* MethodDeclaration */: + currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: - currentKind = 2 /* GetAccessor */; + case 162 /* GetAccessor */: + currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: - currentKind = 4 /* SetAccessor */; + case 163 /* SetAccessor */: + currentKind = 2 /* SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -61633,11 +64913,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + if ((currentKind & 12 /* PropertyAssignmentOrMethod */) && (existingKind & 12 /* PropertyAssignmentOrMethod */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6 /* GetOrSetAccessor */) && (existingKind & 6 /* GetOrSetAccessor */)) { - if (existingKind !== 6 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { + if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -61655,7 +64935,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 === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 273 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -61665,7 +64945,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 274 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -61679,14 +64959,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + if (forInOrOfStatement.kind === 231 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -61697,7 +64977,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 242 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -61712,20 +64992,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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); @@ -61735,42 +65015,38 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304 /* Ambient */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 8388608 /* Ambient */)) { + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { + if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 /* GetAccessor */ ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 162 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160 /* SetAccessor */) { + if (accessor.kind === 163 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; @@ -61780,23 +65056,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 === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143 /* UniqueKeyword */) { - if (node.type.kind !== 140 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140 /* SymbolKeyword */)); + if (node.operator === 146 /* UniqueKeyword */) { + if (node.type.kind !== 143 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* 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)) { @@ -61806,13 +65082,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 158 /* 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 154 /* PropertySignature */: + case 157 /* 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); } @@ -61821,9 +65097,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); + else if (node.operator === 137 /* ReadonlyKeyword */) { + if (node.type.kind !== 173 /* ArrayType */ && node.type.kind !== 174 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143 /* SymbolKeyword */)); } } } @@ -61836,10 +65112,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 160 /* MethodDeclaration */) { + if (node.parent.kind === 192 /* 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 === 122 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -61862,17 +65138,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* 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 === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 160 /* 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 === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* 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 === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* 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); } } @@ -61883,11 +65159,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 237 /* 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 === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 232 /* 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); @@ -61895,8 +65171,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 236 /* SwitchStatement */: + if (node.kind === 233 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -61911,13 +65187,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* 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 === 230 /* BreakStatement */ + var message = node.kind === 233 /* 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); @@ -61940,13 +65216,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -61959,7 +65235,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 /* TrueKeyword */ || initializer.kind === 88 /* FalseKeyword */ || + initializer.kind === 105 /* TrueKeyword */ || initializer.kind === 90 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -61976,8 +65252,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { - if (node.flags & 4194304 /* Ambient */) { + if (node.parent.parent.kind !== 230 /* ForInStatement */ && node.parent.parent.kind !== 231 /* ForOfStatement */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -61989,11 +65265,11 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -62006,7 +65282,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -62023,8 +65299,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73 /* Identifier */) { - if (name.originalKeywordKind === 112 /* LetKeyword */) { + if (name.kind === 75 /* Identifier */) { + if (name.originalKeywordKind === 114 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -62051,15 +65327,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62077,12 +65353,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96 /* NewKeyword */: + case 98 /* 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 93 /* ImportKeyword */: + case 95 /* 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"); } @@ -62140,7 +65416,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* 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; } @@ -62148,7 +65424,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* 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; } @@ -62156,11 +65432,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { + node.flags & 8388608 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } @@ -62177,13 +65453,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 246 /* TypeAliasDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 259 /* ExportDeclaration */ || + node.kind === 258 /* ExportAssignment */ || + node.kind === 251 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62192,7 +65468,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 === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 224 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62201,17 +65477,13 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304 /* Ambient */) { - // An accessors is already reported about the ambient context - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } + if (node.flags & 8388608 /* Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } // We are either parented by another statement, or some sort of block. @@ -62219,7 +65491,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 === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 222 /* Block */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62241,20 +65513,39 @@ 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, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 186 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 282 /* 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 === 39 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62309,11 +65600,19 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 243 /* FunctionDeclaration */ && declaration.kind !== 160 /* MethodDeclaration */) || + !!declaration.body; + } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62321,21 +65620,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 254 /* ImportClause */: // For default import + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: // For rename import `x as y` return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 257 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62345,7 +65643,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62416,6 +65713,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62463,7 +65761,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73 /* Identifier */); + var node = createSynthesizedNode(75 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -62544,23 +65842,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(99 /* SuperKeyword */); + return createSynthesizedNode(101 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101 /* ThisKeyword */); + return createSynthesizedNode(103 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97 /* NullKeyword */); + return createSynthesizedNode(99 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103 /* TrueKeyword */); + return createSynthesizedNode(105 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88 /* FalseKeyword */); + return createSynthesizedNode(90 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -62571,44 +65869,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(86 /* ExportKeyword */)); + result.push(createModifier(88 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(126 /* DeclareKeyword */)); + result.push(createModifier(129 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(81 /* DefaultKeyword */)); + result.push(createModifier(83 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(78 /* ConstKeyword */)); + result.push(createModifier(80 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(116 /* PublicKeyword */)); + result.push(createModifier(118 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(114 /* PrivateKeyword */)); + result.push(createModifier(116 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(115 /* ProtectedKeyword */)); + result.push(createModifier(117 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(119 /* AbstractKeyword */)); + result.push(createModifier(121 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(117 /* StaticKeyword */)); + result.push(createModifier(119 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(134 /* ReadonlyKeyword */)); + result.push(createModifier(137 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(122 /* AsyncKeyword */)); + result.push(createModifier(125 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(152 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -62627,7 +65925,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(153 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -62640,7 +65938,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(154 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -62656,7 +65954,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(155 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -62680,7 +65978,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(156 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -62693,7 +65991,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(157 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -62713,12 +66011,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(158 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -62728,8 +66026,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -62737,7 +66035,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(159 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -62754,7 +66052,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(160 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -62767,6 +66065,38 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), + /*typeArguments*/ undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + /* @internal */ + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + /* @internal */ + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -62782,7 +66112,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(161 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -62802,7 +66132,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(162 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62825,7 +66155,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(163 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62846,7 +66176,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -62854,7 +66184,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -62862,7 +66192,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(166 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -62902,21 +66232,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167 /* TypePredicate */); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(168 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -62930,7 +66270,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(169 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -62938,7 +66278,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(170 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -62946,7 +66286,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(171 /* TypeQuery */); node.exprName = exprName; return node; } @@ -62958,7 +66298,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(172 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -62970,7 +66310,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(173 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -62982,7 +66322,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(174 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -62994,7 +66334,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(175 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -63006,7 +66346,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(176 /* RestType */); node.type = type; return node; } @@ -63018,7 +66358,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(177 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63026,7 +66366,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(178 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63045,7 +66385,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(179 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63063,7 +66403,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(180 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63075,7 +66415,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(187 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63093,7 +66433,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(181 /* ParenthesizedType */); node.type = type; return node; } @@ -63105,12 +66445,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(182 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; + var node = createSynthesizedNode(183 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -63120,7 +66460,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(184 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63134,7 +66474,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(185 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63152,7 +66492,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(186 /* LiteralType */); node.literal = literal; return node; } @@ -63165,7 +66505,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(188 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63177,7 +66517,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(189 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63189,7 +66529,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(190 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63208,7 +66548,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(191 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63222,7 +66562,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(192 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63236,7 +66576,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63244,6 +66584,7 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessChain using updatePropertyAccess. Use updatePropertyAccessChain instead."); // Because we are updating existed propertyAccess we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -63252,22 +66593,62 @@ var ts; : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072 /* NoIndentation */); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(194 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessChain using updateElementAccess. Use updateElementAccessChain instead."); return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194 /* ElementAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(195 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63275,6 +66656,7 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update a CallChain using updateCall. Use updateCallChain instead."); return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -63282,8 +66664,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195 /* CallExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(196 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63299,7 +66701,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(197 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63322,7 +66724,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(198 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63336,7 +66738,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(199 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63348,7 +66750,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(200 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63372,12 +66774,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(201 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -63394,7 +66796,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(202 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63406,7 +66808,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(203 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63418,7 +66820,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(204 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63430,7 +66832,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(205 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63442,7 +66844,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(206 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63455,7 +66857,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(207 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63468,7 +66870,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(208 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63485,11 +66887,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(209 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(58 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -63505,7 +66907,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(210 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -63518,34 +66920,93 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15 /* TemplateHead */); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + } + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15 /* TemplateHead */: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16 /* TemplateMiddle */: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17 /* TemplateTail */: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23 /* CloseBracketToken */) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15 /* TemplateHead */, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16 /* TemplateMiddle */); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16 /* TemplateMiddle */, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17 /* TemplateTail */); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17 /* TemplateTail */, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14 /* NoSubstitutionTemplateLiteral */, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -63557,7 +67018,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(212 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -63569,7 +67030,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(213 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63590,11 +67051,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(214 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(215 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -63608,7 +67069,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(216 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -63622,7 +67083,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(217 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63634,7 +67095,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(218 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -63648,7 +67109,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(220 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -63662,12 +67123,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(221 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(222 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -63681,7 +67142,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(224 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -63696,11 +67157,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(223 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(225 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -63716,7 +67177,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(226 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -63732,7 +67193,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(227 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -63746,7 +67207,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(228 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63760,7 +67221,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(229 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -63778,7 +67239,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(230 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -63794,7 +67255,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(231 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -63812,7 +67273,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(232 /* ContinueStatement */); node.label = asName(label); return node; } @@ -63824,7 +67285,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(233 /* BreakStatement */); node.label = asName(label); return node; } @@ -63836,7 +67297,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(234 /* ReturnStatement */); node.expression = expression; return node; } @@ -63848,7 +67309,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(235 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63862,7 +67323,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(236 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -63876,7 +67337,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(237 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -63890,7 +67351,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(238 /* ThrowStatement */); node.expression = expression; return node; } @@ -63902,7 +67363,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(239 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -63918,11 +67379,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(240 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(241 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -63939,7 +67400,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(242 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -63952,7 +67413,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(243 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63978,7 +67439,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(244 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64000,7 +67461,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(245 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64022,7 +67483,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(246 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64042,7 +67503,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(247 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64061,8 +67522,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); + var node = createSynthesizedNode(248 /* ModuleDeclaration */); + node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -64080,7 +67541,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(249 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64092,7 +67553,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(250 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64104,7 +67565,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(251 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64116,7 +67577,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(252 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64134,7 +67595,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(253 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64152,7 +67613,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(254 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64166,7 +67627,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(255 /* NamespaceImport */); node.name = name; return node; } @@ -64178,7 +67639,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(256 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64190,7 +67651,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(257 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64204,11 +67665,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(258 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -64221,7 +67682,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(259 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64238,8 +67699,13 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + /* @internal */ + function createEmptyExports() { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(260 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64251,7 +67717,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(261 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64266,7 +67732,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(263 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64280,14 +67746,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(292 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(313 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64295,7 +67761,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(311 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64303,14 +67769,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(312 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(310 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64320,7 +67786,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297 /* JSDocComment */); + var node = createSynthesizedNode(301 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64334,7 +67800,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(264 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64350,7 +67816,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(265 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64366,7 +67832,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(266 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64382,7 +67848,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(267 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64394,7 +67860,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(268 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64416,11 +67882,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(269 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(270 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64432,7 +67898,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(271 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -64446,7 +67912,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(272 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -64458,7 +67924,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(273 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -64470,7 +67936,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(274 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -64484,7 +67950,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(275 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -64498,7 +67964,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(276 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -64510,7 +67976,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(277 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -64523,7 +67989,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(278 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -64538,7 +68004,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(279 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -64553,7 +68019,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(280 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -64567,7 +68033,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(281 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64580,7 +68046,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(282 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -64601,7 +68067,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(288 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -64685,7 +68151,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314 /* NotEmittedStatement */); + var node = createSynthesizedNode(318 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -64697,7 +68163,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(322 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64709,7 +68175,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(321 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64724,7 +68190,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(315 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(319 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -64740,7 +68206,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316 /* CommaListExpression */) { + if (node.kind === 320 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -64750,7 +68216,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316 /* CommaListExpression */); + var node = createSynthesizedNode(320 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -64761,9 +68227,25 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + /* @internal */ + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323 /* SyntheticReferenceExpression */); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + /* @internal */ + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(289 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -64794,7 +68276,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(290 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -64876,8 +68358,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal" /* Internal */: - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } // falls through case "text" /* Text */: (texts || (texts = [])).push(createUnparsedNode(section, node)); @@ -64926,10 +68411,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 283 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 284 /* UnparsedPrepend */; + case "internal" /* Internal */: return 286 /* UnparsedInternalText */; + case "text" /* Text */: return 285 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -64947,14 +68432,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(287 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(291 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -65000,8 +68485,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65044,43 +68529,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28 /* LessThanToken */, right); + return createBinary(left, 29 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60 /* EqualsToken */, right); + return createBinary(left, 62 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 36 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 37 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38 /* PlusToken */, right); + return createBinary(left, 39 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39 /* MinusToken */, right); + return createBinary(left, 40 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44 /* PlusPlusToken */); + return createPostfix(operand, 45 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54 /* AmpersandAmpersandToken */, right); + return createBinary(left, 55 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55 /* BarBarToken */, right); + return createBinary(left, 56 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60 /* QuestionQuestionToken */, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52 /* ExclamationToken */, operand); + return createPrefix(53 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -65100,7 +68589,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -65144,7 +68636,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 === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65209,7 +68701,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -65495,9 +68986,9 @@ var ts; ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -65598,29 +69089,34 @@ var ts; } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; // Helpers - function getHelperName(name) { + /** + * Gets an identifier for the name of an *unscoped* emit helper. + */ + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); @@ -65628,24 +69124,26 @@ var ts; ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; @@ -65667,7 +69165,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); @@ -65678,7 +69176,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -65690,20 +69188,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cacheIdentifiers; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -65718,7 +69216,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99 /* SuperKeyword */) { + else if (callee.kind === 101 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -65730,7 +69228,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 193 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65743,7 +69241,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65800,14 +69298,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66085,8 +69583,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -66114,9 +69612,9 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } @@ -66133,7 +69631,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 === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 199 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66167,10 +69665,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(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 /* ArrowFunction */ && binaryOperatorPrecedence > 3) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66182,7 +69680,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 211 /* YieldExpression */) { return false; } return true; @@ -66219,7 +69717,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 38 /* PlusToken */) { + if (binaryOperator === 39 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -66254,10 +69752,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 === 40 /* AsteriskToken */ - || binaryOperator === 50 /* BarToken */ - || binaryOperator === 49 /* AmpersandToken */ - || binaryOperator === 51 /* CaretToken */; + return binaryOperator === 41 /* AsteriskToken */ + || binaryOperator === 51 /* BarToken */ + || binaryOperator === 50 /* AmpersandToken */ + || binaryOperator === 52 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -66270,22 +69768,20 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(209 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -66320,8 +69816,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: needsParens = true; } } @@ -66337,9 +69833,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66362,7 +69858,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66400,7 +69896,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66411,29 +69907,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 200 /* FunctionExpression */ || kind === 201 /* 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 === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 192 /* ObjectLiteralExpression */ || leftmostExpressionKind === 200 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 179 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -66441,9 +69937,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 171 /* TypeQuery */: + case 183 /* TypeOperator */: + case 180 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -66469,28 +69965,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 315 /* PartiallyEmittedExpression */: + case 216 /* AsExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 217 /* NonNullExpression */: + case 319 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -66499,15 +69995,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 192 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 316 /* CommaListExpression */; + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 320 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -66520,13 +70016,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 217 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -66551,7 +70047,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 217 /* NonNullExpression */) { node = node.expression; } return node; @@ -66559,11 +70055,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 315 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -66581,7 +70077,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -66606,6 +70102,60 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + // use named imports + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + // Alias the imports if the names are used somewhere in the file. + // NOTE: We don't need to care about global import collisions as this is a module. + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + // use a namespace import + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -66620,8 +70170,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -66646,10 +70196,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 253 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 259 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -66768,7 +70318,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -66780,11 +70330,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -66816,12 +70366,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 155 /* Parameter */: + case 190 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 212 /* SpreadElement */: + case 281 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -66833,7 +70383,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 190 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -66845,7 +70395,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -66857,7 +70407,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -66880,13 +70430,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -66926,11 +70476,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67053,11 +70603,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -67091,278 +70639,287 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */) || kind === 182 /* ThisType */) { return node; } switch (kind) { // Names - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 155 /* 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 153 /* Decorator */: + case 156 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 157 /* 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 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 159 /* 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 157 /* MethodDeclaration */: + case 160 /* 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 158 /* Constructor */: + case 161 /* 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 159 /* GetAccessor */: + case 162 /* 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 160 /* SetAccessor */: + case 163 /* 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 161 /* CallSignature */: + case 164 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 166 /* 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 164 /* TypePredicate */: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 167 /* TypePredicate */: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 174 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 176 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 177 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 179 /* 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 177 /* InferType */: + case 180 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 187 /* 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 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 185 /* 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 183 /* LiteralType */: + case 186 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 190 /* 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 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 200 /* 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 198 /* ArrowFunction */: + case 201 /* 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 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 209 /* 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 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 213 /* 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 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 222 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 226 /* 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 224 /* DoStatement */: + case 227 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 229 /* 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 227 /* ForInStatement */: + case 230 /* 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 228 /* ForOfStatement */: + case 231 /* 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 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 243 /* 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 241 /* ClassDeclaration */: + case 244 /* 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 242 /* InterfaceDeclaration */: + case 245 /* 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 243 /* TypeAliasDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 247 /* 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 245 /* ModuleDeclaration */: + case 248 /* 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 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 252 /* 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 250 /* ImportDeclaration */: + case 253 /* 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 251 /* ImportClause */: + case 254 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 259 /* 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 257 /* NamedExports */: + case 260 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -67404,58 +70961,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 167 /* TypePredicate */ && kind <= 186 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 314 /* NotEmittedStatement */: + case 221 /* SemicolonClassElement */: + case 223 /* EmptyStatement */: + case 214 /* OmittedExpression */: + case 240 /* DebuggerStatement */: + case 318 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 155 /* 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 153 /* Decorator */: + case 156 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 157 /* 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 155 /* PropertyDeclaration */: + case 158 /* 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 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67464,12 +71021,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 161 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67477,7 +71034,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67485,50 +71042,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 196 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -67536,123 +71093,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 201 /* 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 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 213 /* 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 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 216 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 222 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 229 /* 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 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67661,7 +71218,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67669,140 +71226,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 247 /* 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 245 /* ModuleDeclaration */: + case 248 /* 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 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* 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 250 /* ImportDeclaration */: + case 253 /* 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 251 /* ImportClause */: + case 254 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 259 /* 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 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -67875,7 +71432,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 !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 215 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -67948,19 +71505,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ 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); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68163,12 +71721,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ 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 @@ -68180,6 +71737,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -68548,7 +72106,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -68590,25 +72148,31 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 252 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -68638,13 +72202,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -68652,7 +72216,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -68672,7 +72236,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -68694,12 +72258,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -68774,7 +72334,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -68804,42 +72364,28 @@ var ts; } ts.helperString = helperString; /** - * Gets all property declarations with initializers on either the static or instance side of a class. + * Gets all the static or all the instance property declarations of a class * * @param node The class node. * @param isStatic A value indicating whether to get properties from the static or instance side of the class. */ - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.getInitializedProperties = getInitializedProperties; + ts.getProperties = getProperties; /** - * Gets a value indicating whether a class element is a static property declaration with an initializer. - * - * @param member The class element node. - */ - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); - } - ts.isStaticInitializedProperty = isStaticInitializedProperty; - /** - * Gets a value indicating whether a class element is an instance property declaration with an initializer. - * - * @param member The class element node. - */ - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); - } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; - /** - * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. + * Is a class element either a static or an instance property declaration with an initializer? * * @param member The class element node. * @param isStatic A value indicating whether the member should be a static or instance member. */ - function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ - && member.initializer !== undefined; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; + } + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -69287,6 +72833,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -69311,7 +72858,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), + return ts.createCall(ts.getUnscopedHelperName("__rest"), /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) @@ -69364,8 +72911,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -69391,14 +72938,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* 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 === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -69449,16 +72996,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 249 /* ModuleBlock */: + case 222 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -69470,7 +73017,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 === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 244 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -69513,10 +73060,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -69537,13 +73084,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -69563,11 +73110,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 259 /* ExportDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 254 /* ImportClause */ || + (node.kind === 252 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 263 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -69591,19 +73138,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -69613,7 +73160,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 86 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 88 /* ExportKeyword */) { return undefined; } return node; @@ -69630,67 +73177,71 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 124 /* BooleanKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 133 /* NeverKeyword */: - case 107 /* VoidKeyword */: - case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 137 /* ReadonlyKeyword */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 172 /* TypeLiteral */: + case 167 /* TypePredicate */: + case 154 /* TypeParameter */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 127 /* BooleanKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 136 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 143 /* SymbolKeyword */: + case 170 /* ConstructorType */: + case 169 /* FunctionType */: + case 171 /* TypeQuery */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 181 /* ParenthesizedType */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 166 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 156 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 158 /* 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 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 245 /* 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 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69700,7 +73251,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69710,35 +73261,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -69748,35 +73299,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -69814,7 +73365,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -69843,7 +73394,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1 /* Export */))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); @@ -70080,7 +73631,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -70186,12 +73737,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70344,7 +73895,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 158 /* 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() @@ -70445,13 +73996,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(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -70467,10 +74018,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 158 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -70480,7 +74031,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -70491,12 +74042,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; } return false; @@ -70513,15 +74064,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -70558,7 +74109,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 162 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -70603,69 +74154,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: - case 124 /* BooleanKeyword */: + case 167 /* TypePredicate */: + case 127 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return ts.createIdentifier("String"); - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: - if (node.operator === 134 /* ReadonlyKeyword */) { + case 183 /* TypeOperator */: + if (node.operator === 137 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 171 /* TypeQuery */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 172 /* TypeLiteral */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 182 /* ThisType */: + case 187 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70676,15 +74227,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* 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); @@ -70764,12 +74315,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73 /* Identifier */) { + if (node.left.kind === 75 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -70785,7 +74336,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* 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); @@ -70793,7 +74344,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -70877,7 +74428,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 110 /* ImplementsKeyword */) { + if (node.token === 112 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -70927,7 +74478,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -71340,12 +74891,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 === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 288 /* 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 === 244 /* EnumDeclaration */) { + if (node.kind === 247 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -71470,7 +75021,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 249 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -71516,13 +75067,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 !== 246 /* ModuleBlock */) { + if (body.kind !== 249 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -71563,7 +75114,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 255 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -71776,7 +75327,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -71784,7 +75335,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(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -71794,17 +75345,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(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(75 /* Identifier */); + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(248 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 248 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 247 /* EnumDeclaration */; } /** * Hook for node emit. @@ -71863,11 +75414,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -71905,9 +75456,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 !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 288 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 248 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 247 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -71929,9 +75480,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } return substitute; @@ -71957,18 +75509,19 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), + return ts.createCall(ts.getUnscopedHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue @@ -71976,13 +75529,14 @@ var ts; } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression @@ -71990,6 +75544,7 @@ var ts; } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -72032,7 +75587,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -72043,11 +75600,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72059,20 +75616,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72082,7 +75639,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -72115,7 +75672,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var statements = [ ts.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -72131,9 +75688,9 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -72151,9 +75708,9 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { @@ -72165,7 +75722,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -72206,8 +75763,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -72220,7 +75777,7 @@ var ts; /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, /*isStatic*/ false); + var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false); // Only generate synthetic constructor when there are property initializers to move. if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); @@ -72252,7 +75809,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -72264,7 +75821,7 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -72281,7 +75838,7 @@ var ts; * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -72318,19 +75875,29 @@ var ts; */ function transformInitializedProperty(property, receiver) { // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72350,7 +75917,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -72434,6 +76001,7 @@ var ts; var hasSuperElementAccess; /** A set of node IDs for generated super accessors (variable statements). */ var substitutedSuperAccessors = []; + var topLevel; // Save the previous transformation hooks. var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; @@ -72445,38 +76013,57 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32 /* ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 243 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -72484,27 +76071,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 222 /* Block */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 235 /* WithStatement */: + case 237 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -72705,7 +76292,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 === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 201 /* 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 @@ -72728,7 +76315,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -72755,7 +76342,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -72796,17 +76383,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -72854,23 +76441,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -72882,19 +76469,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -72954,23 +76541,24 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; - return ts.createCall(ts.getHelperName("__awaiter"), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -73004,9 +76592,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; /** Keeps track of property names accessed on super (`super.x`) within async functions. */ var capturedSuperProperties; /** Whether the async function contains an element access on super (`super[x]`). */ @@ -73018,6 +76608,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -73029,68 +76621,85 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122 /* AsyncKeyword */) { + if (node.kind === 125 /* AsyncKeyword */) { return undefined; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 238 /* VariableDeclaration */: + case 224 /* VariableStatement */: + return visitVariableStatement(node); + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: - return visitConstructorDeclaration(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - return visitGetAccessorDeclaration(node); - case 160 /* SetAccessor */: - return visitSetAccessorDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + return doOutsideOfTopLevel(visitConstructorDeclaration, node); + case 160 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 162 /* GetAccessor */: + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 163 /* SetAccessor */: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 243 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -73123,7 +76732,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 231 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73135,7 +76744,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 === 278 /* SpreadAssignment */) { + if (e.kind === 281 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73144,7 +76753,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 279 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73178,7 +76787,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 192 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -73223,23 +76832,44 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a VariableDeclaration node with a binding pattern. * * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false); + } + function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. if (ts.isBindingPattern(node.name) && node.name.transformFlags & 8192 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */); + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -73454,10 +77084,10 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); @@ -73523,17 +77153,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -73581,23 +77211,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -73609,19 +77239,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73637,65 +77267,69 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), + return ts.createCall(ts.getUnscopedHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), /*typeArguments*/ undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__asyncGenerator"), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } })(ts || (ts = {})); @@ -73715,7 +77349,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -73734,6 +77368,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -73746,10 +77381,143 @@ var ts; return node; } switch (node.kind) { + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + var updated = visitOptionalExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208 /* BinaryExpression */: + if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a.b` -> { expression: `(_a = a).b`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a[b]` -> { expression: `(_a = a)[b]`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193 /* PropertyAccessExpression */: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194 /* ElementAccessExpression */: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193 /* PropertyAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194 /* ElementAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195 /* CallExpression */: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, + /*typeArguments*/ undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createNull()), ts.createToken(55 /* AmpersandAmpersandToken */), ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -73784,13 +77552,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73800,13 +77568,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -73881,7 +77649,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 274 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -73975,7 +77743,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 264 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74281,7 +78049,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74289,9 +78057,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74494,13 +78262,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 234 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 222 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -74513,72 +78281,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 73 /* Identifier */: + case 75 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -74589,28 +78357,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitSpreadElement(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -74701,14 +78469,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 === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 233 /* 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 === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -74719,7 +78487,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -74977,7 +78745,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -75115,11 +78883,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 234 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 226 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75127,7 +78895,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 222 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75282,10 +79050,10 @@ var ts; return false; } // `declarationName` is the name of the local declaration for the parameter. - var declarationName = parameter.name.kind === 73 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var declarationName = parameter.name.kind === 75 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 73 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; @@ -75309,7 +79077,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73 /* Identifier */) { + if (parameter.name.kind !== 75 /* Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); @@ -75325,7 +79093,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 201 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -75346,25 +79114,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 161 /* 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 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 */), 95 /* 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 */), 97 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -75393,20 +79161,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -75432,12 +79200,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), - /*location*/ member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. @@ -75594,7 +79372,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 === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 243 /* FunctionDeclaration */ || node.kind === 200 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -75638,7 +79416,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 201 /* 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 @@ -75706,9 +79484,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 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -75727,9 +79505,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 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -75764,7 +79542,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 60 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -75938,14 +79716,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76133,7 +79911,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 153 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76188,7 +79966,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -76254,11 +80032,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 229 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 231 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 227 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 228 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76283,11 +80061,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 242 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -76438,7 +80216,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -76500,7 +80278,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(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -76538,7 +80316,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -76549,7 +80327,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, 60 /* EqualsToken */, source); + return ts.createBinary(target, 62 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -76562,7 +80340,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -76576,7 +80354,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(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -76597,10 +80375,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -76686,20 +80464,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -76775,7 +80553,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a @@ -76806,7 +80584,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -76859,7 +80637,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 /* SuperKeyword */ || + if (expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -76983,10 +80761,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 4096 /* ContainsRestOrSpread */ || - node.expression.kind === 99 /* SuperKeyword */ || + node.expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -77004,7 +80782,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -77016,10 +80794,10 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -77043,7 +80821,7 @@ var ts; // [output] // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), /*typeArguments*/ undefined, []); } return ts.visitEachChild(node, visitor, context); @@ -77207,13 +80985,16 @@ var ts; // Find original source text, since we need to emit the raw strings of the tagged template. // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + 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 // and LineTerminatorSequences are normalized to for both TV and TRV. @@ -77304,13 +81085,11 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 98 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return ts.createFileLevelUniqueName("_newTarget"); } @@ -77342,7 +81121,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } /** @@ -77352,14 +81131,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableSubstitution(103 /* ThisKeyword */); + context.enableEmitNotification(161 /* Constructor */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(201 /* ArrowFunction */); + context.enableEmitNotification(200 /* FunctionExpression */); + context.enableEmitNotification(243 /* FunctionDeclaration */); } } /** @@ -77400,10 +81179,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 241 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -77416,9 +81195,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -77485,19 +81264,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -77507,7 +81286,7 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), + return ts.createCall(ts.getUnscopedHelperName("__extends"), /*typeArguments*/ undefined, [ name, ts.createFileLevelUniqueName("_super") @@ -77515,7 +81294,7 @@ var ts; } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw @@ -77523,12 +81302,14 @@ var ts; } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -77550,15 +81331,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(266 /* JsxOpeningElement */); + context.enableEmitNotification(267 /* JsxClosingElement */); + context.enableEmitNotification(265 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(279 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -77577,9 +81358,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -77636,7 +81417,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */) { + if (token !== undefined && token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -77911,13 +81692,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -77930,24 +81711,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -77968,21 +81749,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -77995,9 +81776,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78196,23 +81977,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 /* FirstCompoundAssignment */ - && kind <= 72 /* LastCompoundAssignment */; + return kind >= 63 /* FirstCompoundAssignment */ + && kind <= 74 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61 /* PlusEqualsToken */: return 38 /* PlusToken */; - case 62 /* MinusEqualsToken */: return 39 /* MinusToken */; - case 63 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; - case 64 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; - case 65 /* SlashEqualsToken */: return 42 /* SlashToken */; - case 66 /* PercentEqualsToken */: return 43 /* PercentToken */; - case 67 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; - case 68 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; - case 70 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; - case 71 /* BarEqualsToken */: return 50 /* BarToken */; - case 72 /* CaretEqualsToken */: return 51 /* CaretToken */; + case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; + case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; + case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; + case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; + case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; + case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; + case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; + case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; + case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; + case 73 /* BarEqualsToken */: return 51 /* BarToken */; + case 74 /* CaretEqualsToken */: return 52 /* CaretToken */; } } /** @@ -78225,7 +82006,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78237,7 +82018,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -78324,7 +82105,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 === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -78463,13 +82244,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -78478,7 +82259,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -78613,35 +82394,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79071,7 +82852,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 276 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79084,7 +82865,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79257,11 +83038,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -79396,7 +83176,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -80222,7 +84002,7 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), + return ts.createCall(ts.getUnscopedHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } // The __generator helper is used by down-level transformations to emulate the runtime @@ -80286,6 +84066,7 @@ var ts; // For examples of how these are used, see the comments in ./transformers/generators.ts ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -80312,12 +84093,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(288 /* 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. @@ -80415,14 +84196,14 @@ var ts; // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), // Add the module body function argument: // // function (require, exports, module1, module2) ... @@ -80432,10 +84213,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ]))) ]), @@ -80470,11 +84251,11 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) @@ -80502,10 +84283,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), @@ -80645,23 +84426,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 317 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -80688,24 +84469,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -80820,7 +84601,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -80834,7 +84615,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; if (languageVersion >= 2 /* ES2015 */) { @@ -80868,11 +84649,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; } @@ -81183,7 +84964,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81238,10 +85019,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -81423,8 +85204,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -81440,7 +85221,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -81502,12 +85283,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -81528,7 +85309,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -81596,15 +85377,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 === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* 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 === 204 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 207 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -81644,7 +85425,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]); } // emit helper for dynamic import @@ -81656,12 +85437,14 @@ var ts; // emit helper for `import * as Name from "foo"` ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -81678,16 +85461,18 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(218 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. + var contextObjectMap = []; // The context object associated with a source file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -81726,7 +85511,7 @@ var ts; // existing identifiers. exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -81904,7 +85689,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 259 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -81929,7 +85714,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 259 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -81998,28 +85783,28 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; + var group_2 = dependencyGroups_1[_i]; // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82069,15 +85854,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82253,7 +86038,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 === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 288 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -82317,7 +86102,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 === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -82379,10 +86164,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82562,43 +86347,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node); - case 317 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -82845,7 +86630,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 288 /* SourceFile */; } else { return false; @@ -82861,8 +86646,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -82878,12 +86663,13 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -82891,6 +86677,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -82926,7 +86713,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -82960,13 +86747,15 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); + case 218 /* MetaProperty */: + return substituteMetaProperty(node); } return node; } @@ -83051,22 +86840,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 === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* 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 === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 207 /* 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 === 204 /* PostfixUnaryExpression */) { - expression = node.operator === 44 /* PlusPlusToken */ + if (node.kind === 207 /* PostfixUnaryExpression */) { + expression = node.operator === 45 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -83075,6 +86864,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } /** * Gets the exports of a name. * @@ -83087,7 +86882,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83126,24 +86921,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); - context.enableSubstitution(73 /* Identifier */); - var currentSourceFile; + context.enableEmitNotification(288 /* SourceFile */); + context.enableSubstitution(75 /* Identifier */); + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864 /* NeverApplyImportHelper */); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -83155,10 +86946,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83179,9 +86970,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -83198,19 +86989,18 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -83266,7 +87056,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83295,7 +87085,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83321,7 +87111,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -83342,7 +87132,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 === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* 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 : @@ -83351,8 +87141,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 === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 158 /* PropertyDeclaration */ || node.kind === 193 /* PropertyAccessExpression */ || node.kind === 157 /* PropertySignature */ || + (node.kind === 155 /* 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 ? @@ -83361,7 +87151,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 === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 244 /* ClassDeclaration */ || node.kind === 155 /* 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 : @@ -83386,7 +87176,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* 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 */)) { @@ -83425,26 +87215,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* 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 161 /* CallSignature */: + case 164 /* 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 163 /* IndexSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83452,7 +87242,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83466,7 +87256,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 243 /* 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 : @@ -83491,30 +87281,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 161 /* 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 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 165 /* ConstructSignature */: + case 170 /* 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 161 /* CallSignature */: + case 164 /* 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 163 /* IndexSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83522,7 +87312,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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* 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 : @@ -83535,13 +87325,20 @@ 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 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 243 /* FunctionDeclaration */: + case 169 /* 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 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -83550,39 +87347,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 185 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* 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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* 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 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 169 /* FunctionType */: + case 243 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -83597,9 +87394,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 244 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 /* 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; } @@ -83634,11 +87431,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; // No declaration diagnostics for js for now - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -83648,7 +87442,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 155 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -83709,9 +87503,9 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -83794,20 +87588,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -83820,18 +87623,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { 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(126 /* 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 statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : 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 === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -83868,12 +87671,19 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -83915,6 +87725,15 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { + var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, host.getSourceFiles(), + /*preferences*/ undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration + // via a non-relative name, emit a type reference directive to that non-relative name, rather than + // a relative path to the declaration file + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { @@ -83951,11 +87770,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 189 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -83963,20 +87782,20 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 214 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { oldDiag = getSymbolAccessibilityDiagnostic; 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(56 /* 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(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -84001,19 +87820,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 155 /* 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(121 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* 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(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -84021,12 +87840,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 155 /* Parameter */ + || node.kind === 158 /* PropertyDeclaration */ + || node.kind === 157 /* 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)); @@ -84037,26 +87856,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(124 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return false; } return false; @@ -84083,6 +87902,33 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, /*modifierMask*/ undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -84110,7 +87956,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 /* ModuleDeclaration */ && parent.kind !== 187 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84130,7 +87976,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 263 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84157,7 +88003,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 === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 255 /* 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; @@ -84206,11 +88052,11 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -84220,13 +88066,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -84249,6 +88088,11 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + // Setup diagnostic-related flags before first potential `cleanup` call, otherwise + // We'd see a TDZ violation at runtime + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 /* TypeLiteral */ || input.kind === 185 /* MappedType */) && input.parent.kind !== 246 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -84257,76 +88101,77 @@ var ts; return cleanup(ts.createProperty(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* 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 212 /* ExpressionWithTypeArguments */: { + case 215 /* 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 165 /* TypeReference */: { + case 168 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 161 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(161 /* 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 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(159 /* 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 159 /* GetAccessor */: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 162 /* GetAccessor */: { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); } - case 160 /* SetAccessor */: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 163 /* SetAccessor */: { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); } - case 155 /* PropertyDeclaration */: + case 158 /* 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 154 /* PropertySignature */: + case 157 /* 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 156 /* MethodSignature */: { + case 159 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 164 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 166 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -84334,13 +88179,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 151 /* TypeParameter */: { + case 154 /* 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 176 /* ConditionalType */: { + case 179 /* 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); @@ -84352,13 +88197,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 169 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 170 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 187 /* 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)); @@ -84368,13 +88213,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -84387,7 +88232,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 160 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -84397,7 +88242,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 259 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -84406,13 +88251,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 258 /* 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 === 73 /* Identifier */) { + if (input.expression.kind === 75 /* Identifier */) { return input; } else { @@ -84422,7 +88267,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(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -84447,10 +88292,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -84471,14 +88316,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 246 /* 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), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 245 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 243 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -84493,7 +88338,7 @@ var ts; fakespace_1.symbol = props[0].parent; var declarations = ts.mapDefined(props, function (p) { if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { - return undefined; + return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker); @@ -84526,17 +88371,17 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 248 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 249 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304 /* Ambient */) { + if (input.flags & 8388608 /* Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -84545,7 +88390,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -84572,7 +88417,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 244 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -84583,7 +88428,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73 /* Identifier */) { + if (param.name.kind === 75 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -84613,7 +88458,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 !== 97 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); @@ -84623,16 +88468,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(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87 /* ExtendsKeyword */) { + if (clause.token === 89 /* 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 === 97 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -84643,10 +88488,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 247 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -84665,7 +88510,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 248 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -84686,7 +88531,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 214 /* OmittedExpression */) { return; } if (e.name) { @@ -84736,55 +88581,36 @@ var ts; function ensureModifierFlags(node) { 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 === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 288 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask, additions); } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); } - var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3 /* MultiLineCommentTrivia */) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; + return accessorType; } 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 === 87 /* ExtendsKeyword */ && t.expression.kind === 97 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 /* ExtendsKeyword */ && t.expression.kind === 99 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { return true; } return false; @@ -84809,7 +88635,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 162 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -84818,52 +88644,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 224 /* VariableStatement */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 165 /* ConstructSignature */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 241 /* VariableDeclaration */: + case 154 /* TypeParameter */: + case 215 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 179 /* ConditionalType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 187 /* ImportType */: return true; } return false; @@ -84992,7 +88818,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(319 /* Count */); + var enabledSyntaxKindFeatures = new Array(324 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -85199,7 +89025,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement( @@ -85277,15 +89103,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -85295,22 +89121,21 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - /*@internal*/ - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -85333,7 +89158,7 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; @@ -85341,14 +89166,14 @@ var ts; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 289 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -85358,9 +89183,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -85401,11 +89224,13 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : @@ -85416,43 +89241,73 @@ var ts; outputFileName : undefined; } + function createAddOutput() { + var outputs; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } /*@internal*/ function getAllProjectOutputs(configFile, ignoreCase) { - var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) - continue; - if (configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; /*@internal*/ function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { @@ -85466,8 +89321,13 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + continue; + if (ts.getEmitDeclarations(configFile.options)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); @@ -85475,7 +89335,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -85489,7 +89349,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -85585,17 +89445,16 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !declarationFilePath) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; // Setup and perform the transformation to retrieve declarations from the input files - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -85627,7 +89486,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -85635,12 +89494,8 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { - // Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule. - // But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow. - // Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the - // tslint directive can be all be removed. - var sourceFile = declarationTransform.transformed[0]; // tslint:disable-line + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288 /* SourceFile */) { + var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } @@ -85650,7 +89505,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -85662,8 +89517,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -85704,7 +89559,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 288 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -85811,10 +89666,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(288 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -85826,7 +89682,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(225 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -85865,7 +89721,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -85919,6 +89775,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers)); @@ -85971,6 +89828,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -85999,9 +89858,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 288 /* SourceFile */: return printFile(node); + case 289 /* Bundle */: return printBundle(node); + case 290 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86170,8 +90029,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -86183,7 +90041,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86199,6 +90057,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { @@ -86208,21 +90068,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(4 /* Unspecified */, node); + var substitute = pipelineEmit(4 /* Unspecified */, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(2 /* IdentifierName */, node); + return pipelineEmit(2 /* IdentifierName */, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1 /* Expression */, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(1 /* Expression */, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -86237,12 +90108,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 288 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -86256,10 +90127,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -86279,279 +90153,279 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 290 /* UnparsedSource */: + case 284 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 283 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 287 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 156 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 293 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 294 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + case 299 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 222 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 223 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 267 /* JsxClosingElement */: + case 270 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 304 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 299 /* JSDocSignature */: + case 303 /* JSDocSignature */: return emitJSDocSignature(node); - case 298 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 303 /* JSDocClassTag */: - case 300 /* JSDocTag */: + case 307 /* JSDocClassTag */: + case 304 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 297 /* JSDocComment */: + case 301 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -86569,83 +90443,83 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Reserved words - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 103 /* TrueKeyword */: - case 101 /* ThisKeyword */: - case 93 /* ImportKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 105 /* TrueKeyword */: + case 103 /* ThisKeyword */: + case 95 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return emitCommaList(node); } } @@ -86658,8 +90532,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -86673,8 +90550,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -86685,7 +90562,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 289 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -86694,12 +90571,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -86785,7 +90662,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -86818,7 +90695,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -86854,7 +90731,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 298 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -86916,7 +90793,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 162 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -86957,11 +90834,17 @@ var ts; // Types // function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -87093,18 +90976,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); - pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* QuestionToken */) { writePunctuation("?"); } } @@ -87184,66 +91066,57 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, - /*stopAfterLineBreak*/ false, - /*stopAtComments*/ true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { - var dotToken = ts.createToken(24 /* DotToken */); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(96 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(98 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -87283,22 +91156,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(84 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(107 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(126 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -87323,9 +91196,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* 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 */))); + return operand.kind === 206 /* PrefixUnaryExpression */ + && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) + || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -87338,7 +91211,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); @@ -87366,7 +91239,7 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(118 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(120 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -87443,7 +91316,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87451,8 +91324,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + emitTokenWithComment(86 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -87462,14 +91335,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(85 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -87478,14 +91351,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -87497,25 +91370,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -87523,7 +91396,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { emit(node); } else { @@ -87532,12 +91405,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(76 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -87565,12 +91438,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(100 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87578,7 +91451,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87588,17 +91461,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -87607,13 +91480,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(82 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -87638,7 +91511,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -87810,7 +91683,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512 /* GlobalAugmentation */) { + if (~node.flags & 1024 /* GlobalAugmentation */) { writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); writeSpace(); } @@ -87818,7 +91691,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 248 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -87839,17 +91712,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -87858,12 +91731,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -87878,9 +91751,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -87891,42 +91764,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(81 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(83 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -87946,7 +91819,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -88024,7 +91897,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88035,13 +91908,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(75 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(77 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -88053,12 +91926,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -88069,7 +91942,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -88139,7 +92012,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88173,7 +92046,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88192,7 +92065,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -88326,8 +92199,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_20 = types; _d < types_20.length; _d++) { + var directive = types_20[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -88507,7 +92380,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -88545,8 +92418,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmbeddedStatement */, node); } else { emit(node); @@ -88953,6 +92825,9 @@ var ts; return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -88970,7 +92845,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89035,81 +92910,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 237 /* LabeledStatement */: + case 235 /* WithStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89118,12 +92993,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -89181,7 +93056,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { return false; } } @@ -89303,25 +93178,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 258 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -89364,11 +93239,12 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 318 /* 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 */; @@ -89392,7 +93268,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -89422,6 +93298,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -89635,6 +93512,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -89649,7 +93527,7 @@ var ts; 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 !== 314 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -89662,12 +93540,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -90030,6 +93909,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -90385,7 +94267,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -90574,8 +94456,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -90588,6 +94470,8 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + /* @internal */ + ts.inferredTypesContainingFile = "__inferred type names__.ts"; /** * Determines if program structure is upto date or needs to be recreated */ @@ -90662,7 +94546,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -90692,15 +94576,17 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -90736,7 +94622,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).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; @@ -90753,7 +94639,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 @@ -90782,8 +94668,13 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks + // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -90791,20 +94682,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } } } @@ -90817,7 +94724,7 @@ var ts; 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(); - var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -90853,8 +94760,8 @@ var ts; // not part of the new program. if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || // old file wasnt redirect but new file is @@ -90870,12 +94777,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -90912,7 +94820,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -90939,9 +94849,14 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + // source file is allowed to be emitted and its not source of project reference redirect + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -91145,6 +95060,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; @@ -91235,7 +95156,7 @@ var ts; // moduleAugmentations has changed oldProgram.structureIsReused = 1 /* SafeModules */; } - if ((oldSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) { // dynamicImport has changed oldProgram.structureIsReused = 1 /* SafeModules */; } @@ -91272,28 +95193,26 @@ var ts; 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 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) { - oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + 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) { + oldProgram.structureIsReused = 1 /* SafeModules */; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } 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, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutions_1 = 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) { + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -91307,11 +95226,19 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping 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 (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined); + } + } // Set the file as found during node modules search if it was found that way in old progra, if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); @@ -91329,9 +95256,10 @@ var ts; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -91340,7 +95268,7 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -91396,15 +95324,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -91412,7 +95340,7 @@ var ts; // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); } @@ -91436,7 +95364,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -91511,15 +95440,16 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || - sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || + sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -91578,22 +95508,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 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 241 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -91601,41 +95531,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 110 /* ImplementsKeyword */) { + if (heritageClause.token === 112 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -91648,51 +95578,52 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* 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 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 224 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 158 /* 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 !== 117 /* StaticKeyword */) { + if (modifier.kind !== 119 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152 /* Parameter */: + case 155 /* 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 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 197 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -91709,24 +95640,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 126 /* DeclareKeyword */: - case 119 /* AbstractKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 129 /* DeclareKeyword */: + case 121 /* 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 117 /* StaticKeyword */: - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 119 /* StaticKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: } } } @@ -91801,8 +95732,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 /* Identifier */ - ? b.kind === 73 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 75 /* Identifier */ + ? b.kind === 75 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -91832,7 +95763,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -91883,7 +95814,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -91964,24 +95895,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -92004,15 +95929,26 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); + var file_2 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected - if (file_1 && options.forceConsistentCasingInFileNames) { + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -92021,34 +95957,35 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } // See if we need to reprocess the imports due to prior skipped imports - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -92066,14 +96003,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92104,7 +96034,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92127,8 +96057,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92143,8 +96083,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts or any of the non ts files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + // Ignore dts + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -92183,6 +96123,35 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + // Dont know which source file it means so return true? + var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); @@ -92217,9 +96186,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -92235,10 +96212,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -92250,7 +96233,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -92260,8 +96243,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -92269,14 +96251,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -92294,20 +96276,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -92347,14 +96329,22 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152 /* JSDoc */)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -92373,12 +96363,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -92435,9 +96428,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -92472,17 +96462,18 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -92598,8 +96589,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -92664,8 +96655,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -92692,7 +96716,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -92767,7 +96791,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -92826,6 +96850,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; /* @internal */ @@ -92871,9 +96901,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } /* @internal */ /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. @@ -92923,9 +96950,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93171,11 +97198,19 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, + /*emitOnlyDtsFiles*/ true, cancellationToken, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); + var firstDts_1 = emitOutput_1.outputFiles && + programOfThisState.getCompilerOptions().declarationMap ? + emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : + emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + if (firstDts_1) { + ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + latestSignature = computeHash(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -93278,6 +97313,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; /** * For script files that contains only ambient external modules, although they are not actually external module files, * they can only be consumed via importing elements from them. Regular script files cannot consume them. Therefore, @@ -93381,6 +97417,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -93394,8 +97435,7 @@ var ts; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them - // With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -93418,7 +97458,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -93464,7 +97505,7 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -93473,7 +97514,7 @@ var ts; function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -93492,7 +97533,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } /** * Releases program and other related not needed properties @@ -93518,7 +97559,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -93550,7 +97592,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } // Remove the changed file from the change set @@ -93596,13 +97637,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -93621,7 +97667,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -93646,7 +97692,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -93664,14 +97710,39 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } /** * Iterate on referencing modules that export entities from affected file */ function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { + return; + } + if (!isChangedSignagure(state, affectedFile.path)) return; + // Since isolated modules dont change js files, files affected by change in signature is itself + // But we need to cleanup semantic diagnostics and queue dts emit for affected files + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); @@ -93740,7 +97811,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -93750,6 +97821,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -93761,8 +97835,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + /** + * Returns the result with affected file + */ + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -93792,7 +97873,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -93887,7 +97968,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -93985,22 +98066,24 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94013,10 +98096,10 @@ var ts; affected = program; } } - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94072,7 +98155,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94104,7 +98187,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94116,8 +98199,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94153,7 +98242,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true }; return { @@ -94279,15 +98368,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -94452,8 +98553,8 @@ var ts; !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]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && @@ -94533,7 +98634,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -94744,6 +98845,10 @@ var ts; // Mark the file as needing re-evaluation of module resolution instead of using it blindly. resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + // When its a file with inferred types resolution, invalidate type reference directive resolution + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -94929,8 +99034,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -94946,20 +99052,26 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // Returns an import for each symlink and for the realpath. + /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) { var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); if (ambient) return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -94975,7 +99087,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0 /* Relative */) { return relativePath; @@ -95011,38 +99123,12 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. - // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** * Looks for existing imports that use symlinks to this module. @@ -95050,10 +99136,12 @@ var ts; */ function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -95070,7 +99158,31 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + // Sort by paths closest to importing file Name directory + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -95101,16 +99213,18 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -95119,24 +99233,27 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } // Simplify the full file path to something that can be resolved by Node. // If the module could be imported by a directory name, use that directory's name - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) @@ -95331,6 +99448,15 @@ var ts; ? newLine + newLine : newLine; } + /** + * Get locale specific time based on whether we are in test mode + */ + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -95338,7 +99464,7 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -95347,7 +99473,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -95540,7 +99666,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -95554,7 +99680,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -95588,7 +99716,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -95637,7 +99765,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -95730,7 +99858,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -95758,10 +99886,22 @@ 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, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -95987,13 +100127,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -96177,12 +100323,22 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -96338,11 +100494,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -96351,8 +100510,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -96372,12 +100530,35 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + // Clear all to ResolvedConfigFilePaths cache to start fresh + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + // Config file cache + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + // Remove watches for the program no longer in the solution + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -96385,6 +100566,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -96401,7 +100583,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -96456,7 +100638,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -96628,7 +100810,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -96796,6 +100978,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -96852,8 +101036,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97024,10 +101211,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97086,7 +101275,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -97251,16 +101440,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -97403,8 +101598,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -97436,6 +101631,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -97446,7 +101642,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -97454,7 +101650,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -97472,23 +101668,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -97521,13 +101727,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -97549,7 +101758,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -97937,6 +102145,15 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ + var PackageJsonDependencyGroup; + (function (PackageJsonDependencyGroup) { + PackageJsonDependencyGroup[PackageJsonDependencyGroup["Dependencies"] = 1] = "Dependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["DevDependencies"] = 2] = "DevDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["PeerDependencies"] = 4] = "PeerDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["OptionalDependencies"] = 8] = "OptionalDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["All"] = 15] = "All"; + })(PackageJsonDependencyGroup = ts.PackageJsonDependencyGroup || (ts.PackageJsonDependencyGroup = {})); + /* @internal */ ts.emptyOptions = {}; var HighlightSpanKind; (function (HighlightSpanKind) { @@ -97951,6 +102168,12 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = ts.SemicolonPreference || (ts.SemicolonPreference = {})); function getDefaultFormatCodeSettings(newLineCharacter) { return { indentSize: 4, @@ -97972,6 +102195,7 @@ var ts; insertSpaceBeforeFunctionParenthesis: false, placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, + semicolons: SemicolonPreference.Ignore, }; } ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; @@ -98201,37 +102425,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 278 /* CatchClause */: + case 271 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 154 /* TypeParameter */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 172 /* TypeLiteral */: return 2 /* Type */; - case 311 /* JSDocTypedefTag */: + case 315 /* 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 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 282 /* EnumMember */: + case 244 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -98241,26 +102465,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 247 /* EnumDeclaration */: + case 256 /* NamedImports */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 258 /* ExportAssignment */ || node.parent.kind === 263 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -98292,11 +102516,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 152 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 252 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -98308,27 +102532,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 152 /* QualifiedName */) { + while (root.parent && root.parent.kind === 152 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 168 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 193 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 193 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 215 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 277 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 244 /* ClassDeclaration */ && root.parent.parent.token === 112 /* ImplementsKeyword */) || + (decl.kind === 245 /* InterfaceDeclaration */ && root.parent.parent.token === 89 /* ExtendsKeyword */); } return false; } @@ -98337,17 +102561,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return true; - case 184 /* ImportType */: + case 187 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -98374,7 +102598,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 237 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -98390,11 +102614,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 73 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 73 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -98406,40 +102630,40 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 248 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 73 /* Identifier */ && + return node.kind === 75 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 282 /* EnumMember */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 248 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 186 /* LiteralType */: + return node.parent.parent.kind === 184 /* IndexedAccessType */; default: return false; } @@ -98463,17 +102687,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return node; } } @@ -98481,48 +102705,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 245 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 246 /* TypeAliasDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 247 /* EnumDeclaration */: return "enum" /* enumElement */; + case 241 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 162 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 163 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 279 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 166 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 165 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 164 /* CallSignature */: return "call" /* callSignatureElement */; + case 161 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 154 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 282 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 155 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -98549,7 +102778,7 @@ var ts; return "" /* unknown */; } } - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -98565,12 +102794,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 155 /* Parameter */; default: return false; } @@ -98635,42 +102864,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 172 /* TypeLiteral */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 250 /* CaseBlock */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 196 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 195 /* CallExpression */: + case 199 /* ParenthesizedExpression */: + case 181 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 201 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -98680,65 +102909,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 191 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 194 /* ElementAccessExpression */: + case 153 /* ComputedPropertyName */: + case 174 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 110 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 203 /* TypeOfExpression */: + case 202 /* DeleteExpression */: + case 204 /* VoidExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -98870,7 +103099,7 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - return ts.firstDefined(n.getChildren(), function (child) { + return ts.firstDefined(n.getChildren(sourceFile), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -98917,7 +103146,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 288 /* 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. @@ -98983,21 +103212,21 @@ var ts; return true; } //
Hello |
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 267 /* JsxClosingElement */) { return true; } return false; @@ -99019,7 +103248,7 @@ var ts; 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)) { + if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -99046,6 +103275,12 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; + function removeOptionality(type, isOptionalExpression, isOptionalChain) { + return isOptionalExpression ? type.getNonNullableType() : + isOptionalChain ? type.getNonOptionalType() : + type; + } + ts.removeOptionality = removeOptionality; function isPossiblyTypeArgumentPosition(token, sourceFile, checker) { var info = getPossibleTypeArgumentsInfo(token, sourceFile); return info !== undefined && (ts.isPartOfTypeNode(info.called) || @@ -99055,6 +103290,9 @@ var ts; ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; function getPossibleGenericSignatures(called, typeArgumentCount, checker) { var type = checker.getTypeAtLocation(called); + if (ts.isOptionalChain(called.parent)) { + type = removeOptionality(type, !!called.parent.questionDotToken, /*isOptionalChain*/ true); + } var signatures = ts.isNewExpression(called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); return signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= typeArgumentCount; }); } @@ -99071,9 +103309,12 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); + if (token && token.kind === 28 /* QuestionDotToken */) { + token = findPrecedingToken(token.getFullStart(), sourceFile); + } if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { @@ -99081,13 +103322,13 @@ var ts; } remainingLessThanTokens--; break; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: remainingLessThanTokens++; break; case 19 /* CloseBraceToken */: @@ -99115,20 +103356,22 @@ var ts; case 27 /* CommaToken */: nTypeArguments++; break; - case 37 /* EqualsGreaterThanToken */: - case 73 /* Identifier */: + case 38 /* EqualsGreaterThanToken */: + // falls through + case 75 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 105 /* TypeOfKeyword */: - case 87 /* ExtendsKeyword */: - case 130 /* KeyOfKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + // falls through + case 107 /* TypeOfKeyword */: + case 89 /* ExtendsKeyword */: + case 133 /* KeyOfKeyword */: case 24 /* DotToken */: - case 50 /* BarToken */: - case 56 /* QuestionToken */: - case 57 /* ColonToken */: + case 51 /* BarToken */: + case 57 /* QuestionToken */: + case 58 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -99177,16 +103420,16 @@ var ts; result.push("abstract" /* abstractModifier */); if (flags & 1 /* Export */) result.push("export" /* exportedModifier */); - if (node.flags & 4194304 /* Ambient */) + if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 168 /* TypeReference */ || node.kind === 195 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 244 /* ClassDeclaration */ || node.kind === 245 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -99206,7 +103449,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 72 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 74 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -99216,9 +103459,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: return true; } return false; @@ -99231,18 +103474,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 191 /* ArrayLiteralExpression */ || + node.kind === 192 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 208 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 60 /* EqualsToken */) { + node.parent.operatorToken.kind === 62 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 231 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -99250,7 +103493,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 279 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -99294,23 +103537,23 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 121 /* AnyKeyword */, - 147 /* BigIntKeyword */, - 124 /* BooleanKeyword */, - 88 /* FalseKeyword */, - 130 /* KeyOfKeyword */, - 133 /* NeverKeyword */, - 97 /* NullKeyword */, - 136 /* NumberKeyword */, - 137 /* ObjectKeyword */, - 134 /* ReadonlyKeyword */, - 139 /* StringKeyword */, - 140 /* SymbolKeyword */, - 103 /* TrueKeyword */, - 107 /* VoidKeyword */, - 142 /* UndefinedKeyword */, - 143 /* UniqueKeyword */, - 144 /* UnknownKeyword */, + 124 /* AnyKeyword */, + 150 /* BigIntKeyword */, + 127 /* BooleanKeyword */, + 90 /* FalseKeyword */, + 133 /* KeyOfKeyword */, + 136 /* NeverKeyword */, + 99 /* NullKeyword */, + 139 /* NumberKeyword */, + 140 /* ObjectKeyword */, + 137 /* ReadonlyKeyword */, + 142 /* StringKeyword */, + 143 /* SymbolKeyword */, + 105 /* TrueKeyword */, + 109 /* VoidKeyword */, + 145 /* UndefinedKeyword */, + 146 /* UniqueKeyword */, + 147 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -99346,7 +103589,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 153 /* 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); @@ -99422,7 +103665,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 73 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 75 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -99511,7 +103754,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 155 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -99552,6 +103795,8 @@ var ts; getColumn: function () { return 0; }, getLine: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingWhitespace: function () { return false; }, + hasTrailingComment: function () { return false; }, rawWrite: ts.notImplemented, getIndent: function () { return indent; }, increaseIndent: function () { indent++; }, @@ -99973,15 +104218,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 208 /* 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 272 /* CaseClause */: + case 275 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -100009,10 +104254,10 @@ var ts; ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: return true; default: return false; @@ -100023,8 +104268,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: return true; default: return false; @@ -100045,7 +104290,6 @@ var ts; 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, @@ -100063,28 +104307,90 @@ var ts; return typeIsAccessible ? res : undefined; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; - function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; - } - ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; + function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { + return kind === 164 /* CallSignature */ + || kind === 165 /* ConstructSignature */ + || kind === 166 /* IndexSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */; + } + ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; + function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { + return kind === 243 /* FunctionDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; + } + ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; + function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { + return kind === 248 /* ModuleDeclaration */; + } + ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; + function syntaxRequiresTrailingSemicolonOrASI(kind) { + return kind === 224 /* VariableStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 227 /* DoStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 233 /* BreakStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 158 /* PropertyDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 258 /* ExportAssignment */; + } + ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; + ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); + function isASICandidate(node, sourceFile) { + var lastToken = node.getLastToken(sourceFile); + if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + return false; + } + if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { + if (lastToken && lastToken.kind === 27 /* CommaToken */) { + return false; + } + } + else if (syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isModuleBlock(lastChild)) { + return false; + } + } + else if (syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isFunctionBlock(lastChild)) { + return false; + } + } + else if (!syntaxRequiresTrailingSemicolonOrASI(node.kind)) { + return false; + } + // See comment in parser’s `parseDoStatement` + if (node.kind === 227 /* DoStatement */) { + return true; + } + var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); + var nextToken = ts.findNextToken(node, topNode, sourceFile); + if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + return true; + } + var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(nextToken.getStart(sourceFile)).line; + return startLine !== endLine; + } + ts.isASICandidate = isASICandidate; function probablyUsesSemicolons(sourceFile) { var withSemicolon = 0; var withoutSemicolon = 0; var nStatementsToObserve = 5; ts.forEachChild(sourceFile, function visit(node) { - if (syntaxUsuallyHasTrailingSemicolon(node.kind)) { + if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { withSemicolon++; @@ -100107,9 +104413,154 @@ var ts; return withSemicolon / withoutSemicolon > 1 / nStatementsToObserve; } ts.probablyUsesSemicolons = probablyUsesSemicolons; + function tryGetDirectories(host, directoryName) { + return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || []; + } + ts.tryGetDirectories = tryGetDirectories; + function tryReadDirectory(host, path, extensions, exclude, include) { + return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include) || ts.emptyArray; + } + ts.tryReadDirectory = tryReadDirectory; + function tryFileExists(host, path) { + return tryIOAndConsumeErrors(host, host.fileExists, path); + } + ts.tryFileExists = tryFileExists; + function tryDirectoryExists(host, path) { + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; + } + ts.tryDirectoryExists = tryDirectoryExists; + function tryAndIgnoreErrors(cb) { + try { + return cb(); + } + catch (_a) { + return undefined; + } + } + ts.tryAndIgnoreErrors = tryAndIgnoreErrors; + 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); }); + } + ts.tryIOAndConsumeErrors = tryIOAndConsumeErrors; + function findPackageJsons(startDirectory, host, stopDirectory) { + var paths = []; + ts.forEachAncestorDirectory(startDirectory, function (ancestor) { + if (ancestor === stopDirectory) { + return true; + } + var currentConfigPath = ts.combinePaths(ancestor, "package.json"); + if (tryFileExists(host, currentConfigPath)) { + paths.push(currentConfigPath); + } + }); + return paths; + } + ts.findPackageJsons = findPackageJsons; + function findPackageJson(directory, host) { + var packageJson; + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (ancestor === "node_modules") + return true; + packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); + if (packageJson) { + return true; // break out + } + }); + return packageJson; + } + ts.findPackageJson = findPackageJson; + function getPackageJsonsVisibleToFile(fileName, host) { + if (!host.fileExists) { + return []; + } + var packageJsons = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(fileName), function (ancestor) { + var packageJsonFileName = ts.combinePaths(ancestor, "package.json"); + if (host.fileExists(packageJsonFileName)) { + var info = createPackageJsonInfo(packageJsonFileName, host); + if (info) { + packageJsons.push(info); + } + } + }); + return packageJsons; + } + ts.getPackageJsonsVisibleToFile = getPackageJsonsVisibleToFile; + function createPackageJsonInfo(fileName, host) { + if (!host.readFile) { + return undefined; + } + var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]; + var stringContent = host.readFile(fileName); + var content = stringContent && tryParseJson(stringContent); + if (!content) { + return undefined; + } + var info = {}; + for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) { + var key = dependencyKeys_1[_i]; + var dependencies = content[key]; + if (!dependencies) { + continue; + } + var dependencyMap = ts.createMap(); + for (var packageName in dependencies) { + dependencyMap.set(packageName, dependencies[packageName]); + } + info[key] = dependencyMap; + } + var dependencyGroups = [ + [1 /* Dependencies */, info.dependencies], + [2 /* DevDependencies */, info.devDependencies], + [8 /* OptionalDependencies */, info.optionalDependencies], + [4 /* PeerDependencies */, info.peerDependencies], + ]; + return __assign(__assign({}, info), { fileName: fileName, + get: get, + has: function (dependencyName, inGroups) { + return !!get(dependencyName, inGroups); + } }); + function get(dependencyName, inGroups) { + if (inGroups === void 0) { inGroups = 15 /* All */; } + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; + if (deps && (inGroups & group_1)) { + var dep = deps.get(dependencyName); + if (dep !== undefined) { + return dep; + } + } + } + } + } + ts.createPackageJsonInfo = createPackageJsonInfo; + function tryParseJson(text) { + try { + return JSON.parse(text); + } + catch (_a) { + return undefined; + } + } + function consumesNodeCoreModules(sourceFile) { + return ts.some(sourceFile.imports, function (_a) { + var text = _a.text; + return ts.JsTyping.nodeCoreModules.has(text); + }); + } + ts.consumesNodeCoreModules = consumesNodeCoreModules; + function isInsideNodeModules(fileOrDirectory) { + return ts.contains(ts.getPathComponents(fileOrDirectory), "node_modules"); + } + ts.isInsideNodeModules = isInsideNodeModules; })(ts || (ts = {})); var ts; (function (ts) { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { @@ -100187,36 +104638,36 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; - case 28 /* LessThanToken */: - if (lastNonTriviaToken === 73 /* Identifier */) { + case 29 /* LessThanToken */: + if (lastNonTriviaToken === 75 /* 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 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 121 /* AnyKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: + case 124 /* AnyKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* 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 = 73 /* Identifier */; + token = 75 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -100255,14 +104706,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 73 /* Identifier */; + token = 75 /* 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 = 73 /* Identifier */; + token = 75 /* Identifier */; } } } @@ -100276,19 +104727,19 @@ 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([ - 73 /* Identifier */, + 75 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 101 /* ThisKeyword */, - 44 /* PlusPlusToken */, - 45 /* MinusMinusToken */, + 103 /* ThisKeyword */, + 45 /* PlusPlusToken */, + 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 103 /* TrueKeyword */, - 88 /* FalseKeyword */, + 105 /* TrueKeyword */, + 90 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -100400,10 +104851,10 @@ var ts; return true; } switch (keyword2) { - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 125 /* ConstructorKeyword */: - case 117 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 128 /* ConstructorKeyword */: + case 119 /* 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. @@ -100436,43 +104887,44 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - 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 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* 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 71 /* BarEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 60 /* EqualsToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 50 /* AmpersandToken */: + case 52 /* CaretToken */: + case 51 /* BarToken */: + case 55 /* AmpersandAmpersandToken */: + case 56 /* BarBarToken */: + case 73 /* BarEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: + case 60 /* QuestionQuestionToken */: return true; default: return false; @@ -100480,12 +104932,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: return true; default: return false; @@ -100498,7 +104950,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 72 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 74 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -100517,7 +104969,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 73 /* Identifier */: + case 75 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -100542,10 +104994,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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -100738,6 +105190,11 @@ var ts; return; } } + else if (kind === 2 /* SingleLineCommentTrivia */) { + if (tryClassifyTripleSlashComment(start, width)) { + return; + } + } // Simple comment. Just add as is. pushCommentRange(start, width); } @@ -100758,18 +105215,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 306 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 307 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -100798,6 +105255,70 @@ var ts; } } } + function tryClassifyTripleSlashComment(start, width) { + var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; + var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + var text = sourceFile.text.substr(start, width); + var match = tripleSlashXMLCommentRegEx.exec(text); + if (!match) { + return false; + } + // Limiting classification to exactly the elements and attributes + // defined in `ts.commentPragmas` would be excessive, but we can avoid + // some obvious false positives (e.g. in XML-like doc comments) by + // checking the element name. + // eslint-disable-next-line no-in-operator + if (!match[3] || !(match[3] in ts.commentPragmas)) { + return false; + } + var pos = start; + pushCommentRange(pos, match[1].length); // /// + pos += match[1].length; + pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pos += match[2].length; + pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pos += match[3].length; + var attrText = match[4]; + var attrPos = pos; + while (true) { + var attrMatch = attributeRegex.exec(attrText); + if (!attrMatch) { + break; + } + var newAttrPos = pos + attrMatch.index; + if (newAttrPos > attrPos) { + pushCommentRange(attrPos, newAttrPos - attrPos); + attrPos = newAttrPos; + } + pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[1].length; + if (attrMatch[2].length) { + pushCommentRange(attrPos, attrMatch[2].length); // whitespace + attrPos += attrMatch[2].length; + } + pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = + attrPos += attrMatch[3].length; + if (attrMatch[4].length) { + pushCommentRange(attrPos, attrMatch[4].length); // whitespace + attrPos += attrMatch[4].length; + } + pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[5].length; + } + pos += match[4].length; + if (pos > attrPos) { + pushCommentRange(attrPos, pos - attrPos); + } + if (match[5]) { + pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pos += match[5].length; + } + var end = start + width; + if (pos < end) { + pushCommentRange(pos, end - pos); + } + return true; + } function processJSDocTemplateTag(tag) { for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; @@ -100856,22 +105377,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -100888,7 +105409,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* GreaterThanToken */) { + if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* 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)) { @@ -100898,19 +105419,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 60 /* EqualsToken */) { + if (tokenKind === 62 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 241 /* VariableDeclaration */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 155 /* Parameter */ || + parent.kind === 271 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 208 /* BinaryExpression */ || + parent.kind === 206 /* PrefixUnaryExpression */ || + parent.kind === 207 /* PostfixUnaryExpression */ || + parent.kind === 209 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -100924,7 +105445,7 @@ var ts; } else if (tokenKind === 10 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 271 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -100937,35 +105458,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 73 /* Identifier */) { + else if (tokenKind === 75 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 155 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -101088,11 +105609,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -101100,9 +105621,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 187 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 177 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -101112,7 +105633,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -101129,7 +105650,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -101142,8 +105663,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* 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 @@ -101152,9 +105673,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 263 /* 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*/"); @@ -101198,11 +105719,8 @@ var ts; 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; + 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 }; @@ -101259,7 +105777,7 @@ var ts; return ts.containsPath(rootDirectory, scriptDirectory, basePath, ignoreCase) ? scriptDirectory.substr(rootDirectory.length) : undefined; }); // TODO: GH#18217 // 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); }).concat([scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); + return ts.deduplicate(__spreadArrays(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), [scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); @@ -101292,10 +105810,10 @@ 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)) + if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { /** * Multiple file entries might map to the same truncated name once we remove extensions @@ -101318,7 +105836,7 @@ var ts; }); } // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); + var directories = ts.tryGetDirectories(host, baseDirectory); if (directories) { for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var directory = directories_1[_b]; @@ -101329,7 +105847,7 @@ var ts; } } // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); + var packageJsonPath = ts.findPackageJson(baseDirectory, host); if (packageJsonPath) { var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; @@ -101407,7 +105925,7 @@ var ts; if (!foundGlobal) { ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); - if (tryDirectoryExists(host, nodeModules)) { + if (ts.tryDirectoryExists(host, nodeModules)) { getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); @@ -101457,16 +105975,16 @@ 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 = ts.mapDefined(tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); }); - var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var directories = ts.mapDefined(ts.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); + return __spreadArrays(matches, directories); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); @@ -101514,22 +106032,22 @@ var ts; if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + var typeRoots = ts.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); } // Also get all @types typings installed in visible node_modules directories - for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + for (var _a = 0, _b = ts.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) { - if (!tryDirectoryExists(host, directory)) + if (!ts.tryDirectoryExists(host, directory)) return; - for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.tryGetDirectories(host, directory); _i < _a.length; _i++) { var typeDirectoryName = _a[_i]; var packageName = ts.unmangleScopedPackageName(typeDirectoryName); if (options.types && !ts.contains(options.types, packageName)) @@ -101550,34 +106068,11 @@ var ts; } } } - function findPackageJsons(directory, host) { - var paths = []; - ts.forEachAncestorDirectory(directory, function (ancestor) { - var currentConfigPath = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (!currentConfigPath) { - return true; // break out - } - paths.push(currentConfigPath); - }); - return paths; - } - function findPackageJson(directory, host) { - var packageJson; - ts.forEachAncestorDirectory(directory, function (ancestor) { - if (ancestor === "node_modules") - return true; - packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (packageJson) { - return true; // break out - } - }); - return packageJson; - } function enumerateNodeModulesVisibleToScript(host, scriptPath) { if (!host.readFile || !host.fileExists) return ts.emptyArray; var result = []; - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.findPackageJsons(scriptPath, host); _i < _a.length; _i++) { var packageJson = _a[_i]; var contents = ts.readJson(packageJson, host); // Cast to assert that readFile is defined // Provide completions for all non @types dependencies @@ -101626,33 +106121,6 @@ var ts; */ var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*" 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, 30 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -101825,14 +106352,25 @@ var ts; function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { var insertText; var replacementSpan; - if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; + var insertQuestionDot = origin && originIsNullableMember(origin); + var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; + if (origin && originIsThisType(origin)) { + insertText = needsConvertPropertyAccess + ? "this" + (insertQuestionDot ? "?." : "") + "[" + ts.quote(name, preferences) + "]" + : "this" + (insertQuestionDot ? "?." : ".") + 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 ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); + else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { + insertText = useBraces ? needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]" : name; + if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { + insertText = "?." + insertText; + } + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + if (!dot) { + return undefined; + } // 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); @@ -101845,6 +106383,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -101939,9 +106484,9 @@ var ts; } return entries; } - function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { + function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host) { var compilerOptions = program.getCompilerOptions(); - var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { return { type: "none" }; } @@ -101981,7 +106526,7 @@ var ts; 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); + var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); switch (symbolCompletion.type) { case "request": { var request = symbolCompletion.request; @@ -102037,8 +106582,8 @@ var ts; var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } - function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { - var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host) { + var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); return completion.type === "symbol" ? completion.symbol : undefined; } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; @@ -102071,34 +106616,34 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return checker.getContextualType(parent); - case 75 /* CaseKeyword */: + case 77 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 264 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.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); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -102108,9 +106653,9 @@ 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 === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 288 /* SourceFile */; }); } - function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 @@ -102159,11 +106704,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 312 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 316 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -102199,6 +106744,7 @@ var ts; var node = currentToken; var propertyAccessToConvert; var isRightOfDot = false; + var isRightOfQuestionDot = false; var isRightOfOpenTag = false; var isStartingCloseTag = false; var isJsxInitializer = false; @@ -102210,10 +106756,11 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */) { - isRightOfDot = true; + if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -102225,14 +106772,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 187 /* ImportType */: + case 218 /* MetaProperty */: node = parent; break; default: @@ -102245,56 +106792,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 === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 193 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + case 31 /* GreaterThanToken */: + if (currentToken.parent.kind === 264 /* JsxElement */ || currentToken.parent.kind === 266 /* JsxOpeningElement */) { location = currentToken; } break; - case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + case 43 /* SlashToken */: + if (currentToken.parent.kind === 265 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: - if (contextToken.kind === 42 /* SlashToken */) { + case 267 /* JsxClosingElement */: + if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: - if (contextToken.kind === 28 /* LessThanToken */) { + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: + case 266 /* JsxOpeningElement */: + if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: switch (previousToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: isJsxInitializer = true; break; - case 73 /* Identifier */: + case 75 /* 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, 60 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 62 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -102309,7 +106856,8 @@ var ts; var symbols = []; var symbolToOriginInfoMap = []; var symbolToSortTextMap = []; - if (isRightOfDot) { + var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { @@ -102359,11 +106907,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 311 /* JSDocTypedefTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 315 /* JSDocTypedefTag */: return true; default: return false; @@ -102407,24 +106955,40 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 288 /* SourceFile */ && d.kind !== 248 /* ModuleDeclaration */ && d.kind !== 247 /* EnumDeclaration */; })) { + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + insertQuestionDot = isRightOfDot && !isRightOfQuestionDot; + type = type.getNonNullableType(); + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 96 /* NewKeyword */ || node.keywordToken === 93 /* ImportKeyword */)) { - var completion = (node.keywordToken === 96 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 98 /* NewKeyword */ || node.keywordToken === 95 /* ImportKeyword */)) { + var completion = (node.keywordToken === 98 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + var type = typeChecker.getTypeAtLocation(node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + insertQuestionDot = isRightOfDot && !isRightOfQuestionDot; + type = type.getNonNullableType(); + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait, insertQuestionDot) { isNewIdentifierLocation = !!type.getStringIndexType(); + if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { + isNewIdentifierLocation = true; + } + var propertyAccess = node.kind === 187 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -102436,13 +107000,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { - addPropertySymbol(symbol); + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { + addPropertySymbol(symbol, /*insertAwait*/ false, insertQuestionDot); + } + } + } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true, insertQuestionDot); + } } } } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait, insertQuestionDot) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -102456,15 +107031,32 @@ var ts; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) + ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } + : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addSymbolOriginInfo(symbol); symbols.push(symbol); } + function addSymbolOriginInfo(symbol) { + if (preferences.includeCompletionsWithInsertText) { + if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + } + else if (insertQuestionDot) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + } + } + } + function getNullableSymbolOriginInfoKind(kind) { + return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -102497,6 +107089,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -102540,7 +107133,7 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); var isTypeOnly = isTypeOnlyCompletion(); - var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; @@ -102550,19 +107143,38 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 288 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ }; + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; } } } if (shouldOfferImportCompletions()) { - getSymbolsFromOtherSourceFileExports(symbols, previousToken && ts.isIdentifier(previousToken) ? previousToken.text : "", program.getCompilerOptions().target); + var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); + if (!detailsEntryId && importSuggestionsCache) { + importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); + } + autoImportSuggestions.forEach(function (_a) { + var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; + if (detailsEntryId) { + if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { + return; + } + } + else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { + return; + } + var symbolId = ts.getSymbolId(symbol); + symbols.push(symbol); + symbolToOriginInfoMap[symbolId] = origin; + symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; + }); } filterGlobalCompletion(symbols); } @@ -102584,10 +107196,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 210 /* TemplateExpression */: + case 274 /* JsxExpression */: + case 222 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -102617,7 +107229,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 67220415 /* Value */); + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); }); } function isTypeAssertion() { @@ -102632,28 +107244,28 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 107 /* TypeOfKeyword */ && + (contextToken.parent.kind === 171 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + case 58 /* ColonToken */: + return parentKind === 158 /* PropertyDeclaration */ || + parentKind === 157 /* PropertySignature */ || + parentKind === 155 /* Parameter */ || + parentKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; - case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; - case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; - case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + case 62 /* EqualsToken */: + return parentKind === 246 /* TypeAliasDeclaration */; + case 122 /* AsKeyword */: + return parentKind === 216 /* AsExpression */; + case 29 /* LessThanToken */: + return parentKind === 168 /* TypeReference */ || + parentKind === 198 /* TypeAssertionExpression */; + case 89 /* ExtendsKeyword */: + return parentKind === 154 /* TypeParameter */; } } return false; @@ -102662,15 +107274,76 @@ var ts; function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { if (seenModules === void 0) { seenModules = ts.createMap(); } var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 67897832 /* Type */) || + return !!(sym.flags & 788968 /* 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(); + /** + * Gathers symbols that can be imported from other files, deduplicating along the way. Symbols can be “duplicates” + * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but + * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, + * if and only if the the first can be imported (it may be excluded due to package.json filtering in + * `codefix.forEachExternalModuleToImportFrom`). + * + * Example. Imagine a chain of node_modules re-exporting one original symbol: + * + * ```js + * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js + * +-----------------------+ +--------------------------+ +--------------------------+ + * | | | | | | + * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | + * | | | | | | + * +-----------------------+ +--------------------------+ +--------------------------+ + * ``` + * + * Also imagine three buckets, which we’ll reference soon: + * + * ```md + * | | | | | | + * | **Bucket A** | | **Bucket B** | | **Bucket C** | + * | Symbols to | | Aliases to symbols | | Symbols to return | + * | definitely | | in Buckets A or C | | if nothing better | + * | return | | (don’t return these) | | comes along | + * |__________________| |______________________| |___________________| + * ``` + * + * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it + * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not + * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we + * may not be sure whether or not it should go in the list. So, we’ll take the following steps: + * + * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is + * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B + * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. + * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. + * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' + * should never be returned in the final list, so put it in Bucket B. + * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so + * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. + * Put this symbol in Bucket A. + * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t + * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move + * everything from Bucket C to Bucket A. + */ + function getSymbolsFromOtherSourceFileExports(target, host) { + var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); + if (cached) { + log("getSymbolsFromOtherSourceFileExports: Using cached list"); + return cached; + } + var startTime = ts.timestamp(); + log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); var seenResolvedModules = ts.createMap(); - ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + /** Bucket B */ + var aliasesToAlreadyIncludedSymbols = ts.createMap(); + /** Bucket C */ + var aliasesToReturnIfOriginalsAreMissing = ts.createMap(); + /** Bucket A */ + var results = []; + /** Ids present in `results` for faster lookup */ + var resultSymbolIds = ts.createMap(); + ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, function (moduleSymbol) { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; @@ -102680,41 +107353,75 @@ var ts; if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { return; } + // Don't add another completion for `export =` of a symbol that's already global. + // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. if (resolvedModuleSymbol !== moduleSymbol && - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { - symbols.push(resolvedModuleSymbol); - symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { + pushSymbol(resolvedModuleSymbol, moduleSymbol, /*skipFilter*/ true); } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; - // Don't add a completion for a re-export, only for the original. - // 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 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) { - // 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); - })) { + // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. + if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { continue; } - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + var symbolId = ts.getSymbolId(symbol).toString(); + // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. + var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; + // 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). + if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { + // Walk the export chain back one module (step 1 or 2 in diagrammed example). + // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. + var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); + if (!nearestExportSymbol) + continue; + var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); + var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); + if (!symbolHasBeenSeen) { + aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol }); + aliasesToAlreadyIncludedSymbols.set(symbolId, true); + } + else { + // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here + // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. + ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); + } } - var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; - if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) { - symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin; + else { + // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.delete(symbolId); + pushSymbol(symbol, moduleSymbol); } } }); + // By this point, any potential duplicates that were actually duplicates have been + // removed, so the rest need to be added. (Step 4 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { + var alias = _a.alias, moduleSymbol = _a.moduleSymbol; + return pushSymbol(alias, moduleSymbol); + }); + log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); + return results; + function pushSymbol(symbol, moduleSymbol, skipFilter) { + if (skipFilter === void 0) { skipFilter = false; } + var isDefaultExport = symbol.escapedName === "default" /* Default */; + if (isDefaultExport) { + symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + } + ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); + var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; + results.push({ + symbol: symbol, + symbolName: getSymbolName(symbol, origin, target), + origin: origin, + skipFilter: skipFilter, + }); + } + } + function getNearestExportSymbol(fromSymbol) { + return findAlias(typeChecker, fromSymbol, function (alias) { + return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); + }); } /** * True if you could remove some characters in `a` to get `b`. @@ -102761,12 +107468,12 @@ var ts; if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 266 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 267 /* JsxClosingElement */ || contextToken.parent.kind === 265 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 264 /* JsxElement */; } } return false; @@ -102777,40 +107484,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 195 /* CallExpression */ // func( a, | + || containingNodeKind === 161 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 196 /* NewExpression */ // new C(a, | + || containingNodeKind === 191 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 208 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 169 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 195 /* CallExpression */ // func( | + || containingNodeKind === 161 /* Constructor */ // constructor( | + || containingNodeKind === 196 /* NewExpression */ // new C(a| + || containingNodeKind === 199 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 181 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 131 /* ModuleKeyword */: // module | - case 132 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 191 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 166 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 153 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 134 /* ModuleKeyword */: // module | + case 135 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 248 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | - case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 244 /* ClassDeclaration */; // class A{ | + case 62 /* EqualsToken */: + return containingNodeKind === 241 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 208 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 210 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 220 /* TemplateSpan */; // `aa ${10} dd ${| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -102837,7 +107544,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 192 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; @@ -102846,7 +107553,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 188 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -102857,12 +107564,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 === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 231 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 155 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 160 /* MethodDeclaration */ || rootDeclaration.parent.kind === 163 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -102879,6 +107586,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -102904,7 +107612,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 256 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -102927,15 +107635,15 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 41 /* 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)) return 1 /* Success */; - var classElement = contextToken.parent; + var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : 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 === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 75 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -102970,9 +107678,9 @@ var ts; return parent; } break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 73 /* Identifier */: + case 75 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -103022,23 +107730,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 30 /* GreaterThanToken */: // End of a type argument list - case 29 /* LessThanSlashToken */: - case 42 /* SlashToken */: - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { - if (contextToken.kind === 30 /* GreaterThanToken */) { + case 31 /* GreaterThanToken */: // End of a type argument list + case 30 /* LessThanSlashToken */: + case 43 /* SlashToken */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 272 /* JsxAttributes */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 265 /* JsxSelfClosingElement */ || parent.kind === 266 /* JsxOpeningElement */)) { + if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) break; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103050,7 +107758,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 271 /* JsxAttribute */) || (parent.kind === 273 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103060,8 +107768,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 274 /* JsxExpression */ && + parent.parent && parent.parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103069,7 +107777,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 273 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103089,64 +107797,64 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 241 /* VariableDeclaration */ || + containingNodeKind === 242 /* VariableDeclarationList */ || + containingNodeKind === 224 /* VariableStatement */ || + containingNodeKind === 247 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| - case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [.| + case 58 /* ColonToken */: + return containingNodeKind === 190 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 278 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | - case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 247 /* EnumDeclaration */; // enum a { | + case 29 /* LessThanToken */: + return containingNodeKind === 244 /* ClassDeclaration */ || // class A< | + containingNodeKind === 213 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 245 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 246 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 119 /* StaticKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + return containingNodeKind === 155 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 189 /* ArrayBindingPattern */); // var [...z| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 155 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 122 /* AsKeyword */: + return containingNodeKind === 257 /* ImportSpecifier */ || + containingNodeKind === 261 /* ExportSpecifier */ || + containingNodeKind === 255 /* NamespaceImport */; + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 111 /* InterfaceKeyword */: - case 91 /* FunctionKeyword */: - case 106 /* VarKeyword */: - case 93 /* ImportKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 118 /* YieldKeyword */: - case 141 /* TypeKeyword */: // type htm| + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 113 /* InterfaceKeyword */: + case 93 /* FunctionKeyword */: + case 108 /* VarKeyword */: + case 95 /* ImportKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 120 /* YieldKeyword */: + case 144 /* TypeKeyword */: // type htm| return true; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -103167,22 +107875,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 119 /* AbstractKeyword */: - case 77 /* ClassKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 91 /* FunctionKeyword */: - case 111 /* InterfaceKeyword */: - case 112 /* LetKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 117 /* StaticKeyword */: - case 106 /* VarKeyword */: - case 118 /* YieldKeyword */: + case 121 /* AbstractKeyword */: + case 79 /* ClassKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 93 /* FunctionKeyword */: + case 113 /* InterfaceKeyword */: + case 114 /* LetKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 119 /* StaticKeyword */: + case 108 /* VarKeyword */: + case 120 /* YieldKeyword */: return true; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -103192,7 +107900,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 161 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -103211,16 +107919,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); 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 !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 279 /* PropertyAssignment */ && + m.kind !== 280 /* ShorthandPropertyAssignment */ && + m.kind !== 190 /* BindingElement */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */ && + m.kind !== 281 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103228,9 +107938,12 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 73 /* Identifier */) { + if (m.propertyName.kind === 75 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -103243,7 +107956,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -103255,10 +108001,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 !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 158 /* PropertyDeclaration */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103292,17 +108038,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 271 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -103313,7 +108065,7 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.startsWithQuote(name) + || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; @@ -103342,7 +108094,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 76 /* FirstKeyword */; i <= 151 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -103368,9 +108120,9 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 126 /* DeclareKeyword */ - || kind === 131 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 142 /* UndefinedKeyword */; + || kind === 129 /* DeclareKeyword */ + || kind === 134 /* ModuleKeyword */ + || ts.isTypeKeyword(kind) && kind !== 145 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -103380,7 +108132,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 78 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 80 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -103390,55 +108142,55 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 121 /* AnyKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 146 /* GlobalKeyword */: - case 110 /* ImplementsKeyword */: - case 128 /* InferKeyword */: - case 111 /* InterfaceKeyword */: - case 129 /* IsKeyword */: - case 130 /* KeyOfKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 133 /* NeverKeyword */: - case 136 /* NumberKeyword */: - case 137 /* ObjectKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: - case 139 /* StringKeyword */: - case 140 /* SymbolKeyword */: - case 141 /* TypeKeyword */: - case 143 /* UniqueKeyword */: - case 144 /* UnknownKeyword */: + case 121 /* AbstractKeyword */: + case 124 /* AnyKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 149 /* GlobalKeyword */: + case 112 /* ImplementsKeyword */: + case 131 /* InferKeyword */: + case 113 /* InterfaceKeyword */: + case 132 /* IsKeyword */: + case 133 /* KeyOfKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 136 /* NeverKeyword */: + case 139 /* NumberKeyword */: + case 140 /* ObjectKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: + case 142 /* StringKeyword */: + case 143 /* SymbolKeyword */: + case 144 /* TypeKeyword */: + case 146 /* UniqueKeyword */: + case 147 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 134 /* ReadonlyKeyword */; + return kind === 137 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 125 /* ConstructorKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 122 /* AsyncKeyword */: + case 121 /* AbstractKeyword */: + case 128 /* ConstructorKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 125 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 122 /* AsyncKeyword */ - || kind === 123 /* AwaitKeyword */ + return kind === 125 /* AsyncKeyword */ + || kind === 126 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -103476,7 +108228,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 313 /* SyntaxList */: + case 317 /* 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); @@ -103484,7 +108236,7 @@ var ts; return cls; } break; - case 73 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } + case 75 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } if (isFromObjectTypeDeclaration(location)) { return ts.findAncestor(location, ts.isObjectTypeDeclaration); } @@ -103510,7 +108262,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -103530,11 +108282,11 @@ var ts; return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -103543,6 +108295,14 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } + function findAlias(typeChecker, symbol, predicate) { + var currentAlias = symbol; + while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { + if (predicate(currentAlias)) { + return currentAlias; + } + } + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -103595,40 +108355,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 92 /* IfKeyword */: - case 84 /* ElseKeyword */: + case 94 /* IfKeyword */: + case 86 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 98 /* ReturnKeyword */: + case 100 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 104 /* TryKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: - var tryStatement = node.kind === 76 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 106 /* TryKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: + var tryStatement = node.kind === 78 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 75 /* CaseKeyword */: - case 81 /* DefaultKeyword */: + case 77 /* CaseKeyword */: + case 83 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 74 /* BreakKeyword */: - case 79 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 81 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 90 /* ForKeyword */: - case 108 /* WhileKeyword */: - case 83 /* DoKeyword */: + case 92 /* ForKeyword */: + case 110 /* WhileKeyword */: + case 85 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 125 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [125 /* ConstructorKeyword */]); - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [127 /* GetKeyword */, 138 /* SetKeyword */]); - case 123 /* AwaitKeyword */: + case 128 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [128 /* ConstructorKeyword */]); + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [130 /* GetKeyword */, 141 /* SetKeyword */]); + case 126 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 118 /* YieldKeyword */: + case 120 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -103671,7 +108431,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 288 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -103703,16 +108463,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 236 /* SwitchStatement */: + if (statement.kind === 232 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -103728,35 +108488,37 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 222 /* Block */: + case 275 /* CaseClause */: + case 276 /* 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]); + return __spreadArrays(declaration.members, [declaration]); } else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 172 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 28 /* AccessibilityModifier */) { + if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { - return nodes.concat(constructor.parameters); + return __spreadArrays(nodes, constructor.parameters); } } else if (modifierFlag & 128 /* Abstract */) { - return nodes.concat([container]); + return __spreadArrays(nodes, [container]); } return nodes; default: @@ -103776,12 +108538,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 92 /* ForKeyword */, 110 /* WhileKeyword */, 85 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 227 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 110 /* WhileKeyword */)) { break; } } @@ -103789,7 +108551,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */, 79 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */, 81 /* ContinueKeyword */); } }); return keywords; @@ -103798,13 +108560,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -103812,13 +108574,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 100 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 102 /* 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(), 75 /* CaseKeyword */, 81 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 77 /* CaseKeyword */, 83 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */); } }); }); @@ -103826,13 +108588,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 104 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 106 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 76 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 78 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 89 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 91 /* FinallyKeyword */); } return keywords; } @@ -103843,13 +108605,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* 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, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -103861,11 +108623,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* 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, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -103877,13 +108639,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 122 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 125 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 123 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 126 /* AwaitKeyword */); } }); }); @@ -103898,7 +108660,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 118 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 120 /* YieldKeyword */); } }); }); @@ -103917,7 +108679,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 === 84 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 86 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -103952,10 +108714,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], 92 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 94 /* 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], 84 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 86 /* ElseKeyword */)) { break; } } @@ -104171,12 +108933,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 241 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { directImports.push(name); break; } @@ -104185,22 +108947,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 73 /* Identifier */: // for 'const x = require("y"); + case 75 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 255 /* 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 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -104210,7 +108972,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 187 /* ImportType */: directImports.push(direct); break; default: @@ -104227,7 +108989,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 288 /* SourceFile */ || sourceFileLike.kind === 248 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -104282,17 +109044,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 252 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 73 /* Identifier */) { + if (decl.kind === 75 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 187 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -104307,17 +109069,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 259 /* 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 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -104367,7 +109129,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 261 /* 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); @@ -104396,7 +109158,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 === 285 /* SourceFile */) { + if (searchSourceFile.kind === 288 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -104444,7 +109206,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 === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 288 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -104459,15 +109221,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -104481,7 +109243,7 @@ var ts; /** * Given a local reference, we might notice that it's an import/export and recursively search for references of that. * If at an import, look locally for the symbol it imports. - * If an an export, look for all imports of it. + * If at an export, look for all imports of it. * This doesn't handle export specifiers; that is done in `getReferencesAtExportSpecifier`. * @param comingFromExport If we are doing a search for all exports, don't bother looking backwards for the imported symbol, since that's the reason we're here. */ @@ -104491,7 +109253,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 193 /* 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) @@ -104613,10 +109375,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 === 238 /* VariableDeclaration */) { - var p = parent; - return p.name !== node ? undefined : - p.parent.kind === 275 /* CatchClause */ ? undefined : p.parent.parent.kind === 220 /* VariableStatement */ ? p.parent.parent : undefined; + var declaration = ts.isVariableDeclaration(parent) ? parent : ts.isBindingElement(parent) ? ts.walkUpBindingElementsAndPatterns(parent) : undefined; + if (declaration) { + return parent.name !== node ? undefined : + ts.isCatchClause(declaration.parent) ? undefined : ts.isVariableStatement(declaration.parent.parent) ? declaration.parent.parent : undefined; } else { return parent; @@ -104625,13 +109387,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -104664,21 +109426,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 288 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 249 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 248 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 263 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -104727,7 +109489,7 @@ var ts; if (ts.isInJSFile(node)) { var binaryExpression = ts.isBinaryExpression(node.parent) ? node.parent : - ts.isPropertyAccessExpression(node.parent) && + ts.isAccessExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && node.parent.parent.left === node.parent ? node.parent.parent : @@ -104771,7 +109533,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 81 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 83 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -104780,7 +109542,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -104788,27 +109550,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -104852,18 +109614,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* 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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 99 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 101 /* 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); @@ -104943,16 +109705,16 @@ var ts; return { displayParts: displayParts, kind: symbolKind }; } function toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixText) { - return __assign({}, entryToDocumentSpan(entry), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); + return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); } FindAllReferences.toRenameLocation = toRenameLocation; function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); if (entry.kind === 0 /* Span */) { - return __assign({}, documentSpan, { isWriteAccess: false, isDefinition: false }); + return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign({}, documentSpan, { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 83 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -104996,10 +109758,10 @@ var ts; var documentSpan = entryToDocumentSpan(entry); if (entry.kind !== 0 /* Span */) { var node = entry.node; - return __assign({}, documentSpan, implementationKindDisplayParts(node, checker)); + return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign({}, documentSpan, { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -105007,13 +109769,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 213 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -105042,7 +109804,7 @@ var ts; function getTextSpan(node, sourceFile, endNode) { var start = node.getStart(sourceFile); var end = (endNode || node).getEnd(); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { ts.Debug.assert(endNode === undefined); start += 1; end -= 1; @@ -105057,7 +109819,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 === 81 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 83 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -105065,49 +109827,49 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 4194304 /* Ambient */)) + if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 208 /* BinaryExpression */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 83 /* DefaultKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 261 /* ExportSpecifier */: + case 254 /* ImportClause */: // default import + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 245 /* InterfaceDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 271 /* JsxAttribute */: + case 248 /* ModuleDeclaration */: + case 251 /* NamespaceExportDeclaration */: + case 255 /* NamespaceImport */: + case 155 /* Parameter */: + case 280 /* ShorthandPropertyAssignment */: + case 246 /* TypeAliasDeclaration */: + case 154 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 159 /* MethodSignature */: + case 157 /* PropertySignature */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -105267,10 +110029,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 288 /* 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 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -105287,21 +110049,32 @@ var ts; 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, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 88 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } + /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ + function isReadonlyTypeOperator(node) { + return node.kind === 137 /* ReadonlyKeyword */ + && ts.isTypeOperatorNode(node.parent) + && node.parent.operator === 137 /* ReadonlyKeyword */; + } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + // A modifier readonly (like on a property declaration) is not special; + // a readonly type keyword (like `readonly string[]`) is. + if (node.kind === 137 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + return undefined; + } + // Likewise, when we *are* looking for a special keyword, make sure we + // *don’t* include readonly member modifiers. + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 137 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -105317,7 +110090,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -105334,7 +110107,7 @@ var ts; // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 81 /* DefaultKeyword */) { + else if (node && node.kind === 83 /* 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); } @@ -105362,9 +110135,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: return 1 /* Constructor */; - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -105600,7 +110373,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 === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 200 /* FunctionExpression */ || valueDeclaration.kind === 213 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -105610,7 +110383,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, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 244 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -105639,7 +110412,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 288 /* 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; @@ -105660,7 +110433,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -105747,8 +110520,9 @@ 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 73 /* Identifier */: + case 75 /* Identifier */: return node.text.length === searchSymbolName.length; + case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && @@ -105756,17 +110530,19 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 81 /* DefaultKeyword */: + case 83 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; } } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, ts.tokenToString(keywordKind), sourceFile), function (referenceLocation) { - return referenceLocation.kind === keywordKind ? FindAllReferences.nodeEntry(referenceLocation) : undefined; + if (referenceLocation.kind === keywordKind && (!filter || filter(referenceLocation))) { + return FindAllReferences.nodeEntry(referenceLocation); + } }); }); return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; @@ -105820,7 +110596,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 73 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 75 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -105876,8 +110652,8 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 81 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 81 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 83 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 83 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.assertDefined(exportSpecifier.symbol); var exportInfo = ts.Debug.assertDefined(FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker)); @@ -105940,7 +110716,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -105956,7 +110732,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 81 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 83 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -105983,7 +110759,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 101 /* ThisKeyword */) { + if (node.kind === 103 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -106002,18 +110778,18 @@ var ts; if (constructorSymbol) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 128 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 161 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 160 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 103 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -106034,10 +110810,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 161 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 101 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -106061,10 +110837,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 73 /* Identifier */) { + if (refNode.kind !== 75 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 280 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -106084,7 +110860,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 222 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -106112,13 +110888,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 191 /* ArrayLiteralExpression */: return true; default: return false; @@ -106171,13 +110947,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -106186,7 +110962,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 99 /* SuperKeyword */) { + if (node.kind !== 101 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -106198,41 +110974,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 75 /* Identifier */ && node.parent.kind === 155 /* Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 288 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -106240,19 +111016,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* 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 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 288 /* SourceFile */: + return container.kind === 288 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -106329,7 +111105,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -106371,7 +111147,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 190 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -106421,11 +111197,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 8388608 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -106475,12 +111250,12 @@ var ts; /* @internal */ var ts; (function (ts) { - function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, _preferences, sourceMapper) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences, sourceMapper) { var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); 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) { + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, function (changeTracker) { updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); @@ -106728,9 +111503,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 101 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -106738,7 +111513,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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -106891,35 +111666,39 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 73 /* Identifier */) { + if (node.kind !== 75 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 257 /* ImportSpecifier */: + return declaration.parent.kind === 256 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(symbol.declarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { + // There are cases when you extend a function by adding properties to it afterwards, + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); 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 === 125 /* ConstructorKeyword */)) { - var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 128 /* ConstructorKeyword */)) { + var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } } function getCallSignatureDefinition() { return ts.isCallOrNewExpressionTarget(node) || ts.isNameOfFunctionDeclaration(node) - ? getSignatureDefinition(symbol.declarations, /*selectConstructors*/ false) + ? getSignatureDefinition(filteredDeclarations, /*selectConstructors*/ false) : undefined; } function getSignatureDefinition(signatureDeclarations, selectConstructors) { @@ -106927,8 +111706,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -106981,9 +111764,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return true; default: return false; @@ -107101,11 +111884,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return [declaration]; - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -107126,16 +111909,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return withNode(tag.class); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -107312,7 +112095,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 === 73 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 75 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -107322,23 +112105,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 159 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 157 /* PropertySignature */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 246 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -107346,14 +112129,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 288 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 248 /* 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 === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 248 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 208 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -107372,14 +112155,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 199 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 213 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -107441,9 +112224,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -107453,7 +112236,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 153 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -107470,7 +112253,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 === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 153 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -107514,6 +112297,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -107528,6 +112312,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -107538,13 +112327,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -107570,7 +112361,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -107595,28 +112386,56 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isPropertyNameLiteral(entityName)) { + var name = ts.getNameOrArgument(entityName); + var nameText = ts.getElementOrPropertyAccessName(entityName); + entityName = entityName.expression; + if (nameText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -107626,46 +112445,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* 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); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 159 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -107677,90 +112498,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 280 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 281 /* SpreadAssignment */: + var expression = node.expression; + // Use the expression as the name of the SpreadAssignment, otherwise show as . + ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); + break; + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: + case 241 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } + addNodeWithRecursiveChild(node, node.body); + break; + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 261 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 166 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 246 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && ts.getElementOrPropertyAccessName(assignmentTarget) !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else if (ts.isBindableStaticAccessExpression(assignmentTarget)) { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, ts.getNameOrArgument(assignmentTarget)); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -107783,8 +112682,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -107798,7 +112697,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -107807,7 +112706,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -107815,7 +112714,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -107828,12 +112820,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -107849,7 +112841,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 !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 248 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -107879,7 +112871,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 248 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -107887,35 +112879,37 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 248 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text + : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -107923,24 +112917,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 164 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -107950,28 +112947,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 246 /* TypeAliasDeclaration */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -107981,21 +112978,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -108008,18 +112999,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -108050,7 +113041,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 === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -108064,13 +113055,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 153 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 288 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 241 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -108078,14 +113069,14 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(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 === 60 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -108102,7 +113093,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -108123,14 +113118,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -108144,8 +113149,8 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, _preferences) { - var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext }); + function organizeImports(sourceFile, formatContext, host, program, preferences) { + var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); var coalesceAndOrganizeImports = function (importGroup) { return coalesceImports(removeUnusedImports(importGroup, sourceFile, program)); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); @@ -108473,7 +113478,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 93 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 95 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -108590,7 +113595,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -108598,23 +113603,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 227 /* DoStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 278 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 239 /* 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, 89 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -108622,24 +113627,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 250 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -108681,7 +113686,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 201 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -109216,10 +114221,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 126 /* DeclareKeyword */) { + if (token === 129 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 131 /* ModuleKeyword */) { + if (token === 134 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -109237,7 +114242,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 93 /* ImportKeyword */) { + if (token === 95 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -109253,9 +114258,9 @@ var ts; return true; } else { - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -109263,7 +114268,7 @@ var ts; return true; } } - else if (token === 60 /* EqualsToken */) { + else if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -109286,7 +114291,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -109296,13 +114301,13 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 120 /* AsKeyword */) { + if (token === 122 /* AsKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -109320,7 +114325,7 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 86 /* ExportKeyword */) { + if (token === 88 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); if (token === 18 /* OpenBraceToken */) { @@ -109332,7 +114337,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -109342,9 +114347,9 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -109352,11 +114357,11 @@ var ts; } } } - else if (token === 93 /* ImportKeyword */) { + else if (token === 95 /* ImportKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 60 /* EqualsToken */) { + if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -109369,7 +114374,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 135 /* RequireKeyword */) { + if (token === 138 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -109384,7 +114389,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 73 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 75 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -109518,14 +114523,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 === 81 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 83 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 153 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -109572,7 +114577,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { // Exclude the quotes start += 1; width -= 2; @@ -109581,9 +114586,10 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -109614,7 +114620,7 @@ var ts; if (node.getStart(sourceFile) > pos) { break outer; } - if (positionShouldSnapToNode(pos, node, nextNode)) { + if (positionShouldSnapToNode(sourceFile, pos, node)) { // 1. Blocks are effectively redundant with SyntaxLists. // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping // of things that should be considered independently. @@ -109623,7 +114629,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -109686,12 +114692,11 @@ var ts; * count too, unless that position belongs to the next node. In effect, makes * selections able to snap to preceding tokens when the cursor is on the tail * end of them with only whitespace ahead. + * @param sourceFile The source file containing the nodes. * @param pos The position to check. * @param node The candidate node to snap to. - * @param nextNode The next sibling node in the tree. - * @param sourceFile The source file containing the nodes. */ - function positionShouldSnapToNode(pos, node, nextNode) { + function positionShouldSnapToNode(sourceFile, pos, node) { // Can’t use 'ts.positionBelongsToNode()' here because it cleverly accounts // for missing nodes, which can’t really be considered when deciding what // to select. @@ -109700,9 +114705,8 @@ var ts; return true; } var nodeEnd = node.getEnd(); - var nextNodeStart = nextNode && nextNode.getStart(); if (nodeEnd === pos) { - return pos !== nextNodeStart; + return ts.getTouchingPropertyName(sourceFile, pos).pos < node.end; } return false; } @@ -109737,14 +114741,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 134 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 56 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 137 /* ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 154 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -109752,7 +114756,7 @@ var ts; // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; })), closeBraceToken, ]; @@ -109764,7 +114768,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -109777,14 +114781,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } return node.getChildren(); @@ -109851,7 +114855,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(313 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(317 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -109860,14 +114864,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 266 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 267 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -109960,7 +114964,7 @@ var ts; var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -110019,7 +115023,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* 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 }; @@ -110072,10 +115076,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 197 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 210 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -110142,17 +115146,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 199 /* ParenthesizedExpression */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* 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 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -110223,11 +115227,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -110276,7 +115280,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 === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -110341,14 +115345,14 @@ 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(28 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(29 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } 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); - var suffixDisplayParts = suffix.concat(returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); + var prefixDisplayParts = __spreadArrays(callTargetDisplayParts, prefix); + var suffixDisplayParts = __spreadArrays(suffix, returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); var documentation = candidateSignature.getDocumentationComment(checker); var tags = candidateSignature.getJsDocTags(); return { isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; @@ -110372,10 +115376,10 @@ var ts; var parameters = (typeParameters || ts.emptyArray).map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -110387,7 +115391,7 @@ var ts; } }); var parameters = checker.getExpandedParameters(candidateSignature).map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: __spreadArrays(typeParameterParts, [ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -110451,6 +115455,10 @@ var ts; if (!sourceFile) return undefined; var program = host.getProgram(); + // If this is source file of project reference source (instead of redirect) there is no generated position + if (program.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) { + return undefined; + } var options = program.getCompilerOptions(); var outPath = options.outFile || options.out; var declarationPath = outPath ? @@ -110588,7 +115596,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -110598,7 +115606,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 243 /* 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)); @@ -110631,11 +115639,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -110652,12 +115660,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 255 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -110715,13 +115723,13 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ - case 97 /* NullKeyword */: - case 73 /* Identifier */: // identifier includes undefined + // falls through + case 99 /* NullKeyword */: + case 75 /* Identifier */: // identifier includes undefined return true; default: return false; @@ -110744,7 +115752,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -110781,7 +115789,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 101 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 103 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -110832,11 +115840,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 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + return location.kind === 75 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 271 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -110863,13 +115871,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 === 101 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 103 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 101 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(101 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 103 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(103 /* 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 */) { @@ -110879,7 +115887,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 193 /* 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)) { @@ -110899,7 +115907,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 196 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 101 /* 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 @@ -110917,7 +115925,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -110934,14 +115942,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(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* 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(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -110954,29 +115962,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 128 /* ConstructorKeyword */ && location.parent.kind === 161 /* 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 === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 128 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 161 /* 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 === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 161 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 164 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -110986,7 +115994,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 213 /* 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 @@ -110994,7 +116002,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(77 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(79 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -111002,37 +116010,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(111 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(113 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* 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(78 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(80 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(85 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(87 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 248 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 75 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 135 /* NamespaceKeyword */ : 134 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -111051,7 +116059,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 154 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -111059,21 +116067,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + if (declaration.kind === 165 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 164 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 246 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -111085,11 +116093,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 282 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -111115,32 +116123,32 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 251 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(135 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 258 /* ExportAssignment */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 83 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 261 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(93 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(95 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 252 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(135 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(138 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -111149,7 +116157,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -111163,7 +116171,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(101 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(103 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -111174,7 +116182,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -111212,10 +116220,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 === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 288 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 208 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -111258,7 +116266,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(94 /* InKeyword */)); + displayParts.push(ts.keywordPart(96 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -111268,7 +116276,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(56 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -111303,7 +116311,7 @@ var ts; if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(38 /* PlusToken */)); + displayParts.push(ts.operatorPart(39 /* 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")); @@ -111328,16 +116336,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 200 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 241 /* VariableDeclaration */ && declaration.kind !== 243 /* 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 === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 288 /* SourceFile */ || parent.kind === 249 /* ModuleBlock */) { return false; } } @@ -111360,32 +116368,24 @@ var ts; */ function transpileModule(input, transpileOptions) { var diagnostics = []; - var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : ts.getDefaultCompilerOptions(); - options.isolatedModules = true; + var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {}; + // mix in default options + var defaultOptions = ts.getDefaultCompilerOptions(); + for (var key in defaultOptions) { + if (ts.hasProperty(defaultOptions, key) && options[key] === undefined) { + options[key] = defaultOptions[key]; + } + } + for (var _i = 0, transpileOptionValueCompilerOptions_1 = ts.transpileOptionValueCompilerOptions; _i < transpileOptionValueCompilerOptions_1.length; _i++) { + var option = transpileOptionValueCompilerOptions_1[_i]; + options[option.name] = option.transpileOptionValue; + } // transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths. options.suppressOutputPathCheck = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, - // so pass --noLib to avoid reporting a file not found error. - options.noLib = true; - // Clear out other settings that would not be used in transpiling this module - options.lib = undefined; - options.types = undefined; - options.noEmit = undefined; - options.noEmitOnError = undefined; - options.paths = undefined; - options.rootDirs = undefined; - options.declaration = undefined; - options.composite = undefined; - options.declarationDir = undefined; - options.out = undefined; - options.outFile = undefined; - // We are not doing a full typecheck, we are not resolving the whole context, - // so pass --noResolve to avoid reporting missing file errors. - options.noResolve = true; // if jsx is specified then treat file as .tsx - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -111590,7 +116590,9 @@ var ts; var res = cb({ advance: advance, readTokenInfo: readTokenInfo, + readEOFTokenRange: readEOFTokenRange, isOnToken: isOnToken, + isOnEOF: isOnEOF, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, @@ -111630,11 +116632,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 32 /* GreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -111642,12 +116644,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 271 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* 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 === 73 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 75 /* Identifier */; } } return false; @@ -111663,23 +116665,18 @@ var ts; container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 42 /* SlashToken */ || t === 65 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -111696,11 +116693,7 @@ var ts; scanner.scan(); } var currentToken = getNextToken(n, expectedScanAction); - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var token = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); // consume trailing trivia if (trailingTrivia) { trailingTrivia = undefined; @@ -111710,11 +116703,7 @@ var ts; if (!ts.isTrivia(currentToken)) { break; } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var trivia = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); if (!trailingTrivia) { trailingTrivia = []; } @@ -111733,7 +116722,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -111767,11 +116756,19 @@ var ts; } return token; } + function readEOFTokenRange() { + ts.Debug.assert(isOnEOF()); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); } + function isOnEOF() { + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + return current === 1 /* EndOfFileToken */; + } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, // then kind needs to be fixed. This might happen in cases @@ -111803,10 +116800,16 @@ var ts; formatting.anyContext = ts.emptyArray; var RuleAction; (function (RuleAction) { - RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; - RuleAction[RuleAction["Space"] = 2] = "Space"; - RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; - RuleAction[RuleAction["Delete"] = 8] = "Delete"; + RuleAction[RuleAction["StopProcessingSpaceActions"] = 1] = "StopProcessingSpaceActions"; + RuleAction[RuleAction["StopProcessingTokenActions"] = 2] = "StopProcessingTokenActions"; + RuleAction[RuleAction["InsertSpace"] = 4] = "InsertSpace"; + RuleAction[RuleAction["InsertNewLine"] = 8] = "InsertNewLine"; + RuleAction[RuleAction["DeleteSpace"] = 16] = "DeleteSpace"; + RuleAction[RuleAction["DeleteToken"] = 32] = "DeleteToken"; + RuleAction[RuleAction["InsertTrailingSemicolon"] = 64] = "InsertTrailingSemicolon"; + RuleAction[RuleAction["StopAction"] = 3] = "StopAction"; + RuleAction[RuleAction["ModifySpaceAction"] = 28] = "ModifySpaceAction"; + RuleAction[RuleAction["ModifyTokenAction"] = 96] = "ModifyTokenAction"; })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); var RuleFlags; (function (RuleFlags) { @@ -111822,8 +116825,10 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { - allTokens.push(token); + for (var token = 0 /* FirstToken */; token <= 151 /* LastToken */; token++) { + if (token !== 1 /* EndOfFileToken */) { + allTokens.push(token); + } } function anyTokenExcept() { var tokens = []; @@ -111833,259 +116838,262 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; - var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArrays(allTokens, [1 /* EndOfFileToken */])); + var keywords = tokenRangeFromRange(76 /* FirstKeyword */, 151 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 74 /* LastBinaryOperator */); + var binaryKeywordOperators = [96 /* InKeyword */, 97 /* InstanceOfKeyword */, 151 /* OfKeyword */, 122 /* AsKeyword */, 132 /* IsKeyword */]; + var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 75 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostincrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; - var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; + var unaryPreincrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostincrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; + var unaryPredecrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostdecrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [73 /* Identifier */].concat(ts.typeKeywords); + var typeNames = __spreadArrays([75 /* Identifier */], 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([73 /* Identifier */, 3 /* MultiLineCommentTrivia */, 77 /* ClassKeyword */, 86 /* ExportKeyword */, 93 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([75 /* Identifier */, 3 /* MultiLineCommentTrivia */, 79 /* ClassKeyword */, 88 /* ExportKeyword */, 95 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 83 /* DoKeyword */, 104 /* TryKeyword */, 89 /* FinallyKeyword */, 84 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 85 /* DoKeyword */, 106 /* TryKeyword */, 91 /* FinallyKeyword */, 86 /* 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, 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 */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), // in other cases there should be no space between '?' and next token - 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", 93 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 95 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 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 */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 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 */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 84 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 108 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 86 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 110 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 91 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, 73 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 91 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 93 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 75 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 93 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [127 /* GetKeyword */, 138 /* SetKeyword */], 73 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 118 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [118 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 98 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [106 /* VarKeyword */, 102 /* ThrowKeyword */, 96 /* NewKeyword */, 82 /* DeleteKeyword */, 98 /* ReturnKeyword */, 105 /* TypeOfKeyword */, 123 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [112 /* LetKeyword */, 78 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [130 /* GetKeyword */, 141 /* SetKeyword */], 75 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 120 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [120 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 100 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterCertainKeywords", [108 /* VarKeyword */, 104 /* ThrowKeyword */, 98 /* NewKeyword */, 84 /* DeleteKeyword */, 100 /* ReturnKeyword */, 107 /* TypeOfKeyword */, 126 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [114 /* LetKeyword */, 80 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 107 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 109 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 122 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 122 /* AsyncKeyword */, 91 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 125 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 125 /* AsyncKeyword */, 93 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [73 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [75 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 73 /* 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, 60 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 60 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 75 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [131 /* ModuleKeyword */, 135 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [134 /* ModuleKeyword */, 138 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 119 /* AbstractKeyword */, - 77 /* ClassKeyword */, - 126 /* DeclareKeyword */, - 81 /* DefaultKeyword */, - 85 /* EnumKeyword */, - 86 /* ExportKeyword */, - 87 /* ExtendsKeyword */, - 127 /* GetKeyword */, - 110 /* ImplementsKeyword */, - 93 /* ImportKeyword */, - 111 /* InterfaceKeyword */, - 131 /* ModuleKeyword */, - 132 /* NamespaceKeyword */, - 114 /* PrivateKeyword */, - 116 /* PublicKeyword */, - 115 /* ProtectedKeyword */, - 134 /* ReadonlyKeyword */, - 138 /* SetKeyword */, - 117 /* StaticKeyword */, - 141 /* TypeKeyword */, - 145 /* FromKeyword */, - 130 /* KeyOfKeyword */, - 128 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [87 /* ExtendsKeyword */, 110 /* ImplementsKeyword */, 145 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + 121 /* AbstractKeyword */, + 79 /* ClassKeyword */, + 129 /* DeclareKeyword */, + 83 /* DefaultKeyword */, + 87 /* EnumKeyword */, + 88 /* ExportKeyword */, + 89 /* ExtendsKeyword */, + 130 /* GetKeyword */, + 112 /* ImplementsKeyword */, + 95 /* ImportKeyword */, + 113 /* InterfaceKeyword */, + 134 /* ModuleKeyword */, + 135 /* NamespaceKeyword */, + 116 /* PrivateKeyword */, + 118 /* PublicKeyword */, + 117 /* ProtectedKeyword */, + 137 /* ReadonlyKeyword */, + 141 /* SetKeyword */, + 119 /* StaticKeyword */, + 144 /* TypeKeyword */, + 148 /* FromKeyword */, + 133 /* KeyOfKeyword */, + 131 /* InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [89 /* ExtendsKeyword */, 112 /* ImplementsKeyword */, 148 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 73 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 75 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), // generics and type assertions - 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 */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 73 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 75 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 119 /* AbstractKeyword */, - 73 /* Identifier */, - 86 /* ExportKeyword */, - 81 /* DefaultKeyword */, - 77 /* ClassKeyword */, - 117 /* StaticKeyword */, - 116 /* PublicKeyword */, - 114 /* PrivateKeyword */, - 115 /* ProtectedKeyword */, - 127 /* GetKeyword */, - 138 /* SetKeyword */, + 121 /* AbstractKeyword */, + 75 /* Identifier */, + 88 /* ExportKeyword */, + 83 /* DefaultKeyword */, + 79 /* ClassKeyword */, + 119 /* StaticKeyword */, + 118 /* PublicKeyword */, + 116 /* PrivateKeyword */, + 117 /* ProtectedKeyword */, + 130 /* GetKeyword */, + 141 /* SetKeyword */, 22 /* OpenBracketToken */, - 40 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 96 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 28 /* LessThanToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + 41 /* AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 98 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 125 /* 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 */), + rule("SpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 4 /* InsertSpace */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - 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 */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty brackets - 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 */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 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 */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing template string braces - 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 */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space after { and before } in JSX expression - 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 */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), // 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, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 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, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - 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 */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 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 */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(122 /* AsyncKeyword */, 75 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(125 /* AsyncKeyword */, 77 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 90 /* ForKeyword */, 123 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 92 /* ForKeyword */, 126 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 83 /* DoKeyword */, 84 /* ElseKeyword */, 75 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 85 /* DoKeyword */, 86 /* ElseKeyword */, 77 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [106 /* TryKeyword */, 91 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; - return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); + return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } formatting.getAllRules = getAllRules; /** @@ -112123,6 +117131,9 @@ var ts; /// /// Contexts /// + function optionEquals(optionName, optionValue) { + return function (context) { return context.options && context.options[optionName] === optionValue; }; + } function isOptionEnabled(optionName) { return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; }; } @@ -112139,45 +117150,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 229 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 179 /* ConditionalType */: + case 216 /* AsExpression */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 167 /* TypePredicate */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 190 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 252 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 241 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 155 /* Parameter */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: - return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 154 /* TypeParameter */: + return context.currentTokenSpan.kind === 96 /* InKeyword */ || context.nextTokenSpan.kind === 96 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 231 /* ForOfStatement */: + return context.currentTokenSpan.kind === 151 /* OfKeyword */ || context.nextTokenSpan.kind === 151 /* OfKeyword */; } return false; } @@ -112189,22 +117205,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 158 /* PropertyDeclaration */ || + contextKind === 157 /* PropertySignature */ || + contextKind === 155 /* Parameter */ || + contextKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 209 /* ConditionalExpression */ || + context.contextNode.kind === 179 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 188 /* ObjectBindingPattern */ || + context.contextNode.kind === 185 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -112230,31 +117246,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 192 /* ObjectLiteralExpression */: + case 249 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 164 /* CallSignature */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 201 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 245 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -112263,40 +117282,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 243 /* FunctionDeclaration */ || context.contextNode.kind === 200 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 172 /* TypeLiteral */: + case 248 /* ModuleDeclaration */: + case 259 /* ExportDeclaration */: + case 260 /* NamedExports */: + case 253 /* ImportDeclaration */: + case 256 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 278 /* CatchClause */: + case 249 /* ModuleBlock */: + case 236 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 222 /* 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 !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 201 /* ArrowFunction */ && blockParent.kind !== 200 /* FunctionExpression */) { return true; } } @@ -112305,31 +117324,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 235 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 278 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 192 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 195 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 196 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -112341,28 +117361,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 201 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 187 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 264 /* JsxElement */ && context.contextNode.kind !== 268 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 274 /* JsxExpression */ || context.contextNode.kind === 273 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 271 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 271 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 265 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -112377,45 +117397,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 242 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 248 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 172 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 165 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { + if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 198 /* TypeAssertionExpression */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -112426,16 +117446,78 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 198 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 109 /* VoidKeyword */ && context.currentTokenParent.kind === 204 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 211 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 217 /* NonNullExpression */; + } + function isSemicolonDeletionContext(context) { + var nextTokenKind = context.nextTokenSpan.kind; + var nextTokenStart = context.nextTokenSpan.pos; + if (ts.isTrivia(nextTokenKind)) { + var nextRealToken = context.nextTokenParent === context.currentTokenParent + ? ts.findNextToken(context.currentTokenParent, ts.findAncestor(context.currentTokenParent, function (a) { return !a.parent; }), context.sourceFile) + : context.nextTokenParent.getFirstToken(context.sourceFile); + if (!nextRealToken) { + return true; + } + nextTokenKind = nextRealToken.kind; + nextTokenStart = nextRealToken.getStart(context.sourceFile); + } + var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; + var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; + if (startLine === endLine) { + return nextTokenKind === 19 /* CloseBraceToken */ + || nextTokenKind === 1 /* EndOfFileToken */; + } + if (nextTokenKind === 221 /* SemicolonClassElement */ || + nextTokenKind === 26 /* SemicolonToken */) { + return false; + } + if (context.contextNode.kind === 245 /* InterfaceDeclaration */ || + context.contextNode.kind === 246 /* TypeAliasDeclaration */) { + // Can’t remove semicolon after `foo`; it would parse as a method declaration: + // + // interface I { + // foo; + // (): void + // } + return !ts.isPropertySignature(context.currentTokenParent) + || !!context.currentTokenParent.type + || nextTokenKind !== 20 /* OpenParenToken */; + } + if (ts.isPropertyDeclaration(context.currentTokenParent)) { + return !context.currentTokenParent.initializer; + } + return context.currentTokenParent.kind !== 229 /* ForStatement */ + && context.currentTokenParent.kind !== 223 /* EmptyStatement */ + && context.currentTokenParent.kind !== 221 /* SemicolonClassElement */ + && nextTokenKind !== 22 /* OpenBracketToken */ + && nextTokenKind !== 20 /* OpenParenToken */ + && nextTokenKind !== 39 /* PlusToken */ + && nextTokenKind !== 40 /* MinusToken */ + && nextTokenKind !== 43 /* SlashToken */ + && nextTokenKind !== 13 /* RegularExpressionLiteral */ + && nextTokenKind !== 27 /* CommaToken */ + && nextTokenKind !== 210 /* TemplateExpression */ + && nextTokenKind !== 15 /* TemplateHead */ + && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* DotToken */; + } + function isSemicolonInsertionContext(context) { + var contextAncestor = ts.findAncestor(context.currentTokenParent, function (ancestor) { + if (ancestor.end !== context.currentTokenSpan.end) { + return "quit"; + } + return ts.syntaxMayBeASICandidate(ancestor.kind); + }); + return !!contextAncestor && ts.isASICandidate(contextAncestor, context.sourceFile); } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -112445,7 +117527,7 @@ var ts; var formatting; (function (formatting) { function getFormatContext(options) { - return { options: options, getRule: getRulesMap() }; + return { options: options, getRules: getRulesMap() }; } formatting.getFormatContext = getFormatContext; var rulesMapCache; @@ -112455,11 +117537,45 @@ var ts; } return rulesMapCache; } + /** + * For a given rule action, gets a mask of other rule actions that + * cannot be applied at the same position. + */ + function getRuleActionExclusion(ruleAction) { + var mask = 0; + if (ruleAction & 1 /* StopProcessingSpaceActions */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 2 /* StopProcessingTokenActions */) { + mask |= 96 /* ModifyTokenAction */; + } + if (ruleAction & 28 /* ModifySpaceAction */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 96 /* ModifyTokenAction */) { + mask |= 96 /* ModifyTokenAction */; + } + return mask; + } function createRulesMap(rules) { var map = buildMap(rules); return function (context) { var bucket = map[getRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind)]; - return bucket && ts.find(bucket, function (rule) { return ts.every(rule.context, function (c) { return c(context); }); }); + if (bucket) { + var rules_1 = []; + var ruleActionMask = 0; + for (var _i = 0, bucket_1 = bucket; _i < bucket_1.length; _i++) { + var rule = bucket_1[_i]; + var acceptRuleActions = ~getRuleActionExclusion(ruleActionMask); + if (rule.action & acceptRuleActions && ts.every(rule.context, function (c) { return c(context); })) { + rules_1.push(rule); + ruleActionMask |= rule.action; + } + } + if (rules_1.length) { + return rules_1; + } + } }; } function buildMap(rules) { @@ -112467,8 +117583,8 @@ var ts; var map = new Array(mapRowLength * mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(map.length); - for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) { - var rule = rules_1[_i]; + for (var _i = 0, rules_2 = rules; _i < rules_2.length; _i++) { + var rule = rules_2[_i]; var specificRule = rule.leftTokenRange.isSpecific && rule.rightTokenRange.isSpecific; for (var _a = 0, _b = rule.leftTokenRange.tokens; _a < _b.length; _a++) { var left = _b[_a]; @@ -112486,16 +117602,16 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 151 /* LastKeyword */ && column <= 151 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 151 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = maskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; + RulesPosition[RulesPosition["StopRulesAny"] = maskBitSize * 1] = "StopRulesAny"; RulesPosition[RulesPosition["ContextRulesSpecific"] = maskBitSize * 2] = "ContextRulesSpecific"; RulesPosition[RulesPosition["ContextRulesAny"] = maskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = maskBitSize * 4] = "NoContextRulesSpecific"; @@ -112517,11 +117633,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action & 3 /* StopAction */ ? + specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -112546,6 +117662,16 @@ var ts; (function (ts) { var formatting; (function (formatting) { + function createTextRangeWithKind(pos, end, kind) { + var textRangeWithKind = { pos: pos, end: end, kind: kind }; + if (ts.Debug.isDebugging) { + Object.defineProperty(textRangeWithKind, "__debugKind", { + get: function () { return ts.Debug.formatSyntaxKind(kind); }, + }); + } + return textRangeWithKind; + } + formatting.createTextRangeWithKind = createTextRangeWithKind; var Constants; (function (Constants) { Constants[Constants["Unknown"] = -1] = "Unknown"; @@ -112669,17 +117795,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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 249 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 288 /* SourceFile */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -112814,7 +117940,7 @@ var ts; return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) { - var options = _a.options, getRule = _a.getRule; + var options = _a.options, getRules = _a.getRules; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); var previousRange; @@ -112904,19 +118030,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: return 79 /* ClassKeyword */; + case 245 /* InterfaceDeclaration */: return 113 /* InterfaceKeyword */; + case 243 /* FunctionDeclaration */: return 93 /* FunctionKeyword */; + case 247 /* EnumDeclaration */: return 247 /* EnumDeclaration */; + case 162 /* GetAccessor */: return 130 /* GetKeyword */; + case 163 /* SetAccessor */: return 141 /* SetKeyword */; + case 160 /* MethodDeclaration */: if (node.asteriskToken) { - return 40 /* AsteriskToken */; + return 41 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -112966,22 +118092,22 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 84 /* ElseKeyword */: - case 108 /* WhileKeyword */: - case 58 /* AtToken */: + case 86 /* ElseKeyword */: + case 110 /* WhileKeyword */: + case 59 /* AtToken */: return false; - case 42 /* SlashToken */: - case 30 /* GreaterThanToken */: + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 185 /* MappedType */) { return false; } break; @@ -113028,6 +118154,12 @@ var ts; } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } + if (!node.parent && formattingScanner.isOnEOF()) { + var token = formattingScanner.readEOFTokenRange(); + if (token.end <= node.end && previousRange) { + processPair(token, sourceFile.getLineAndCharacterOfPosition(token.pos).line, node, previousRange, previousRangeStartLine, previousParent, contextNode, nodeDynamicIndentation); + } + } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; @@ -113073,7 +118205,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 156 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 11 /* JsxText */) { @@ -113081,7 +118213,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 191 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -113249,35 +118381,39 @@ var ts; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = getRule(formattingContext); - var trimTrailingWhitespaces; + var rules = getRules(formattingContext); + var trimTrailingWhitespaces = false; var lineAction = 0 /* None */; - if (rule) { - lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - switch (lineAction) { - case 2 /* LineRemoved */: - // Handle the case where the next line is moved to be the end of this line. - // In this case we don't indent the next line in the next pass. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); - } - break; - case 1 /* LineAdded */: - // Handle the case where token2 is moved to the new line. - // In this case we indent token2 in the next pass but we set - // sameLineIndent flag to notify the indenter that the indentation is within the line. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); - } - break; - default: - ts.Debug.assert(lineAction === 0 /* None */); - } - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = !(rule.action & 8 /* Delete */) && rule.flags !== 1 /* CanDeleteNewLines */; + if (rules) { + // Apply rules in reverse order so that higher priority rules (which are first in the array) + // win in a conflict with lower priority rules. + ts.forEachRight(rules, function (rule) { + lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + switch (lineAction) { + case 2 /* LineRemoved */: + // Handle the case where the next line is moved to be the end of this line. + // In this case we don't indent the next line in the next pass. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); + } + break; + case 1 /* LineAdded */: + // Handle the case where token2 is moved to the new line. + // In this case we indent token2 in the next pass but we set + // sameLineIndent flag to notify the indenter that the indentation is within the line. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); + } + break; + default: + ts.Debug.assert(lineAction === 0 /* None */); + } + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespaces = !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + }); } else { - trimTrailingWhitespaces = true; + trimTrailingWhitespaces = currentItem.kind !== 1 /* EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -113414,20 +118550,28 @@ var ts; edits.push(ts.createTextChangeFromStartLength(start, len, newText)); } } + function recordInsert(start, text) { + if (text) { + edits.push(ts.createTextChangeFromStartLength(start, 0, text)); + } + } function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* Ignore */: + case 1 /* StopProcessingSpaceActions */: // no action required return 0 /* None */; - case 8 /* Delete */: + case 16 /* DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } break; - case 4 /* NewLine */: + case 32 /* DeleteToken */: + recordDelete(previousRange.pos, previousRange.end - previousRange.pos); + break; + case 8 /* InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines @@ -113441,7 +118585,7 @@ var ts; return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; } break; - case 2 /* Space */: + case 4 /* InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { return 0 /* None */; @@ -113451,6 +118595,9 @@ var ts; recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } + break; + case 64 /* InsertTrailingSemicolon */: + recordInsert(previousRange.end, ";"); } return 0 /* None */; } @@ -113464,8 +118611,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -113474,6 +118620,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -113499,34 +118646,34 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 201 /* ArrowFunction */: if (node.typeParameters === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.parameters === list) { return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.arguments === list) { return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 168 /* TypeReference */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -113535,8 +118682,8 @@ var ts; switch (kind) { case 20 /* OpenParenToken */: return 21 /* CloseParenToken */; - case 28 /* LessThanToken */: - return 30 /* GreaterThanToken */; + case 29 /* LessThanToken */: + return 31 /* GreaterThanToken */; case 18 /* OpenBraceToken */: return 19 /* CloseBraceToken */; } @@ -113624,7 +118771,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -113643,7 +118791,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 208 /* 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 */) { @@ -113797,7 +118945,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 === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 288 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -113845,8 +118993,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); + if (parent.kind === 226 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 86 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -113880,40 +119028,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -113936,7 +119084,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 242 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -114009,83 +119157,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 225 /* ExpressionStatement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 191 /* ArrayLiteralExpression */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 185 /* MappedType */: + case 174 /* TupleType */: + case 250 /* CaseBlock */: + case 276 /* DefaultClause */: + case 275 /* CaseClause */: + case 199 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 224 /* VariableStatement */: + case 258 /* ExportAssignment */: + case 234 /* ReturnStatement */: + case 209 /* ConditionalExpression */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: + case 265 /* JsxSelfClosingElement */: + case 274 /* JsxExpression */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 155 /* Parameter */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 181 /* ParenthesizedType */: + case 197 /* TaggedTemplateExpression */: + case 205 /* AwaitExpression */: + case 260 /* NamedExports */: + case 256 /* NamedImports */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 158 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 241 /* VariableDeclaration */: + case 279 /* PropertyAssignment */: + case 208 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 192 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 208 /* BinaryExpression */) { + return true; + } + break; + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return childKind !== 222 /* Block */; + case 259 /* ExportDeclaration */: + return childKind !== 260 /* NamedExports */; + case 253 /* ImportDeclaration */: + return childKind !== 254 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 256 /* NamedImports */); + case 264 /* JsxElement */: + return childKind !== 267 /* JsxClosingElement */; + case 268 /* JsxFragment */: + return childKind !== 270 /* JsxClosingFragment */; + case 178 /* IntersectionType */: + case 177 /* UnionType */: + if (childKind === 172 /* TypeLiteral */) { return false; } // falls through @@ -114096,11 +119248,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: + return parent.kind !== 222 /* Block */; default: return false; } @@ -114242,7 +119394,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 192 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -114407,7 +119559,7 @@ var ts; } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 241 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -114439,7 +119591,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { var firstStatement = ts.firstOrUndefined(ctr.body.statements); if (!firstStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, [newStatement].concat(ctr.body.statements)); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays([newStatement], ctr.body.statements)); } else { this.insertNodeBefore(sourceFile, firstStatement, newStatement); @@ -114448,7 +119600,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, ctr.body.statements.concat([newStatement])); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays(ctr.body.statements, [newStatement])); } else { this.insertNodeAfter(sourceFile, lastStatement, newStatement); @@ -114481,7 +119633,7 @@ var ts; if (getMembersOrProperties(cls).length === 0) { if (ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(cls), { node: cls, sourceFile: sourceFile })) { // For `class C {\n}`, don't add the trailing "\n" - var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, getClassOrObjectBraceEnds(cls, sourceFile).concat([sourceFile])); // TODO: GH#4130 remove 'as any' + var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, __spreadArrays(getClassOrObjectBraceEnds(cls, sourceFile), [sourceFile])); // TODO: GH#4130 remove 'as any' return { prefix: this.newLineCharacter, suffix: comma + (shouldSuffix ? this.newLineCharacter : "") }; } else { @@ -114520,22 +119672,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 155 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -114544,12 +119696,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + if (node.kind === 201 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(91 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(93 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -114558,14 +119710,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 222 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(100 /* 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 === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 200 /* FunctionExpression */ ? 93 /* FunctionKeyword */ : 79 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -114816,29 +119968,34 @@ var ts; var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + noIndent + (options.suffix || ""); } + function getFormatCodeSettingsForWriting(_a, sourceFile) { + var options = _a.options; + var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore; + var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile); + return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore }); + } /** Note: this may mutate `nodeIn`. */ function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) { var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta; var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text; if (validate) validate(node, text); - var formatOptions = formatContext.options; + var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile); var initialIndentation = indentation !== undefined ? indentation : ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos); if (delta === undefined) { - delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatContext.options, nodeIn) ? (formatOptions.indentSize || 0) : 0; + delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? (formatOptions.indentSize || 0) : 0; } var file = { text: text, getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); } }; - var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, formatContext); + var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, __assign(__assign({}, formatContext), { options: formatOptions })); return applyChanges(text, changes); } /** Note: output node may be mutated input node. */ function getNonformattedText(node, sourceFile, newLineCharacter) { - var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); - var writer = createWriter(newLineCharacter, omitTrailingSemicolon); + var writer = createWriter(newLineCharacter); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -114873,9 +120030,9 @@ var ts; nodeArray.end = getEnd(nodes); return nodeArray; } - function createWriter(newLine, omitTrailingSemicolon) { + function createWriter(newLine) { var lastNonTriviaPosition = 0; - var writer = omitTrailingSemicolon ? ts.getTrailingSemicolonOmittingWriter(ts.createTextWriter(newLine)) : ts.createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var onEmitNode = function (hint, node, printCallback) { if (node) { setPos(node, lastNonTriviaPosition); @@ -115026,6 +120183,8 @@ var ts; getColumn: getColumn, getIndent: getIndent, isAtStartOfLine: isAtStartOfLine, + hasTrailingComment: function () { return writer.hasTrailingComment(); }, + hasTrailingWhitespace: function () { return writer.hasTrailingWhitespace(); }, clear: clear }; } @@ -115090,14 +120249,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 153 /* 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 152 /* Parameter */: { + case 155 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -115112,14 +120271,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 189 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -115127,13 +120286,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -115142,7 +120301,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -115189,13 +120348,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 253 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 278 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; @@ -115206,14 +120365,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -115374,10 +120533,10 @@ var ts; }); 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 assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) - : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(147 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(147 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -115393,7 +120552,7 @@ var ts; ts.Diagnostics.This_expression_is_not_callable.code, ts.Diagnostics.This_expression_is_not_constructable.code, ]; - var errorCodes = [ + var errorCodes = __spreadArrays([ ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, @@ -115409,13 +120568,13 @@ var ts; ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator.code, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code, propertyAccessCode - ].concat(callableConstructableErrorCodes); + ], callableConstructableErrorCodes); codefix.registerCodeFix({ fixIds: [fixId], errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -115429,27 +120588,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -115463,7 +120633,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -115476,64 +120646,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = function (identifier) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + return "continue"; + } + var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); + var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); + var variableStatement = ts.getAncestor(declaration, 224 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; - }); - if (isUsedElsewhere) { - return; + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; + } + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; } - return declaration.initializer; + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); + }); + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { - return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 243 /* FunctionDeclaration */ || + ancestor.parent.kind === 200 /* FunctionExpression */ || + ancestor.parent.kind === 201 /* ArrowFunction */ || + ancestor.parent.kind === 160 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -115596,16 +120848,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || fixedNodes.tryAdd(initializer)) { - changeTracker.insertModifierBefore(sourceFile, 78 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 80 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 75 /* Identifier */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -115619,8 +120871,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 75 /* Identifier */: + case 208 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -115640,6 +120892,42 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addMissingDeclareProperty"; + var errorCodes = [ + ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration.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); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Prefix_with_declare, fixId, ts.Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var fixedNodes = new ts.NodeSet(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start, fixedNodes); }); + }, + }); + function makeChange(changeTracker, sourceFile, pos, fixedNodes) { + var token = ts.getTokenAtPosition(sourceFile, pos); + if (!ts.isIdentifier(token)) { + return; + } + var declaration = token.parent; + if (declaration.kind === 158 /* PropertyDeclaration */ && + (!fixedNodes || fixedNodes.tryAdd(declaration))) { + changeTracker.insertModifierBefore(sourceFile, 129 /* DeclareKeyword */, declaration); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -115761,33 +121049,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 241 /* VariableDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 158 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -115809,7 +121097,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 299 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); 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); @@ -115849,8 +121137,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -115954,7 +121242,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 73 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 101 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 103 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -116041,13 +121329,8 @@ var ts; if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, 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); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -116066,14 +121349,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -116108,7 +121388,7 @@ var ts; function annotate(changes, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 157 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -116148,14 +121428,14 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); + var jsDocNode = parent.kind === 201 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 158 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -116165,14 +121445,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 306 /* JSDocParameterTag */: { + case 310 /* 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 307 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -116184,25 +121464,31 @@ var ts; } 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); + return inferTypeFromReferences(program, references, cancellationToken).single(); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + } + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); + case 161 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 128 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -116211,54 +121497,109 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - 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); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + var builtinConstructors = { + string: function () { return checker.getStringType(); }, + number: function () { return checker.getNumberType(); }, + Array: function (t) { return checker.createArrayType(t); }, + Promise: function (t) { return checker.createPromiseType(t); }, + }; + var builtins = [ + checker.getStringType(), + checker.getNumberType(), + checker.createArrayType(checker.getAnyType()), + checker.createPromiseType(checker.getAnyType()), + ]; + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function createEmptyUsage() { + return { + isNumber: undefined, + isString: undefined, + isNumberOrString: undefined, + candidateTypes: undefined, + properties: undefined, + calls: undefined, + constructs: undefined, + numberIndex: undefined, + stringIndex: undefined, + candidateThisTypes: undefined, + inferredTypes: undefined, + }; + } + function combineUsages(usages) { + var combinedProperties = ts.createUnderscoreEscapedMap(); + for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) { + var u = usages_1[_i]; + if (u.properties) { + u.properties.forEach(function (p, name) { + if (!combinedProperties.has(name)) { + combinedProperties.set(name, []); + } + combinedProperties.get(name).push(p); + }); + } } - return inferFromContext(usageContext, checker); + var properties = ts.createUnderscoreEscapedMap(); + combinedProperties.forEach(function (ps, name) { + properties.set(name, combineUsages(ps)); + }); + return { + isNumber: usages.some(function (u) { return u.isNumber; }), + isString: usages.some(function (u) { return u.isString; }), + isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }), + candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }), + properties: properties, + calls: ts.flatMap(usages, function (u) { return u.calls; }), + constructs: ts.flatMap(usages, function (u) { return u.constructs; }), + numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }), + stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }), + candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }), + inferredTypes: undefined, + }; + } + function single() { + return combineTypes(inferTypesFromReferencesSingle(references)); } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = createEmptyUsage(); + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = (usageContext.constructContexts || []).concat(usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return 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) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.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])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = combineTypes(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -116266,242 +121607,255 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = createEmptyUsage(); + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return combineTypes(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = createEmptyUsage(); for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferTypes(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 225 /* ExpressionStatement */: + addCandidateType(usage, checker.getVoidType()); + break; + case 207 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 206 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 208 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 193 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 194 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 158 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 241 /* 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)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - usageContext.isNumber = true; + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + usage.isNumber = true; break; - case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + case 39 /* PlusToken */: + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: // MultiplicativeOperator - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + // falls through + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: // ShiftOperator - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // falls through + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator - case 49 /* AmpersandToken */: - case 50 /* BarToken */: - case 51 /* CaretToken */: + // falls through + case 50 /* AmpersandToken */: + case 51 /* BarToken */: + case 52 /* CaretToken */: // CompoundAssignmentOperator - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 71 /* BarEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: + // falls through + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 73 /* BarEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator - case 39 /* MinusToken */: + // falls through + case 40 /* MinusToken */: // RelationalOperator - case 28 /* LessThanToken */: - case 31 /* LessThanEqualsToken */: - case 30 /* GreaterThanToken */: - case 32 /* GreaterThanEqualsToken */: + // falls through + case 29 /* LessThanToken */: + case 32 /* LessThanEqualsToken */: + case 31 /* GreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; - case 61 /* PlusEqualsToken */: - case 38 /* PlusToken */: + case 63 /* PlusEqualsToken */: + case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; + } + else if (otherOperandType.flags & 1 /* Any */) { + // do nothing, maybe we'll learn something elsewhere } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators - case 60 /* EqualsToken */: - case 33 /* EqualsEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + case 62 /* EqualsToken */: + case 34 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 94 /* InKeyword */: + case 96 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; - // LogicalOperator - case 55 /* BarBarToken */: + // LogicalOperator Or NullishCoalescing + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 241 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: // nothing to infer here break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], - returnType: {} + return_: createEmptyUsage() }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.return_); + if (parent.kind === 195 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || createEmptyUsage(); + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = createEmptyUsage(); + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -116510,17 +121864,19 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { - if (fallback === void 0) { fallback = checker.getAnyType(); } + function combineFromUsage(usage) { + return combineTypes(inferTypes(usage)); + } + function combineTypes(inferences) { if (!inferences.length) - return fallback; + return checker.getAnyType(); // 1. string or number individually override string | number // 2. non-any, non-void overrides any or void // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types @@ -116543,12 +121899,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function combineAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -116584,109 +121939,173 @@ var ts; }); 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) { + function inferTypes(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - 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) { - types.push(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 + if (usage.numberIndex) { + types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); + } + if (usage.properties && usage.properties.size + || usage.calls && usage.calls.length + || usage.constructs && usage.constructs.length + || usage.stringIndex) { + types.push(inferStructuralType(usage)); } + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + types.push.apply(types, inferNamedTypesFromProperties(usage)); return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + function inferStructuralType(usage) { + var members = ts.createUnderscoreEscapedMap(); + if (usage.properties) { + usage.properties.forEach(function (u, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = combineFromUsage(u); + members.set(name, symbol); + }); } + var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; + var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; + var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); + return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + function inferNamedTypesFromProperties(usage) { + if (!usage.properties || !usage.properties.size) + return []; + var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); }); + if (0 < types.length && types.length < 3) { + return types.map(function (t) { return inferInstantiationFromUsage(t, usage); }); + } + return []; + } + function allPropertiesAreAssignableToUsage(type, usage) { + if (!usage.properties) + return false; + return !ts.forEachEntry(usage.properties, function (propUsage, name) { + var source = checker.getTypeOfPropertyOfType(type, name); + if (!source) { + return true; + } + if (propUsage.calls) { + var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); + } + else { + return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage)); + } + }); + } + /** + * inference is limited to + * 1. generic types with a single parameter + * 2. inference to/from calls with a single signature + */ + function inferInstantiationFromUsage(type, usage) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + return type; + } + var generic = type.target; + var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters); + if (!singleTypeParameter) + return type; 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])); + usage.properties.forEach(function (propUsage, name) { + var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name); + ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference."); + types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter)); + }); + return builtinConstructors[type.symbol.escapedName](combineTypes(types)); + } + function inferTypeParameters(genericType, usageType, typeParameter) { + if (genericType === typeParameter) { + return [usageType]; + } + else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); + } + else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference + var genericArgs = checker.getTypeArguments(genericType); + var usageArgs = checker.getTypeArguments(usageType); + var types = []; + if (genericArgs && usageArgs) { + for (var i = 0; i < genericArgs.length; i++) { + if (usageArgs[i]) { + types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter)); } } } + return types; } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + if (genericSigs.length === 1 && usageSigs.length === 1) { + return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } - return undefined; + return []; + } + function inferFromSignatures(genericSig, usageSig, typeParameter) { + var types = []; + for (var i = 0; i < genericSig.parameters.length; i++) { + var genericParam = genericSig.parameters[i]; + var usageParam = usageSig.parameters[i]; + var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]); + if (!usageParam) { + break; + } + var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); + if (elementType) { + genericParamType = elementType; + } + var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); + } + var genericReturn = checker.getReturnTypeOfSignature(genericSig); + var usageReturn = checker.getReturnTypeOfSignature(usageSig); + types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter)); + return types; } - function getSignatureFromCallContext(callContext, checker) { + function getFunctionFromCalls(calls) { + return checker.createAnonymousType(undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } + function getSignatureFromCalls(calls) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); + var _loop_12 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); + if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { + symbol.flags |= 16777216 /* Optional */; + } parameters.push(symbol); + }; + for (var i = 0; i < length; i++) { + _loop_12(i); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -116715,12 +122134,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -116752,7 +122171,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(117 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(119 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -116775,7 +122194,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 === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 225 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -116783,27 +122202,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 201 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 222 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -116824,17 +122243,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 200 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 73 /* Identifier */) { + if (node.name.kind !== 75 /* 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, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 88 /* 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 @@ -116845,7 +122264,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 88 /* 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 @@ -116908,12 +122327,12 @@ var ts; return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 122 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 125 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_13 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -116925,7 +122344,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_13(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -117219,10 +122638,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 73 /* Identifier */: // identifier includes undefined + case 75 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -117244,8 +122663,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -117357,6 +122776,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -117448,10 +122868,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -117477,7 +122897,7 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(node.name.text, node, 67220415 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. res.set(text, makeUniqueName("_" + text, identifiers)); } @@ -117497,29 +122917,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 === 60 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 62 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 195 /* 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 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -117559,8 +122979,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -117568,11 +122988,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -117611,18 +123031,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); + case 160 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(88 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -117651,12 +123072,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -117669,7 +123088,7 @@ 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(86 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(88 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -117678,14 +123097,14 @@ var ts; } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(86 /* ExportKeyword */), ts.createToken(78 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(88 /* ExportKeyword */), ts.createToken(80 /* 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(86 /* ExportKeyword */)]; + var modifiers = [ts.createToken(88 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -117693,10 +123112,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -117714,18 +123133,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 188 /* 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 + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 189 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -117736,10 +123157,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -117761,7 +123182,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` var idName = namedBindingsNames.get(propertyName); if (idName === undefined) { idName = makeUniqueName(propertyName, identifiers); @@ -117808,11 +123229,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -117887,8 +123308,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -117915,7 +123338,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -118013,7 +123436,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -118026,7 +123449,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -118034,14 +123457,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -118078,28 +123501,29 @@ var ts; ImportKind[ImportKind["Default"] = 1] = "Default"; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; + ImportKind[ImportKind["ConstEquals"] = 4] = "ConstEquals"; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { - var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); + ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { + function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { var result = []; forEachExternalModule(checker, allSourceFiles, function (moduleSymbol, moduleFile) { // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(sourceFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); if (defaultInfo && defaultInfo.name === symbolName && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); } @@ -118113,7 +123537,7 @@ var ts; return result; } function isTypeOnlySymbol(s, checker) { - return !(ts.skipAlias(s, checker).flags & 67220415 /* Value */); + return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); @@ -118122,7 +123546,7 @@ var ts; var addToExisting = tryAddToExistingImport(existingImports); // Don't bother providing an action to add a new import if we can add to an existing one. var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences); - return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); + return __spreadArrays((useNamespace ? [useNamespace] : ts.emptyArray), addImport); } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -118151,21 +123575,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 253 /* 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 === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 256 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 253 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 255 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -118176,22 +123600,35 @@ 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 === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 253 /* ImportDeclaration */ || i.kind === 252 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } function getNewImportInfos(program, sourceFile, position, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); + var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); - // Sort to keep the shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + // Sort by presence in package.json, then shortest paths first + return ts.sort(choicesForEachExportingModule, function (a, b) { + var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); + var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); + if (allowsImportingA && !allowsImportingB) { + return -1; + } + if (allowsImportingB && !allowsImportingA) { + return 1; + } + return a.moduleSpecifier.length - b.moduleSpecifier.length; + }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -118199,9 +123636,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 253 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 263 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -118211,7 +123648,7 @@ var ts; var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ? getFixesInfoForUMDImport(context, symbolToken) : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken) : undefined; - return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -118221,7 +123658,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } @@ -118233,10 +123670,10 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67220415 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } - function getUmdImportKind(compilerOptions) { + function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { return 1 /* Default */; @@ -118247,6 +123684,9 @@ var ts; case ts.ModuleKind.AMD: case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 4 /* ConstEquals */; + } return 3 /* Equals */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: @@ -118255,7 +123695,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -118268,24 +123708,25 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - ts.Debug.assert(symbolName !== "default" /* Default */); - var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); + var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, host); + var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program, host) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); function addSymbol(moduleSymbol, exportedSymbol, importKind) { originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); } - forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, program.getCompilerOptions()); + var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind); } @@ -118297,20 +123738,41 @@ var ts; }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(moduleSymbol, checker); + function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); if (!exported) return undefined; var symbol = exported.symbol, kind = exported.kind; var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); return info && __assign({ symbol: symbol, kind: kind }, info); } - function getDefaultLikeExportWorker(moduleSymbol, checker) { + function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); if (defaultExport) return { symbol: defaultExport, kind: 1 /* Default */ }; var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); - return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: 3 /* Equals */ }; + return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions, checker) }; + } + function getExportEqualsImportKind(importingFile, compilerOptions, checker) { + if (ts.getAllowSyntheticDefaultImports(compilerOptions) && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return 1 /* Default */; + } + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 1 /* Default */ : 4 /* ConstEquals */; + } + for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isImportEqualsDeclaration(statement)) { + return 3 /* Equals */; + } + if (ts.isImportDeclaration(statement) && statement.importClause && statement.importClause.name) { + var moduleSymbol = checker.getImmediateAliasedSymbol(statement.importClause.symbol); + if (moduleSymbol && moduleSymbol.name !== "default" /* Default */) { + return 1 /* Default */; + } + } + } + return 3 /* Equals */; } function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -118321,7 +123783,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -118337,7 +123799,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -118371,12 +123833,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -118394,7 +123856,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -118419,21 +123881,46 @@ var ts; ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); } if (namespaceLikeImport) { - ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ - ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) - : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) : + namespaceLikeImport.importKind === 4 /* ConstEquals */ ? createConstEqualsRequireDeclaration(namespaceLikeImport.name, quotedModuleSpecifier) : + ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); } } + function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) { + return ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.createIdentifier(name), + /*type*/ undefined, ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) + ], 2 /* Const */)); + } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(checker, from, allSourceFiles, cb) { - forEachExternalModule(checker, allSourceFiles, function (module, sourceFile) { - if (sourceFile === undefined || sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { - cb(module); + function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, cb) { + var filteredCount = 0; + var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host); + var allSourceFiles = program.getSourceFiles(); + forEachExternalModule(program.getTypeChecker(), allSourceFiles, function (module, sourceFile) { + if (sourceFile === undefined) { + if (!packageJson || packageJson.allowsImportingAmbientModule(module, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } + } + else if (sourceFile && sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { + if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } } }); + if (host.log) { + host.log("forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); + } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; function forEachExternalModule(checker, allSourceFiles, cb) { @@ -118488,6 +123975,109 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; + function createAutoImportFilter(fromFile, program, host) { + var packageJsons = host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host); + var dependencyGroups = 1 /* Dependencies */ | 2 /* DevDependencies */ | 8 /* OptionalDependencies */; + // Mix in `getProbablySymlinks` from Program when host doesn't have it + // in order for non-Project hosts to have a symlinks cache. + var moduleSpecifierResolutionHost = { + directoryExists: ts.maybeBind(host, host.directoryExists), + fileExists: ts.maybeBind(host, host.fileExists), + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + readFile: ts.maybeBind(host, host.readFile), + useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || program.getProbableSymlinks, + }; + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName, dependencyGroups) || packageJson.has(ts.getTypesPackageName(packageName), dependencyGroups)) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, allSourceFiles); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, allSourceFiles); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + /** + * Use for a specific module specifier that has already been resolved. + * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve + * the best module specifier for a given module _and_ determine if it’s importable. + */ + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, allSourceFiles) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, allSourceFiles, program.redirectTargetsMap); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -118531,12 +124121,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (property access)"); 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 === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -118565,10 +124155,10 @@ var ts; flags |= 1920 /* Namespace */; } if (meaning & 2 /* Type */) { - flags |= 67897832 /* Type */; + flags |= 788968 /* Type */; } if (meaning & 1 /* Value */) { - flags |= 67220415 /* Value */; + flags |= 111551 /* Value */; } return flags; } @@ -118639,7 +124229,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -118666,7 +124256,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_14(info); } }); })); @@ -118727,7 +124317,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 213 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -118753,7 +124343,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 208 /* 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))); @@ -118763,7 +124353,7 @@ var ts; var contextualType = checker.getContextualType(token.parent); typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; } - return typeNode || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return typeNode || ts.createKeywordTypeNode(124 /* 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); }); @@ -118772,7 +124362,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -118796,7 +124386,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(139 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(142 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -118816,7 +124406,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, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 160 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -119024,7 +124614,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 101 /* ThisKeyword */) + if (token.kind !== 103 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -119063,7 +124653,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 128 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -119107,6 +124697,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -119134,14 +124761,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 87 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 89 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(110 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(112 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 87 /* ExtendsKeyword */ && - heritageClauses[1].token === 110 /* ImplementsKeyword */) { + heritageClauses[0].token === 89 /* ExtendsKeyword */ && + heritageClauses[1].token === 112 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* CommaToken */)); @@ -119228,7 +124855,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 === 28 /* LessThanToken */) { + if (token.kind === 29 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -119248,7 +124875,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* 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)); @@ -119280,7 +124907,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 128 /* InferKeyword */) + if (token.kind === 131 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -119289,7 +124916,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 28 /* LessThanToken */) { + else if (token.kind === 29 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -119299,7 +124926,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -119310,23 +124937,23 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(144 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(147 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 93 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 95 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 155 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -119337,7 +124964,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -119346,7 +124973,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 === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -119355,14 +124982,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 155 /* Parameter */: + case 154 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return true; } } @@ -119409,26 +125036,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 160 /* 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 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* 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); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 75 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -119464,11 +125091,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); 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 223 /* IfStatement */: + case 226 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -119479,15 +125106,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -119529,7 +125156,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, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -119553,7 +125180,7 @@ 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 === 292 /* JSDocNullableType */) { + if (typeNode.kind === 295 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -119573,7 +125200,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 295 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -119590,22 +125217,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 216 /* AsExpression */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 162 /* GetAccessor */: + case 166 /* IndexSignature */: + case 185 /* MappedType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 198 /* TypeAssertionExpression */: + case 241 /* VariableDeclaration */: return true; default: return false; @@ -119634,12 +125261,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -119659,14 +125289,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 93 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -119681,11 +125311,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 73 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 75 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 122 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 125 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -119793,18 +125423,40 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); + var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); switch (declaration.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 158 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: { + var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); + var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + var orderedAccessors = allAccessors.secondAccessor + ? [allAccessors.firstAccessor, allAccessors.secondAccessor] + : [allAccessors.firstAccessor]; + for (var _i = 0, orderedAccessors_1 = orderedAccessors; _i < orderedAccessors_1.length; _i++) { + var accessor = orderedAccessors_1[_i]; + if (ts.isGetAccessorDeclaration(accessor)) { + out(ts.createGetAccessor( + /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); + } + else { + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); + var parameter = ts.getSetAccessorValueParameter(accessor); + var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; + out(ts.createSetAccessor( + /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(preferences))); + } + } + break; + } + case 159 /* MethodSignature */: + case 160 /* 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 @@ -119817,23 +125469,25 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; } - for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { - var signature = signatures_1[_i]; + for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) { + var signature = signatures_1[_a]; // 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)); } - if (declarations.length > signatures.length) { - var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); - } - else { - ts.Debug.assert(declarations.length === signatures.length); - out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + if (!ambient) { + if (declarations.length > signatures.length) { + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + } + else { + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); + out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + } } break; } @@ -119845,14 +125499,14 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 160 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(57 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -119866,15 +125520,14 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(41 /* 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); @@ -119891,8 +125544,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(121 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(124 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -119920,11 +125573,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(121 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(124 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -119935,7 +125588,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -119946,10 +125599,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(116 /* PublicKeyword */); + return ts.createToken(118 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(115 /* ProtectedKeyword */); + return ts.createToken(117 /* ProtectedKeyword */); } return undefined; } @@ -120021,7 +125674,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 195 /* CallExpression */ : 196 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -120132,7 +125785,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(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -120140,7 +125793,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(142 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(145 /* 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)); @@ -120261,6 +125914,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -120282,8 +125968,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 95 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 187 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -120335,8 +126021,8 @@ 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(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); - var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(137 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); @@ -120366,7 +126052,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 123 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 126 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -120377,7 +126063,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 96 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 98 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -120388,6 +126074,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -120404,8 +126124,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -120425,16 +126145,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -120443,7 +126163,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + ts.Debug.assert(!wasDefault, "Can't have a default flag here"); return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } default: @@ -120457,40 +126177,40 @@ 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, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 83 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 88 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(83 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 224 /* 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. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* 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))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -120504,27 +126224,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 257 /* ImportSpecifier */: + case 261 /* 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 251 /* ImportClause */: { + case 254 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 255 /* 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 */; @@ -120545,11 +126265,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 257 /* 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); @@ -120562,7 +126282,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 261 /* 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";` @@ -120571,7 +126291,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -120595,13 +126315,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 255 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 255 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -120618,7 +126338,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 255 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -120639,7 +126359,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -120678,7 +126398,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -120697,7 +126417,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -120818,6 +126538,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -120909,6 +126630,9 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -120961,20 +126685,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 158 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 155 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 161 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 160 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -120992,13 +126716,13 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 4194304 /* Ambient */) { + if (nodeToCheck.flags & 8388608 /* Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -121017,7 +126741,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 241 /* 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`! @@ -121029,13 +126753,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 99 /* SuperKeyword */: + case 101 /* 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 === 192 /* CallExpression */) { + if (node.parent.kind === 195 /* 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)) { @@ -121050,8 +126774,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -121063,20 +126787,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 222 /* Block */: + if (node.parent && node.parent.kind === 239 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -121088,19 +126812,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 182 /* ThisType */: + case 103 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -121109,20 +126833,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 233 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -121176,7 +126900,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 === 152 /* Parameter */) { + if (current.kind === 155 /* 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; } @@ -121187,7 +126911,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 288 /* SourceFile */) { return scopes; } } @@ -121277,32 +127001,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 244 /* 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 === 246 /* ModuleBlock */ + return scope.kind === 249 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -121368,20 +127092,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(114 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(116 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(122 /* AsyncKeyword */)); + modifiers.push(ts.createToken(125 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(122 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(125 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* 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; @@ -121398,7 +127122,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(40 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(41 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -121406,8 +127130,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -121475,7 +127199,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -121522,9 +127246,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 142 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 145 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(142 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); } } /** @@ -121532,6 +127256,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -121542,16 +127267,17 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(114 /* PrivateKeyword */)); + modifiers.push(ts.createToken(116 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } - modifiers.push(ts.createToken(134 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(137 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -121580,7 +127306,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 225 /* 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( @@ -121599,7 +127325,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 225 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -121613,6 +127339,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -121686,7 +127469,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 234 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -121749,11 +127532,11 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; - for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { - var member = members_2[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.pos > maxPos) { return prevMember || members[0]; } @@ -121791,11 +127574,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -121864,7 +127647,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 !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 243 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -121917,7 +127700,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -121927,7 +127710,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -121949,7 +127732,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -121967,7 +127750,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -122180,30 +127963,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 282 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 253 /* ImportDeclaration */ && + parent.kind !== 257 /* ImportSpecifier */; + case 212 /* SpreadElement */: + case 188 /* ObjectBindingPattern */: + case 190 /* BindingElement */: return false; - case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + case 75 /* Identifier */: + return parent.kind !== 190 /* BindingElement */ && + parent.kind !== 257 /* ImportSpecifier */ && + parent.kind !== 261 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 222 /* Block */: + case 288 /* SourceFile */: + case 249 /* ModuleBlock */: + case 275 /* CaseClause */: return true; default: return false; @@ -122219,6 +128002,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -122228,22 +128012,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -122258,11 +128054,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; + } + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function isStatementAndHasJSDoc(n) { return ts.isStatement(n) && ts.hasJSDocNodes(n); @@ -122299,7 +128120,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 67220415 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); if (symbol && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -122313,15 +128134,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(311 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(315 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -122329,10 +128161,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(310 /* JSDocTemplateTag */); + var template = ts.createNode(314 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(154 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -122382,10 +128214,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 116 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 118 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 114 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 116 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -122413,7 +128245,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -122423,7 +128255,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(117 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(119 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -122446,7 +128278,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 155 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -122492,24 +128324,22 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 101 /* ThisKeyword */ && + node.expression.kind === 103 /* ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 103 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -122534,7 +128364,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -122591,11 +128421,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -122630,7 +128460,7 @@ var ts; deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return __spreadArrays(getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference), addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { @@ -122648,10 +128478,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -122673,25 +128503,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 253 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 255 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -122719,20 +128549,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 253 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 252 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -122774,7 +128604,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -122802,19 +128632,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -122823,7 +128653,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 255 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -122833,9 +128663,9 @@ var ts; } if (namedBindings) { if (namedBindingsUnused) { - changes.delete(sourceFile, namedBindings); + changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 256 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -122848,14 +128678,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 188 /* 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); } @@ -122929,7 +128759,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -122982,13 +128812,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -123000,7 +128830,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -123010,18 +128840,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -123031,11 +128861,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 188 /* 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; @@ -123087,18 +128917,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -123106,17 +128936,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -123126,13 +128956,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -123140,9 +128970,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -123173,55 +129003,55 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(88 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { - return [decl].concat(getNamesToExportInCommonJS(decl).map(createExportAssignment)); + return __spreadArrays([decl], getNamesToExportInCommonJS(decl).map(createExportAssignment)); } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 225 /* ExpressionStatement */: + return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 60 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 62 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -123344,7 +129174,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -123376,7 +129206,7 @@ var ts; function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); var classNames = ts.isConstructorDeclaration(functionDeclaration) ? getClassNames(functionDeclaration) : []; - var names = ts.deduplicate(functionNames.concat(classNames), ts.equateValues); + var names = ts.deduplicate(__spreadArrays(functionNames, classNames), ts.equateValues); var checker = program.getTypeChecker(); var references = ts.flatMap(names, /*mapfn*/ function (/*mapfn*/ name) { return ts.FindAllReferences.getReferenceEntriesForNode(-1, name, program, program.getSourceFiles(), cancellationToken); }); var groupedReferences = groupReferences(references); @@ -123483,15 +129313,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -123501,7 +129331,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -123520,14 +129350,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -123569,11 +129399,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 161 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -123581,8 +129411,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -123592,7 +129422,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 81 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 83 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -123707,7 +129537,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(56 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, /*initializer*/ undefined); ts.suppressLeadingAndTrailingTrivia(propertySignature); copyComments(parameterDeclaration.name, propertySignature.name); @@ -123753,15 +129583,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 83 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -123772,30 +129602,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 83 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: - var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + case 161 /* Constructor */: + var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 128 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 213 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -123807,10 +129637,10 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 73 /* Identifier */ ? new IdentifierObject(73 /* Identifier */, pos, end) : + kind === 75 /* Identifier */ ? new IdentifierObject(75 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 12679168 /* ContextFlags */; + node.flags = parent.flags & 25358336 /* ContextFlags */; return node; } var NodeObject = /** @class */ (function () { @@ -123824,7 +129654,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -123881,8 +129711,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 312 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 292 /* FirstJSDocNode */ || kid.kind > 316 /* LastJSDocNode */; }); + return child.kind < 152 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -123893,7 +129723,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 152 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -123939,7 +129769,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 73 /* Identifier */) { + if (token === 75 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -123951,7 +129781,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(313 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(317 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -124074,7 +129904,9 @@ var ts; var IdentifierObject = /** @class */ (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { - return _super.call(this, pos, end) || this; + var _this = _super.call(this, pos, end) || this; + _this.kind = 75 /* Identifier */; + return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { get: function () { @@ -124085,7 +129917,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 73 /* Identifier */; + IdentifierObject.prototype.kind = 75 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -124121,9 +129953,15 @@ var ts; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; }; + TypeObject.prototype.isNullableType = function () { + return this.checker.isNullableType(this); + }; TypeObject.prototype.getNonNullableType = function () { return this.checker.getNonNullableType(this); }; + TypeObject.prototype.getNonOptionalType = function () { + return this.checker.getNonOptionalType(this); + }; TypeObject.prototype.getConstraint = function () { return this.checker.getBaseConstraintOfType(this); }; @@ -124228,7 +130066,9 @@ var ts; var SourceFileObject = /** @class */ (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - return _super.call(this, kind, pos, end) || this; + var _this = _super.call(this, kind, pos, end) || this; + _this.kind = 288 /* SourceFile */; + return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -124286,10 +130126,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -124309,31 +130149,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 172 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -124344,19 +130184,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 259 /* 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 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -124368,7 +130208,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -124377,7 +130217,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -124574,7 +130414,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -124694,16 +130534,20 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; }, getCurrentDirectory: function () { return currentDirectory; }, getProgram: getProgram, - fileExists: host.fileExists && (function (f) { return host.fileExists(f); }), - readFile: host.readFile && (function (f, encoding) { return host.readFile(f, encoding); }), - getDocumentPositionMapper: host.getDocumentPositionMapper && (function (generatedFileName, sourceFileName) { return host.getDocumentPositionMapper(generatedFileName, sourceFileName); }), - getSourceFileLike: host.getSourceFileLike && (function (f) { return host.getSourceFileLike(f); }), + fileExists: ts.maybeBind(host, host.fileExists), + readFile: ts.maybeBind(host, host.readFile), + getDocumentPositionMapper: ts.maybeBind(host, host.getDocumentPositionMapper), + getSourceFileLike: ts.maybeBind(host, host.getSourceFileLike), log: log }); function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - throw new Error("Could not find sourceFile: '" + fileName + "' in " + (program && JSON.stringify(program.getSourceFiles().map(function (f) { return f.fileName; }))) + "."); + var error = new Error("Could not find source file: '" + fileName + "'."); + // We've been having trouble debugging this, so attach sidecar data for the tsserver log. + // See https://github.com/microsoft/TypeScript/issues/30180. + error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); + throw error; } return sourceFile; } @@ -124772,13 +130616,29 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; + compilerHost.resolveModuleNames = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); + compilerHost.resolveTypeReferenceDirectives = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); }; } + if (host.setResolvedProjectReferenceCallbacks) { + compilerHost.setResolvedProjectReferenceCallbacks = function (callbacks) { return host.setResolvedProjectReferenceCallbacks(callbacks); }; + } + if (host.useSourceOfProjectReferenceRedirect) { + compilerHost.useSourceOfProjectReferenceRedirect = function () { return host.useSourceOfProjectReferenceRedirect(); }; + } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -124914,7 +130774,7 @@ var ts; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return semanticDiagnostics.concat(declarationDiagnostics); + return __spreadArrays(semanticDiagnostics, declarationDiagnostics); } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); @@ -124922,12 +130782,12 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + return __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names - var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); + var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } @@ -124939,7 +130799,7 @@ var ts; } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); - return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }); + return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host); } function getQuickInfoAtPosition(fileName, position) { synchronizeHostData(); @@ -124983,15 +130843,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 99 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 101 /* SuperKeyword */: return true; default: return false; @@ -125017,13 +130877,13 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }, highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); + var sourceFilesToSearch = ts.mapDefined(filesToSearch, function (fileName) { return program.getSourceFile(fileName); }); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -125093,16 +130953,16 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: case 10 /* StringLiteral */: - case 88 /* FalseKeyword */: - case 103 /* TrueKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 73 /* Identifier */: + case 90 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 75 /* Identifier */: break; // Cant create the text span default: @@ -125118,7 +130978,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 === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 248 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -125183,7 +131043,7 @@ var ts; _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, + _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -125307,7 +131167,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -125570,7 +131430,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 263 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -125586,14 +131446,15 @@ var ts; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 153 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 192 /* ObjectLiteralExpression */ || node.parent.parent.kind === 272 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -125635,7 +131496,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -125682,7 +131543,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 4194304 /* Ambient */) { + if (tokenAtLocation.flags & 8388608 /* Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -125715,114 +131576,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 190 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 156 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -125840,19 +131701,19 @@ var ts; return spanInOpenParenToken(node); case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 57 /* ColonToken */: + case 58 /* ColonToken */: return spanInColonToken(node); - case 30 /* GreaterThanToken */: - case 28 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return spanInWhileKeyword(node); - case 84 /* ElseKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + case 86 /* ElseKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 151 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -125864,14 +131725,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 === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + if ((node.kind === 75 /* Identifier */ || + node.kind === 212 /* SpreadElement */ || + node.kind === 279 /* PropertyAssignment */ || + node.kind === 280 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 208 /* 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 @@ -125880,7 +131741,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 60 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -125893,22 +131754,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 156 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 208 /* 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 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -125917,21 +131778,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 279 /* 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 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 241 /* VariableDeclaration */: + case 155 /* 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)) { @@ -125939,7 +131800,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -125969,7 +131830,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 230 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -125981,7 +131842,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 231 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -126022,7 +131883,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 244 /* ClassDeclaration */ && functionDeclaration.kind !== 161 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -126045,26 +131906,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 230 /* 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 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* 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 === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 242 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -126089,21 +131950,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 190 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 189 /* ArrayBindingPattern */ && node.kind !== 188 /* ObjectBindingPattern */); + var elements = node.kind === 191 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -126111,18 +131972,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 === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 208 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -126130,25 +131991,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 249 /* 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 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -126156,7 +132017,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 188 /* 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); @@ -126172,7 +132033,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 189 /* 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); @@ -126187,12 +132048,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 227 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 195 /* CallExpression */ || + node.parent.kind === 196 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 199 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -126201,21 +132062,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 199 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -126225,20 +132086,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 279 /* PropertyAssignment */ || + node.parent.kind === 155 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 198 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 227 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -126246,7 +132107,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 231 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -126291,10 +132152,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -126316,9 +132176,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -126389,6 +132251,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -126417,6 +132280,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -126428,6 +132292,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -126571,13 +132436,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -126585,13 +132450,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -126962,7 +132828,7 @@ var ts; typeAcquisition: configFile.typeAcquisition, files: configFile.fileNames, raw: configFile.raw, - errors: realizeDiagnostics(result.parseDiagnostics.concat(configFile.errors), "\r\n") + errors: realizeDiagnostics(__spreadArrays(result.parseDiagnostics, configFile.errors), "\r\n") }; }); }; @@ -127049,8 +132915,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; @@ -127186,11 +133051,13 @@ var ts; } }; ThrottledOperations.run = function (self, operationId, cb) { + ts.perfLogger.logStartScheduledOperation(operationId); self.pendingTimeouts.delete(operationId); if (self.logger) { self.logger.info("Running: " + operationId); } cb(); + ts.perfLogger.logStopScheduledOperation(); }; return ThrottledOperations; }()); @@ -127210,6 +133077,7 @@ var ts; }; GcTimer.run = function (self) { self.timerId = undefined; + ts.perfLogger.logStartScheduledOperation("GC collect"); var log = self.logger.hasLevel(server.LogLevel.requestTime); var before = log && self.host.getMemoryUsage(); // TODO: GH#18217 self.host.gc(); // TODO: GH#18217 @@ -127217,6 +133085,7 @@ var ts; var after = self.host.getMemoryUsage(); // TODO: GH#18217 self.logger.perftrc("GC::before " + before + ", after " + after); } + ts.perfLogger.logStopScheduledOperation(); }; return GcTimer; }()); @@ -127263,9 +133132,10 @@ var ts; WatchType["MissingSourceMapFile"] = "Missing source map file"; WatchType["NoopConfigFileForInferredRoot"] = "Noop Config file for the inferred project root"; WatchType["MissingGeneratedFile"] = "Missing generated file"; + WatchType["PackageJsonFile"] = "package.json file for import suggestions"; })(WatchType = ts.WatchType || (ts.WatchType = {})); })(ts || (ts = {})); -// tslint:disable no-unnecessary-qualifier +/* eslint-disable @typescript-eslint/no-unnecessary-qualifier */ /** * Declaration module describing the TypeScript Server protocol */ @@ -127414,6 +133284,12 @@ var ts; IndentStyle["Block"] = "Block"; IndentStyle["Smart"] = "Smart"; })(IndentStyle = protocol.IndentStyle || (protocol.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = protocol.SemicolonPreference || (protocol.SemicolonPreference = {})); var JsxEmit; (function (JsxEmit) { JsxEmit["None"] = "None"; @@ -127843,16 +133719,20 @@ var ts; // the default project; if no configured projects, the first external project should // be the default project; otherwise the first inferred project should be the default. var firstExternalProject = void 0; + var firstConfiguredProject = void 0; for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { var project = _a[_i]; if (project.projectKind === server.ProjectKind.Configured) { - return project; + if (!project.isSourceOfProjectReferenceRedirect(this.fileName)) + return project; + if (!firstConfiguredProject) + firstConfiguredProject = project; } else if (project.projectKind === server.ProjectKind.External && !firstExternalProject) { firstExternalProject = project; } } - return firstExternalProject || this.containingProjects[0]; + return firstConfiguredProject || firstExternalProject || this.containingProjects[0]; } }; ScriptInfo.prototype.registerFileUpdate = function () { @@ -127868,14 +133748,14 @@ var ts; ts.assign(this.formatSettings, formatSettings); } else { - this.formatSettings = __assign({}, this.formatSettings, formatSettings); + this.formatSettings = __assign(__assign({}, this.formatSettings), formatSettings); } } if (preferences) { if (!this.preferences) { this.preferences = ts.emptyOptions; } - this.preferences = __assign({}, this.preferences, preferences); + this.preferences = __assign(__assign({}, this.preferences), preferences); } }; ScriptInfo.prototype.getLatestVersion = function () { @@ -127915,7 +133795,7 @@ var ts; ScriptInfo.prototype.markContainingProjectsAsDirty = function () { for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { var p = _a[_i]; - p.markAsDirty(); + p.markFileAsDirty(this.path); } }; ScriptInfo.prototype.isOrphan = function () { @@ -128195,6 +134075,8 @@ var ts; /*@internal*/ this.typingFiles = server.emptyArray; /*@internal*/ + this.importSuggestionsCache = ts.Completions.createImportSuggestionsForFileCache(); + /*@internal*/ this.globalCacheResolutionModuleName = ts.JsTyping.nonRelativeModuleNameForTypingCache; this.directoryStructureHost = directoryStructureHost; this.currentDirectory = this.projectService.getNormalizedAbsolutePath(currentDirectory || ""); @@ -128229,7 +134111,12 @@ var ts; } this.markAsDirty(); this.projectService.pendingEnsureProjectForOpenFiles = true; + this.packageJsonCache = server.createPackageJsonCache(this); } + /*@internal*/ + Project.prototype.getResolvedProjectReferenceToRedirect = function (_fileName) { + return undefined; + }; Project.prototype.isNonTsProject = function () { server.updateProjectIfDirty(this); return allFilesAreJsOrDts(this); @@ -128253,7 +134140,7 @@ var ts; return this.typingsCache.isKnownTypesPackageName(name); }; Project.prototype.installPackage = function (options) { - return this.typingsCache.installPackage(__assign({}, options, { projectName: this.projectName, projectRootPath: this.toPath(this.currentDirectory) })); + return this.typingsCache.installPackage(__assign(__assign({}, options), { projectName: this.projectName, projectRootPath: this.toPath(this.currentDirectory) })); }; Object.defineProperty(Project.prototype, "typingsCache", { get: function () { @@ -128262,6 +134149,10 @@ var ts; enumerable: true, configurable: true }); + /*@internal*/ + Project.prototype.getProbableSymlinks = function (files) { + return this.symlinks || (this.symlinks = ts.discoverProbableSymlinks(files, this.getCanonicalFileName, this.getCurrentDirectory())); + }; // Method of LanguageServiceHost Project.prototype.getCompilationSettings = function () { return this.compilerOptions; @@ -128343,6 +134234,10 @@ var ts; return this.projectService.host.writeFile(fileName, content); }; Project.prototype.fileExists = function (file) { + return this.fileExistsWithCache(file); + }; + /* @internal */ + Project.prototype.fileExistsWithCache = function (file) { // As an optimization, don't hit the disks for files we already know don't exist // (because we're watching for their creation). var path = this.toPath(file); @@ -128439,8 +134334,11 @@ var ts; Project.prototype.getSourceFileLike = function (fileName) { return this.projectService.getSourceFileLike(fileName, this); }; + /*@internal*/ Project.prototype.shouldEmitFile = function (scriptInfo) { - return scriptInfo && !scriptInfo.isDynamicOrHasMixedContent(); + return scriptInfo && + !scriptInfo.isDynamicOrHasMixedContent() && + !this.program.isSourceOfProjectReferenceRedirect(scriptInfo.path); }; Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { var _this = this; @@ -128499,7 +134397,7 @@ var ts; // Nothing to filter out, so just return as-is return newTypeAcquisition; } - return __assign({}, newTypeAcquisition, { include: this.removeExistingTypings(newTypeAcquisition.include) }); + return __assign(__assign({}, newTypeAcquisition), { include: this.removeExistingTypings(newTypeAcquisition.include) }); }; Project.prototype.getExternalFiles = function () { var _this = this; @@ -128566,6 +134464,10 @@ var ts; ts.clearMap(this.missingFilesMap, ts.closeFileWatcher); this.missingFilesMap = undefined; } + if (this.packageJsonFilesMap) { + ts.clearMap(this.packageJsonFilesMap, ts.closeFileWatcher); + this.packageJsonFilesMap = undefined; + } this.clearGeneratedFileWatch(); // signal language service to release source files acquired from document registry this.languageService.dispose(); @@ -128722,6 +134624,13 @@ var ts; Project.prototype.registerFileUpdate = function (fileName) { (this.updatedFileNames || (this.updatedFileNames = ts.createMap())).set(fileName, true); }; + /*@internal*/ + Project.prototype.markFileAsDirty = function (changedFile) { + this.markAsDirty(); + if (!this.importSuggestionsCache.isEmpty()) { + (this.dirtyFilesForSuggestions || (this.dirtyFilesForSuggestions = ts.createMap())).set(changedFile, true); + } + }; Project.prototype.markAsDirty = function () { if (!this.dirty) { this.projectStateVersion++; @@ -128737,6 +134646,7 @@ var ts; * @returns: true if set of files in the project stays the same and false - otherwise. */ Project.prototype.updateGraph = function () { + ts.perfLogger.logStartUpdateGraph(); this.resolutionCache.startRecordingFilesWithChangedResolutions(); var hasNewProgram = this.updateGraphWorker(); var hasAddedorRemovedFiles = this.hasAddedorRemovedFiles; @@ -128767,6 +134677,7 @@ var ts; if (hasNewProgram) { this.projectProgramVersion++; } + ts.perfLogger.logStopUpdateGraph(); return !hasNewProgram; }; /*@internal*/ @@ -128855,6 +134766,27 @@ var ts; this.resolutionCache.updateTypeRootsWatch(); } } + if (!this.importSuggestionsCache.isEmpty()) { + if (this.hasAddedorRemovedFiles || oldProgram && !oldProgram.structureIsReused) { + this.importSuggestionsCache.clear(); + } + else if (this.dirtyFilesForSuggestions && oldProgram && this.program) { + ts.forEachKey(this.dirtyFilesForSuggestions, function (fileName) { + var oldSourceFile = oldProgram.getSourceFile(fileName); + var sourceFile = _this.program.getSourceFile(fileName); + if (_this.sourceFileHasChangedOwnImportSuggestions(oldSourceFile, sourceFile)) { + _this.importSuggestionsCache.clear(); + return true; + } + }); + } + } + if (this.dirtyFilesForSuggestions) { + this.dirtyFilesForSuggestions.clear(); + } + if (this.hasAddedorRemovedFiles) { + this.symlinks = undefined; + } var oldExternalFiles = this.externalFiles || server.emptyArray; this.externalFiles = this.getExternalFiles(); ts.enumerateInsertsAndDeletes(this.externalFiles, oldExternalFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), @@ -128867,11 +134799,62 @@ var ts; }, function (removed) { return _this.detachScriptInfoFromProject(removed); }); var elapsed = ts.timestamp() - start; this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + " Elapsed: " + elapsed + "ms"); - if (this.program !== oldProgram) { + if (this.hasAddedorRemovedFiles) { this.print(); } + else if (this.program !== oldProgram) { + this.writeLog("Different program with same set of files:: oldProgram.structureIsReused:: " + (oldProgram && oldProgram.structureIsReused)); + } return hasNewProgram; }; + /*@internal*/ + Project.prototype.sourceFileHasChangedOwnImportSuggestions = function (oldSourceFile, newSourceFile) { + if (!oldSourceFile && !newSourceFile) { + return false; + } + // Probably shouldn’t get this far, but on the off chance the file was added or removed, + // we can’t reliably tell anything about it. + if (!oldSourceFile || !newSourceFile) { + return true; + } + ts.Debug.assertEqual(oldSourceFile.fileName, newSourceFile.fileName); + // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. + // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. + if (this.getTypeAcquisition().enable && ts.consumesNodeCoreModules(oldSourceFile) !== ts.consumesNodeCoreModules(newSourceFile)) { + return true; + } + // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. + // Changes elsewhere in the file can change the *type* of an export in a module augmentation, + // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. + if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || + !this.ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { + return true; + } + return false; + }; + /*@internal*/ + Project.prototype.ambientModuleDeclarationsAreEqual = function (oldSourceFile, newSourceFile) { + if (!ts.arrayIsEqualTo(oldSourceFile.ambientModuleNames, newSourceFile.ambientModuleNames)) { + return false; + } + var oldFileStatementIndex = -1; + var newFileStatementIndex = -1; + var _loop_1 = function (ambientModuleName) { + var isMatchingModuleDeclaration = function (node) { return ts.isNonGlobalAmbientModule(node) && node.name.text === ambientModuleName; }; + oldFileStatementIndex = ts.findIndex(oldSourceFile.statements, isMatchingModuleDeclaration, oldFileStatementIndex + 1); + newFileStatementIndex = ts.findIndex(newSourceFile.statements, isMatchingModuleDeclaration, newFileStatementIndex + 1); + if (oldSourceFile.statements[oldFileStatementIndex] !== newSourceFile.statements[newFileStatementIndex]) { + return { value: false }; + } + }; + for (var _i = 0, _a = newSourceFile.ambientModuleNames; _i < _a.length; _i++) { + var ambientModuleName = _a[_i]; + var state_1 = _loop_1(ambientModuleName); + if (typeof state_1 === "object") + return state_1.value; + } + return true; + }; Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName, noRemoveResolution) { var scriptInfoToDetach = this.projectService.getScriptInfo(uncheckedFileName); if (scriptInfoToDetach) { @@ -129048,6 +135031,10 @@ var ts; ts.orderedRemoveItem(this.rootFiles, info); this.rootFilesMap.delete(info.path); }; + /*@internal*/ + Project.prototype.isSourceOfProjectReferenceRedirect = function (fileName) { + return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName); + }; Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { @@ -129056,9 +135043,9 @@ var ts; } // Search our peer node_modules, then any globally-specified probe paths // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ - var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); + var searchPaths = __spreadArrays([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations); if (this.projectService.globalPlugins) { - var _loop_1 = function (globalPluginName) { + var _loop_2 = function (globalPluginName) { // Skip empty names from odd commandline parses if (!globalPluginName) return "continue"; @@ -129073,7 +135060,7 @@ var ts; // Enable global plugins with synthetic configuration entries for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) { var globalPluginName = _a[_i]; - _loop_1(globalPluginName); + _loop_2(globalPluginName); } } }; @@ -129104,7 +135091,7 @@ var ts; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { - this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did expose a proper factory function"); + this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did not expose a proper factory function"); return; } var info = { @@ -129118,6 +135105,7 @@ var ts; var newLS = pluginModule.create(info); for (var _i = 0, _a = Object.keys(this.languageService); _i < _a.length; _i++) { var k = _a[_i]; + // eslint-disable-next-line no-in-operator if (!(k in newLS)) { this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); newLS[k] = this.languageService[k]; @@ -129143,6 +135131,61 @@ var ts; Project.prototype.refreshDiagnostics = function () { this.projectService.sendProjectsUpdatedInBackgroundEvent(); }; + /*@internal*/ + Project.prototype.getPackageJsonsVisibleToFile = function (fileName, rootDir) { + var packageJsonCache = this.packageJsonCache; + var watchPackageJsonFile = this.watchPackageJsonFile.bind(this); + var toPath = this.toPath.bind(this); + var rootPath = rootDir && toPath(rootDir); + var filePath = toPath(fileName); + var result = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(filePath), function processDirectory(directory) { + switch (packageJsonCache.directoryHasPackageJson(directory)) { + // Sync and check same directory again + case 1 /* Maybe */: + packageJsonCache.searchDirectoryAndAncestors(directory); + return processDirectory(directory); + // Check package.json + case -1 /* True */: + var packageJsonFileName = ts.combinePaths(directory, "package.json"); + watchPackageJsonFile(packageJsonFileName); + result.push(ts.Debug.assertDefined(packageJsonCache.getInDirectory(directory))); + } + if (rootPath && rootPath === toPath(directory)) { + return true; + } + }); + return result; + }; + /*@internal*/ + Project.prototype.onAddPackageJson = function (path) { + this.packageJsonCache.addOrUpdate(path); + this.watchPackageJsonFile(path); + }; + /*@internal*/ + Project.prototype.getImportSuggestionsCache = function () { + return this.importSuggestionsCache; + }; + Project.prototype.watchPackageJsonFile = function (path) { + var _this = this; + var watchers = this.packageJsonFilesMap || (this.packageJsonFilesMap = ts.createMap()); + if (!watchers.has(path)) { + watchers.set(path, this.projectService.watchFactory.watchFile(this.projectService.host, path, function (fileName, eventKind) { + var path = _this.toPath(fileName); + switch (eventKind) { + case ts.FileWatcherEventKind.Created: + return ts.Debug.fail(); + case ts.FileWatcherEventKind.Changed: + _this.packageJsonCache.addOrUpdate(path); + break; + case ts.FileWatcherEventKind.Deleted: + _this.packageJsonCache.delete(path); + watchers.get(path).close(); + watchers.delete(path); + } + }, ts.PollingInterval.Low, "package.json file for import suggestions" /* PackageJsonFile */)); + } + }; return Project; }()); server.Project = Project; @@ -129282,9 +135325,63 @@ var ts; _this.isInitialLoadPending = ts.returnTrue; /*@internal*/ _this.sendLoadingProjectFinish = false; + /* @internal */ + _this.useSourceOfProjectReferenceRedirect = function () { return !!_this.languageServiceEnabled && + !_this.getCompilerOptions().disableSourceOfProjectReferenceRedirect; }; _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); return _this; } + /* @internal */ + ConfiguredProject.prototype.setResolvedProjectReferenceCallbacks = function (projectReferenceCallbacks) { + this.projectReferenceCallbacks = projectReferenceCallbacks; + }; + /** + * This implementation of fileExists checks if the file being requested is + * .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that file exists on host + */ + ConfiguredProject.prototype.fileExists = function (file) { + // Project references go to source file instead of .d.ts file + if (this.useSourceOfProjectReferenceRedirect() && this.projectReferenceCallbacks) { + var source = this.projectReferenceCallbacks.getSourceOfProjectReferenceRedirect(file); + if (source) + return ts.isString(source) ? _super.prototype.fileExists.call(this, source) : true; + } + return _super.prototype.fileExists.call(this, file); + }; + /** + * This implementation of directoryExists checks if the directory being requested is + * directory of .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that directory exists on host + */ + ConfiguredProject.prototype.directoryExists = function (path) { + var _this = this; + if (_super.prototype.directoryExists.call(this, path)) + return true; + if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) + return false; + if (!this.mapOfDeclarationDirectories) { + this.mapOfDeclarationDirectories = ts.createMap(); + this.projectReferenceCallbacks.forEachResolvedProjectReference(function (ref) { + if (!ref) + return; + var out = ref.commandLine.options.outFile || ref.commandLine.options.outDir; + if (out) { + _this.mapOfDeclarationDirectories.set(ts.getDirectoryPath(_this.toPath(out)), true); + } + else { + // Set declaration's in different locations only, if they are next to source the directory present doesnt change + var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir; + if (declarationDir) { + _this.mapOfDeclarationDirectories.set(_this.toPath(declarationDir), true); + } + } + }); + } + var dirPath = this.toPath(path); + var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + return !!ts.forEachKey(this.mapOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator); }); + }; /** * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph * @returns: true if set of files in the project stays the same and false - otherwise. @@ -129293,6 +135390,8 @@ var ts; this.isInitialLoadPending = ts.returnFalse; var reloadLevel = this.pendingReload; this.pendingReload = ts.ConfigFileProgramReloadLevel.None; + this.projectReferenceCallbacks = undefined; + this.mapOfDeclarationDirectories = undefined; var result; switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: @@ -129330,6 +135429,11 @@ var ts; return program && program.forEachResolvedProjectReference(cb); }; /*@internal*/ + ConfiguredProject.prototype.getResolvedProjectReferenceToRedirect = function (fileName) { + var program = this.getCurrentProgram(); + return program && program.getResolvedProjectReferenceToRedirect(fileName); + }; + /*@internal*/ ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { @@ -129338,7 +135442,7 @@ var ts; } // Search our peer node_modules, then any globally-specified probe paths // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ - var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); + var searchPaths = __spreadArrays([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations); if (this.projectService.allowLocalPluginLoads) { var local = ts.getDirectoryPath(this.canonicalConfigFilePath); this.projectService.logger.info("Local plugin loading enabled; adding " + local + " to search paths"); @@ -129396,6 +135500,8 @@ var ts; this.stopWatchingWildCards(); this.projectErrors = undefined; this.configFileSpecs = undefined; + this.projectReferenceCallbacks = undefined; + this.mapOfDeclarationDirectories = undefined; _super.prototype.close.call(this); }; /* @internal */ @@ -129489,7 +135595,6 @@ var ts; server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; /*@internal*/ server.maxFileSize = 4 * 1024 * 1024; - // tslint:disable variable-name server.ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; server.ProjectLoadingStartEvent = "projectLoadingStart"; server.ProjectLoadingFinishEvent = "projectLoadingFinish"; @@ -130059,7 +136164,7 @@ var ts; }; ProjectService.prototype.getPreferences = function (file) { var info = this.getScriptInfoForNormalizedPath(file); - return __assign({}, this.hostConfiguration.preferences, info && info.getPreferences()); + return __assign(__assign({}, this.hostConfiguration.preferences), info && info.getPreferences()); }; ProjectService.prototype.getHostFormatCodeOptions = function () { return this.hostConfiguration.formatCodeOptions; @@ -130146,7 +136251,7 @@ var ts; var _this = this; return this.watchFactory.watchDirectory(this.host, directory, function (fileOrDirectory) { var fileOrDirectoryPath = _this.toPath(fileOrDirectory); - project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + var fsResult = project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); // don't trigger callback on open, existing files if (project.fileIsOpen(fileOrDirectoryPath)) { return; @@ -130154,6 +136259,11 @@ var ts; if (ts.isPathIgnored(fileOrDirectoryPath)) return; var configFilename = project.getConfigFilePath(); + if (ts.getBaseFileName(fileOrDirectoryPath) === "package.json" && !ts.isInsideNodeModules(fileOrDirectoryPath) && + (fsResult && fsResult.fileExists || !fsResult && _this.host.fileExists(fileOrDirectoryPath))) { + _this.logger.info("Project: " + configFilename + " Detected new package.json: " + fileOrDirectory); + project.onAddPackageJson(fileOrDirectoryPath); + } // 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, project.getCompilationSettings(), _this.hostConfiguration.extraFileExtensions)) { @@ -130257,7 +136367,7 @@ var ts; } project.updateGraph(); if (!this.useSingleInferredProject && !project.projectRootPath) { - var _loop_2 = function (inferredProject) { + var _loop_3 = function (inferredProject) { if (inferredProject === project || inferredProject.isOrphan()) { return "continue"; } @@ -130278,7 +136388,7 @@ var ts; // Note that we need to create a copy of the array since the list of project can change for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var inferredProject = _a[_i]; - _loop_2(inferredProject); + _loop_3(inferredProject); } } return project; @@ -130797,6 +136907,11 @@ var ts; if (parsedCommandLine.errors.length) { configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); } + this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ + rootNames: parsedCommandLine.fileNames, + options: parsedCommandLine.options, + projectReferences: parsedCommandLine.projectReferences + }, /*replacer*/ undefined, " ")); ts.Debug.assert(!!parsedCommandLine.fileNames); var compilerOptions = parsedCommandLine.options; // Update the project @@ -130823,7 +136938,7 @@ var ts; } 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 + this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); }; ProjectService.prototype.updateNonInferredProjectFiles = function (project, files, propertyReader) { var projectRootFilesMap = project.getRootFilesMap(); @@ -130836,7 +136951,7 @@ var ts; var scriptInfo = void 0; var path = void 0; // Use the project's fileExists so that it can use caching instead of reaching to disk for the query - if (!isDynamic && !project.fileExists(newRootFile)) { + if (!isDynamic && !project.fileExistsWithCache(newRootFile)) { path = server.normalizedPathToPath(normalizedPath, this.currentDirectory, this.toCanonicalFileName); var existingValue = projectRootFilesMap.get(path); if (server.isScriptInfo(existingValue)) { @@ -130868,7 +136983,7 @@ var ts; projectRootFilesMap.forEach(function (value, path) { if (!newRootScriptInfoMap.has(path)) { if (server.isScriptInfo(value)) { - project.removeFile(value, project.fileExists(path), /*detachFromProject*/ true); + project.removeFile(value, project.fileExistsWithCache(path), /*detachFromProject*/ true); } else { projectRootFilesMap.delete(path); @@ -131047,7 +137162,7 @@ var ts; return projects; function combineProjects(toAddInfo) { if (toAddInfo !== info) { - var _loop_3 = function (project) { + var _loop_4 = function (project) { // Add the projects only if they can use symLink targets and not already in the list if (project.languageServiceEnabled && !project.isOrphan() && @@ -131064,7 +137179,7 @@ var ts; }; for (var _i = 0, _a = toAddInfo.containingProjects; _i < _a.length; _i++) { var project = _a[_i]; - _loop_3(project); + _loop_4(project); } } } @@ -131374,12 +137489,12 @@ var ts; this.logger.info("Host information " + args.hostInfo); } if (args.formatOptions) { - this.hostConfiguration.formatCodeOptions = __assign({}, this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); + this.hostConfiguration.formatCodeOptions = __assign(__assign({}, this.hostConfiguration.formatCodeOptions), convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } if (args.preferences) { var lazyConfiguredProjectsFromExternalProject = this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject; - this.hostConfiguration.preferences = __assign({}, this.hostConfiguration.preferences, args.preferences); + this.hostConfiguration.preferences = __assign(__assign({}, this.hostConfiguration.preferences), args.preferences); if (lazyConfiguredProjectsFromExternalProject && !this.hostConfiguration.preferences.lazyConfiguredProjectsFromExternalProject) { // Load configured projects for external projects that are pending reload this.configuredProjects.forEach(function (project) { @@ -131529,7 +137644,9 @@ var ts; }; /*@internal*/ ProjectService.prototype.getOriginalLocationEnsuringConfiguredProject = function (project, location) { - var originalLocation = project.getSourceMapper().tryGetSourcePosition(location); + var originalLocation = project.isSourceOfProjectReferenceRedirect(location.fileName) ? + location : + project.getSourceMapper().tryGetSourcePosition(location); if (!originalLocation) return undefined; var fileName = originalLocation.fileName; @@ -131540,7 +137657,9 @@ var ts; if (!configFileName) return undefined; var configuredProject = this.findConfiguredProjectByProjectName(configFileName) || - this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + " for location: " + location.fileName); + this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + if (configuredProject === project) + return originalLocation; updateProjectIfDirty(configuredProject); // Keep this configured project as referenced from project addOriginalConfiguredProject(configuredProject); @@ -131581,6 +137700,7 @@ var ts; var configFileName; var configFileErrors; var project = this.findExternalProjectContainingOpenScriptInfo(info); + var defaultConfigProject; if (!project && !this.syntaxOnly) { // Checking syntaxOnly is an optimization configFileName = this.getConfigFileNameForFile(info); if (configFileName) { @@ -131601,6 +137721,7 @@ var ts; // Ensure project is ready to check if it contains opened script info updateProjectIfDirty(project); } + defaultConfigProject = project; } } // Project we have at this point is going to be updated since its either found through @@ -131617,12 +137738,12 @@ var ts; this.assignOrphanScriptInfoToInferredProject(info, this.openFiles.get(info.path)); } ts.Debug.assert(!info.isOrphan()); - return { configFileName: configFileName, configFileErrors: configFileErrors }; + return { configFileName: configFileName, configFileErrors: configFileErrors, defaultConfigProject: defaultConfigProject }; }; - ProjectService.prototype.cleanupAfterOpeningFile = function () { + ProjectService.prototype.cleanupAfterOpeningFile = function (toRetainConfigProjects) { // This was postponed from closeOpenFile to after opening next file, // so that we can reuse the project if we need to right away - this.removeOrphanConfiguredProjects(); + this.removeOrphanConfiguredProjects(toRetainConfigProjects); // Remove orphan inferred projects now that we have reused projects // We need to create a duplicate because we cant guarantee order after removal for (var _i = 0, _a = this.inferredProjects.slice(); _i < _a.length; _i++) { @@ -131636,25 +137757,33 @@ var ts; // It was then postponed to cleanup these script infos so that they can be reused if // the file from that old project is reopened because of opening file from here. this.removeOrphanScriptInfos(); - this.printProjects(); }; ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent, projectRootPath) { var info = this.getOrCreateOpenScriptInfo(fileName, fileContent, scriptKind, hasMixedContent, projectRootPath); - var result = this.assignProjectToOpenedScriptInfo(info); - this.cleanupAfterOpeningFile(); + var _a = this.assignProjectToOpenedScriptInfo(info), defaultConfigProject = _a.defaultConfigProject, result = __rest(_a, ["defaultConfigProject"]); + this.cleanupAfterOpeningFile(defaultConfigProject); this.telemetryOnOpenFile(info); + this.printProjects(); return result; }; - ProjectService.prototype.removeOrphanConfiguredProjects = function () { + ProjectService.prototype.removeOrphanConfiguredProjects = function (toRetainConfiguredProjects) { var _this = this; var toRemoveConfiguredProjects = ts.cloneMap(this.configuredProjects); + if (toRetainConfiguredProjects) { + if (ts.isArray(toRetainConfiguredProjects)) { + toRetainConfiguredProjects.forEach(retainConfiguredProject); + } + else { + retainConfiguredProject(toRetainConfiguredProjects); + } + } // Do not remove configured projects that are used as original projects of other this.inferredProjects.forEach(markOriginalProjectsAsUsed); this.externalProjects.forEach(markOriginalProjectsAsUsed); this.configuredProjects.forEach(function (project) { // If project has open ref (there are more than zero references from external project/open file), keep it alive as well as any project it references if (project.hasOpenRef()) { - toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + retainConfiguredProject(project); markOriginalProjectsAsUsed(project); } else { @@ -131663,7 +137792,7 @@ var ts; if (ref) { var refProject = _this.configuredProjects.get(ref.sourceFile.path); if (refProject && refProject.hasOpenRef()) { - toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + retainConfiguredProject(project); } } }); @@ -131676,6 +137805,9 @@ var ts; project.originalConfiguredProjects.forEach(function (_value, configuredProjectPath) { return toRemoveConfiguredProjects.delete(configuredProjectPath); }); } } + function retainConfiguredProject(project) { + toRemoveConfiguredProjects.delete(project.canonicalConfigFilePath); + } }; ProjectService.prototype.removeOrphanScriptInfos = function () { var _this = this; @@ -131748,13 +137880,13 @@ var ts; return result; }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_4 = function (proj) { + var _loop_5 = function (proj) { var knownProject = ts.find(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName(); }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_4(proj); + _loop_5(proj); } }; /* @internal */ @@ -131803,18 +137935,24 @@ var ts; } } // All the script infos now exist, so ok to go update projects for open files + var defaultConfigProjects; if (openScriptInfos) { - openScriptInfos.forEach(function (info) { return _this.assignProjectToOpenedScriptInfo(info); }); + defaultConfigProjects = ts.mapDefined(openScriptInfos, function (info) { return _this.assignProjectToOpenedScriptInfo(info).defaultConfigProject; }); } // While closing files there could be open files that needed assigning new inferred projects, do it now if (assignOrphanScriptInfosToInferredProject) { this.assignOrphanScriptInfosToInferredProject(); } - // Cleanup projects - this.cleanupAfterOpeningFile(); - // Telemetry - ts.forEach(openScriptInfos, function (info) { return _this.telemetryOnOpenFile(info); }); - this.printProjects(); + if (openScriptInfos) { + // Cleanup projects + this.cleanupAfterOpeningFile(defaultConfigProjects); + // Telemetry + openScriptInfos.forEach(function (info) { return _this.telemetryOnOpenFile(info); }); + this.printProjects(); + } + else if (ts.length(closedFiles)) { + this.printProjects(); + } }; /* @internal */ ProjectService.prototype.applyChangesToFile = function (scriptInfo, changes) { @@ -131891,7 +138029,7 @@ var ts; var excludeRules = []; var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); var excludedFiles = []; - var _loop_5 = function (name) { + var _loop_6 = function (name) { var rule = this_2.safelist[name]; for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) { var root = normalizedNames_1[_i]; @@ -131909,7 +138047,7 @@ var ts; } } if (rule.exclude) { - var _loop_7 = function (exclude) { + var _loop_8 = function (exclude) { var processedRule = root.replace(rule.match, function () { var groups = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -131936,7 +138074,7 @@ var ts; }; for (var _c = 0, _d = rule.exclude; _c < _d.length; _c++) { var exclude = _d[_c]; - _loop_7(exclude); + _loop_8(exclude); } } else { @@ -131952,11 +138090,11 @@ var ts; var this_2 = this; for (var _i = 0, _a = Object.keys(this.safelist); _i < _a.length; _i++) { var name = _a[_i]; - _loop_5(name); + _loop_6(name); } var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); var filesToKeep = []; - var _loop_6 = function (i) { + var _loop_7 = function (i) { if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) { excludedFiles.push(normalizedNames[i]); } @@ -131994,7 +138132,7 @@ var ts; }; var this_3 = this; for (var i = 0; i < proj.rootFiles.length; i++) { - _loop_6(i); + _loop_7(i); } proj.rootFiles = filesToKeep; return excludedFiles; @@ -132152,6 +138290,55 @@ var ts; } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + var server; + (function (server) { + function createPackageJsonCache(project) { + var packageJsons = ts.createMap(); + var directoriesWithoutPackageJson = ts.createMap(); + return { + addOrUpdate: addOrUpdate, + delete: function (fileName) { + packageJsons.delete(fileName); + directoriesWithoutPackageJson.set(ts.getDirectoryPath(fileName), true); + }, + getInDirectory: function (directory) { + return packageJsons.get(ts.combinePaths(directory, "package.json")); + }, + directoryHasPackageJson: directoryHasPackageJson, + searchDirectoryAndAncestors: function (directory) { + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (directoryHasPackageJson(ancestor) !== 1 /* Maybe */) { + return true; + } + var packageJsonFileName = project.toPath(ts.combinePaths(ancestor, "package.json")); + if (ts.tryFileExists(project, packageJsonFileName)) { + addOrUpdate(packageJsonFileName); + } + else { + directoriesWithoutPackageJson.set(ancestor, true); + } + }); + }, + }; + function addOrUpdate(fileName) { + var packageJsonInfo = ts.createPackageJsonInfo(fileName, project); + if (packageJsonInfo) { + packageJsons.set(fileName, packageJsonInfo); + directoriesWithoutPackageJson.delete(ts.getDirectoryPath(fileName)); + } + } + function directoryHasPackageJson(directory) { + return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* True */ : + directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : + 1 /* Maybe */; + } + } + server.createPackageJsonCache = createPackageJsonCache; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); var ts; (function (ts) { var server; @@ -132186,6 +138373,9 @@ var ts; } return false; } + function dtsChangeCanAffectEmit(compilationSettings) { + return ts.getEmitDeclarations(compilationSettings) || !!compilationSettings.emitDecoratorMetadata; + } function formatDiag(fileName, project, diag) { var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); // TODO: GH#18217 return { @@ -132238,12 +138428,12 @@ var ts; relatedInformation: ts.map(diag.relatedInformation, formatRelatedInformation), }; return includeFileName - ? __assign({}, common, { fileName: diag.file && diag.file.fileName }) : common; + ? __assign(__assign({}, common), { fileName: diag.file && diag.file.fileName }) : common; } function allEditsBeforePos(edits, pos) { return edits.every(function (edit) { return ts.textSpanEnd(edit.span) < pos; }); } - server.CommandNames = server.protocol.CommandTypes; // tslint:disable-line variable-name + server.CommandNames = server.protocol.CommandTypes; function formatMessage(msg, logger, byteLength, newLine) { var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); @@ -132399,10 +138589,10 @@ var ts; var outputs = []; combineProjectOutputWorker(projects, defaultProject, initialLocation, function (_a, getMappedLocation) { var project = _a.project, location = _a.location; - var _loop_8 = function (outputReferencedSymbol) { + var _loop_9 = function (outputReferencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); var definition = mappedDefinitionFile === undefined ? - outputReferencedSymbol.definition : __assign({}, outputReferencedSymbol.definition, { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); + outputReferencedSymbol.definition : __assign(__assign({}, outputReferencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); var symbolToAddTo = ts.find(outputs, function (o) { return ts.documentSpansEqual(o.definition, definition); }); if (!symbolToAddTo) { symbolToAddTo = { definition: definition, references: [] }; @@ -132418,7 +138608,7 @@ var ts; }; 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); + _loop_9(outputReferencedSymbol); } }, function () { return getDefinitionLocation(defaultProject, initialLocation); }); return outputs.filter(function (o) { return o.references.length !== 0; }); @@ -132452,7 +138642,7 @@ var ts; projectService.forEachEnabledProject(function (project) { if (!ts.addToSeen(seenProjects, project.projectName)) return; - var definition = getDefinitionInProject(memGetDefinition_1(), defaultProject, project); + var definition = mapDefinitionInProject(memGetDefinition_1(), defaultProject, project); if (definition) { toDo = callbackProjectAndLocation({ project: project, location: definition }, projectService, toDo, seenProjects, cb); } @@ -132462,15 +138652,41 @@ var ts; toDo = callbackProjectAndLocation(ts.Debug.assertDefined(toDo.pop()), projectService, toDo, seenProjects, cb); } } - function getDefinitionInProject(definition, definingProject, project) { - if (!definition || project.containsFile(server.toNormalizedPath(definition.fileName))) + function mapDefinitionInProject(definition, definingProject, project) { + // If the definition is actually from the project, definition is correct as is + if (!definition || + project.containsFile(server.toNormalizedPath(definition.fileName)) && + !isLocationProjectReferenceRedirect(project, definition)) { return definition; - var mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); + } + var mappedDefinition = definingProject.isSourceOfProjectReferenceRedirect(definition.fileName) ? + definition : + definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); return mappedDefinition && project.containsFile(server.toNormalizedPath(mappedDefinition.fileName)) ? mappedDefinition : undefined; } + function isLocationProjectReferenceRedirect(project, location) { + if (!location) + return false; + var program = project.getLanguageService().getProgram(); + if (!program) + return false; + var sourceFile = program.getSourceFile(location.fileName); + // It is possible that location is attached to project but + // the program actually includes its redirect instead. + // This happens when rootFile in project is one of the file from referenced project + // Thus root is attached but program doesnt have the actual .ts file but .d.ts + // If this is not the file we were actually looking, return rest of the toDo + return !!sourceFile && + sourceFile.resolvedPath !== sourceFile.path && + sourceFile.resolvedPath !== project.toPath(location.fileName); + } function callbackProjectAndLocation(projectAndLocation, projectService, toDo, seenProjects, cb) { - if (projectAndLocation.project.getCancellationToken().isCancellationRequested()) + var project = projectAndLocation.project, location = projectAndLocation.location; + if (project.getCancellationToken().isCancellationRequested()) return undefined; // Skip rest of toDo if cancelled + // If this is not the file we were actually looking, return rest of the toDo + if (isLocationProjectReferenceRedirect(project, location)) + return toDo; cb(projectAndLocation, function (project, location) { seenProjects.set(projectAndLocation.project.projectName, true); var originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(project, location); @@ -132484,14 +138700,14 @@ var ts; } var symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo); if (symlinkedProjectsMap) { - symlinkedProjectsMap.forEach(function (symlinkedProjects) { + symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) { for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) { var symlinkedProject = symlinkedProjects_2[_i]; - addToTodo({ project: symlinkedProject, location: originalLocation }, toDo, seenProjects); + addToTodo({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } }, toDo, seenProjects); } }); } - return originalLocation; + return originalLocation === location ? undefined : originalLocation; }); return toDo; } @@ -132532,8 +138748,8 @@ var ts; } var Session = /** @class */ (function () { function Session(opts) { - var _this = this; var _a; + var _this = this; this.changeSeq = 0; this.handlers = ts.createMapFromTemplate((_a = {}, _a[server.CommandNames.Status] = function () { @@ -133000,9 +139216,10 @@ var ts; msg += "\n\nFile text of " + fileRequest.file + ":" + server.indent(text) + "\n"; } } - catch (_b) { } // tslint:disable-line no-empty + catch (_b) { } // eslint-disable-line no-empty } - if (err.message && err.message.indexOf("Could not find sourceFile:") !== -1) { + if (err.ProgramFiles) { + msg += "\n\nProgram files: " + JSON.stringify(err.ProgramFiles) + "\n"; msg += "\n\nProjects::\n"; var counter_1 = 0; var addProjectInfo = function (project) { @@ -133025,7 +139242,9 @@ var ts; } return; } - this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); + var msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine); + ts.perfLogger.logEvent("Response message size: " + msgText.length); + this.host.write(msgText); }; Session.prototype.event = function (body, eventName) { this.send(toEvent(eventName, body)); @@ -133244,7 +139463,7 @@ var ts; Session.prototype.mapDefinitionInfoLocations = function (definitions, project) { return definitions.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign({}, newDocumentSpan, { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }); + return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }); }); }; Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) { @@ -133273,7 +139492,9 @@ var ts; }; Session.prototype.getEmitOutput = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getEmitOutput(file); + return project.shouldEmitFile(project.getScriptInfo(file)) ? + project.getLanguageService().getEmitOutput(file) : + { emitSkipped: true, outputFiles: [] }; }; Session.prototype.mapDefinitionInfo = function (definitions, project) { var _this = this; @@ -133289,7 +139510,7 @@ var ts; Session.mapToOriginalLocation = function (def) { if (def.originalFileName) { ts.Debug.assert(def.originalTextSpan !== undefined, "originalTextSpan should be present if originalFileName is"); - return __assign({}, def, { fileName: def.originalFileName, textSpan: def.originalTextSpan, targetFileName: def.fileName, targetTextSpan: def.textSpan, contextSpan: def.originalContextSpan, targetContextSpan: def.contextSpan }); + return __assign(__assign({}, def), { fileName: def.originalFileName, textSpan: def.originalTextSpan, targetFileName: def.fileName, targetTextSpan: def.textSpan, contextSpan: def.originalContextSpan, targetContextSpan: def.contextSpan }); } return def; }; @@ -133306,7 +139527,7 @@ var ts; Session.prototype.toFileSpanWithContext = function (fileName, textSpan, contextSpan, project) { var fileSpan = this.toFileSpan(fileName, textSpan, project); var context = contextSpan && this.toFileSpan(fileName, contextSpan, project); - return context ? __assign({}, fileSpan, { contextStart: context.start, contextEnd: context.end }) : + return context ? __assign(__assign({}, fileSpan), { contextStart: context.start, contextEnd: context.end }) : fileSpan; }; Session.prototype.getTypeDefinition = function (args) { @@ -133318,7 +139539,7 @@ var ts; Session.prototype.mapImplementationLocations = function (implementations, project) { return implementations.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign({}, newDocumentSpan, { kind: info.kind, displayParts: info.displayParts }); + return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { kind: info.kind, displayParts: info.displayParts }); }); }; Session.prototype.getImplementation = function (args, simplifiedResult) { @@ -133341,7 +139562,7 @@ var ts; occurrences.map(function (occurrence) { var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan, isInString = occurrence.isInString, contextSpan = occurrence.contextSpan; var scriptInfo = project.getScriptInfo(fileName); - return __assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), { file: fileName, isWriteAccess: isWriteAccess }, (isInString ? { isInString: isInString } : undefined)); + return __assign(__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), { file: fileName, isWriteAccess: isWriteAccess }), (isInString ? { isInString: isInString } : undefined)); }) : server.emptyArray; }; @@ -133390,7 +139611,7 @@ var ts; file: fileName, highlightSpans: highlightSpans.map(function (_a) { var textSpan = _a.textSpan, kind = _a.kind, contextSpan = _a.contextSpan; - return (__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), { kind: kind })); + return (__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), { kind: kind })); }) }; }); @@ -133485,7 +139706,7 @@ var ts; if (!group_1) map.set(fileName, group_1 = { file: fileName, locs: [] }); var scriptInfo = ts.Debug.assertDefined(this.projectService.getScriptInfo(fileName)); - group_1.locs.push(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), prefixSuffixText)); + group_1.locs.push(__assign(__assign({}, toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo)), prefixSuffixText)); } return ts.arrayFrom(map.values()); }; @@ -133511,7 +139732,7 @@ var ts; var span = toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo); var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1); var lineText = scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, ""); - return __assign({ file: fileName }, span, { lineText: lineText, + return __assign(__assign({ file: fileName }, span), { lineText: lineText, isWriteAccess: isWriteAccess, isDefinition: isDefinition }); }); @@ -133713,7 +139934,7 @@ var ts; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); - var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign({}, server.convertUserPreferences(this.getPreferences(file)), { triggerCharacter: args.triggerCharacter, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions })); + var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions })); if (completions === undefined) return undefined; if (kind === "completions-full" /* CompletionsFull */) @@ -133732,7 +139953,7 @@ var ts; entries.metadata = completions.metadata; return entries; } - var res = __assign({}, completions, { entries: entries }); + var res = __assign(__assign({}, completions), { entries: entries }); return res; }; Session.prototype.getCompletionEntryDetails = function (args, simplifiedResult) { @@ -133746,7 +139967,7 @@ var ts; return project.getLanguageService().getCompletionEntryDetails(file, position, name, formattingOptions, source, _this.getPreferences(file)); }); return simplifiedResult - ? result.map(function (details) { return (__assign({}, details, { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }) })); }) + ? result.map(function (details) { return (__assign(__assign({}, details), { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }) })); }) : result; }; Session.prototype.getCompileOnSaveAffectedFileList = function (args) { @@ -133757,15 +139978,19 @@ var ts; return server.emptyArray; } return combineProjectOutput(info, function (path) { return _this.projectService.getScriptInfoForPath(path); }, projects, function (project, info) { - var result; - if (project.compileOnSaveEnabled && project.languageServiceEnabled && !project.isOrphan() && !project.getCompilationSettings().noEmit) { - result = { - projectFileName: project.getProjectName(), - fileNames: project.getCompileOnSaveAffectedFileList(info), - projectUsesOutFile: !!project.getCompilationSettings().outFile || !!project.getCompilationSettings().out - }; + if (!project.compileOnSaveEnabled || !project.languageServiceEnabled || project.isOrphan()) { + return undefined; } - return result; + var compilationSettings = project.getCompilationSettings(); + if (!!compilationSettings.noEmit || ts.fileExtensionIs(info.fileName, ".d.ts" /* Dts */) && !dtsChangeCanAffectEmit(compilationSettings)) { + // avoid triggering emit when a change is made in a .d.ts when declaration emit and decorator metadata emit are disabled + return undefined; + } + return { + projectFileName: project.getProjectName(), + fileNames: project.getCompileOnSaveAffectedFileList(info), + projectUsesOutFile: !!compilationSettings.outFile || !!compilationSettings.out + }; }); }; Session.prototype.emitFile = function (args) { @@ -133805,11 +140030,11 @@ var ts; return helpItems; } }; - Session.prototype.createCheckList = function (fileNames, defaultProject) { + Session.prototype.createCheckList = function (fileNames) { var _this = this; return ts.mapDefined(fileNames, function (uncheckedFileName) { var fileName = server.toNormalizedPath(uncheckedFileName); - var project = defaultProject || _this.projectService.tryGetDefaultProjectForFile(fileName); + var project = _this.projectService.tryGetDefaultProjectForFile(fileName); return project && { fileName: fileName, project: project }; }); }; @@ -134156,7 +140381,7 @@ var ts; } } } - var sortedFiles = highPriorityFiles.concat(mediumPriorityFiles, lowPriorityFiles, veryLowPriorityFiles); + var sortedFiles = __spreadArrays(highPriorityFiles, mediumPriorityFiles, lowPriorityFiles, veryLowPriorityFiles); var checkList = sortedFiles.map(function (fileName) { return ({ fileName: fileName, project: project }); }); // Project level error analysis runs on background files too, therefore // doesn't require the file to be opened @@ -134246,6 +140471,7 @@ var ts; try { request = JSON.parse(message); relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined; + ts.perfLogger.logStartCommand("" + request.command, message.substring(0, 100)); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; if (this.logger.hasLevel(server.LogLevel.requestTime)) { var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); @@ -134256,6 +140482,8 @@ var ts; this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); } } + // Note: Log before writing the response, else the editor can complete its activity before the server does + ts.perfLogger.logStopCommand("" + request.command, "Success"); if (response) { this.doOutput(response, request.command, request.seq, /*success*/ true); } @@ -134266,10 +140494,12 @@ var ts; catch (err) { if (err instanceof ts.OperationCanceledException) { // Handle cancellation exceptions + ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err); this.doOutput({ canceled: true }, request.command, request.seq, /*success*/ true); return; } this.logErrorWorker(err, message, relevantFile); + ts.perfLogger.logStopCommand("" + (request && request.command), "Error: " + err); this.doOutput( /*info*/ undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, /*success*/ false, "Error processing request. " + err.message + "\n" + err.stack); @@ -134299,7 +140529,7 @@ var ts; function toProtocolTextSpanWithContext(span, contextSpan, scriptInfo) { var textSpan = toProcolTextSpan(span, scriptInfo); var contextTextSpan = contextSpan && toProcolTextSpan(contextSpan, scriptInfo); - return contextTextSpan ? __assign({}, textSpan, { contextStart: contextTextSpan.start, contextEnd: contextTextSpan.end }) : + return contextTextSpan ? __assign(__assign({}, textSpan), { contextStart: contextTextSpan.start, contextEnd: contextTextSpan.end }) : textSpan; } function convertTextChangeToCodeEdit(change, scriptInfo) { diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 7a2559bbc2242..7bf245876e599 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.6"; + const versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ const version: string; } @@ -65,17 +65,17 @@ declare namespace ts { } } declare namespace ts { - type Path = string & { + export type Path = string & { __pathBrand: any; }; - interface TextRange { + export interface TextRange { pos: number; end: number; } - type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - 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 { + export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | 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; + export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; + export enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, @@ -104,359 +104,367 @@ declare namespace ts { 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, + QuestionDotToken = 28, + LessThanToken = 29, + LessThanSlashToken = 30, + GreaterThanToken = 31, + LessThanEqualsToken = 32, + GreaterThanEqualsToken = 33, + EqualsEqualsToken = 34, + ExclamationEqualsToken = 35, + EqualsEqualsEqualsToken = 36, + ExclamationEqualsEqualsToken = 37, + EqualsGreaterThanToken = 38, + PlusToken = 39, + MinusToken = 40, + AsteriskToken = 41, + AsteriskAsteriskToken = 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 = 58, + AtToken = 59, + QuestionQuestionToken = 60, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - BacktickToken = 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 = 72, - Identifier = 73, - BreakKeyword = 74, - CaseKeyword = 75, - CatchKeyword = 76, - ClassKeyword = 77, - ConstKeyword = 78, - ContinueKeyword = 79, - DebuggerKeyword = 80, - DefaultKeyword = 81, - DeleteKeyword = 82, - DoKeyword = 83, - ElseKeyword = 84, - EnumKeyword = 85, - ExportKeyword = 86, - ExtendsKeyword = 87, - FalseKeyword = 88, - FinallyKeyword = 89, - ForKeyword = 90, - FunctionKeyword = 91, - IfKeyword = 92, - ImportKeyword = 93, - InKeyword = 94, - InstanceOfKeyword = 95, - NewKeyword = 96, - NullKeyword = 97, - ReturnKeyword = 98, - SuperKeyword = 99, - SwitchKeyword = 100, - ThisKeyword = 101, - ThrowKeyword = 102, - TrueKeyword = 103, - TryKeyword = 104, - TypeOfKeyword = 105, - VarKeyword = 106, - VoidKeyword = 107, - WhileKeyword = 108, - WithKeyword = 109, - ImplementsKeyword = 110, - InterfaceKeyword = 111, - LetKeyword = 112, - PackageKeyword = 113, - PrivateKeyword = 114, - ProtectedKeyword = 115, - PublicKeyword = 116, - StaticKeyword = 117, - YieldKeyword = 118, - AbstractKeyword = 119, - AsKeyword = 120, - AnyKeyword = 121, - AsyncKeyword = 122, - AwaitKeyword = 123, - BooleanKeyword = 124, - ConstructorKeyword = 125, - DeclareKeyword = 126, - GetKeyword = 127, - InferKeyword = 128, - IsKeyword = 129, - KeyOfKeyword = 130, - ModuleKeyword = 131, - NamespaceKeyword = 132, - NeverKeyword = 133, - ReadonlyKeyword = 134, - RequireKeyword = 135, - NumberKeyword = 136, - ObjectKeyword = 137, - SetKeyword = 138, - StringKeyword = 139, - SymbolKeyword = 140, - TypeKeyword = 141, - UndefinedKeyword = 142, - UniqueKeyword = 143, - UnknownKeyword = 144, - FromKeyword = 145, - GlobalKeyword = 146, - BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocComment = 297, - JSDocTypeLiteral = 298, - JSDocSignature = 299, - JSDocTag = 300, - JSDocAugmentsTag = 301, - JSDocAuthorTag = 302, - JSDocClassTag = 303, - JSDocCallbackTag = 304, - JSDocEnumTag = 305, - JSDocParameterTag = 306, - JSDocReturnTag = 307, - JSDocThisTag = 308, - JSDocTypeTag = 309, - JSDocTemplateTag = 310, - JSDocTypedefTag = 311, - JSDocPropertyTag = 312, - SyntaxList = 313, - NotEmittedStatement = 314, - PartiallyEmittedExpression = 315, - CommaListExpression = 316, - MergeDeclarationMarker = 317, - EndOfDeclarationMarker = 318, - Count = 319, - FirstAssignment = 60, - LastAssignment = 72, - FirstCompoundAssignment = 61, - LastCompoundAssignment = 72, - FirstReservedWord = 74, - LastReservedWord = 109, - FirstKeyword = 74, - LastKeyword = 148, - FirstFutureReservedWord = 110, - LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + BacktickToken = 61, + EqualsToken = 62, + PlusEqualsToken = 63, + MinusEqualsToken = 64, + AsteriskEqualsToken = 65, + AsteriskAsteriskEqualsToken = 66, + SlashEqualsToken = 67, + PercentEqualsToken = 68, + LessThanLessThanEqualsToken = 69, + GreaterThanGreaterThanEqualsToken = 70, + GreaterThanGreaterThanGreaterThanEqualsToken = 71, + AmpersandEqualsToken = 72, + BarEqualsToken = 73, + CaretEqualsToken = 74, + Identifier = 75, + BreakKeyword = 76, + CaseKeyword = 77, + CatchKeyword = 78, + ClassKeyword = 79, + ConstKeyword = 80, + ContinueKeyword = 81, + DebuggerKeyword = 82, + DefaultKeyword = 83, + DeleteKeyword = 84, + DoKeyword = 85, + ElseKeyword = 86, + EnumKeyword = 87, + ExportKeyword = 88, + ExtendsKeyword = 89, + FalseKeyword = 90, + FinallyKeyword = 91, + ForKeyword = 92, + FunctionKeyword = 93, + IfKeyword = 94, + ImportKeyword = 95, + InKeyword = 96, + InstanceOfKeyword = 97, + NewKeyword = 98, + NullKeyword = 99, + ReturnKeyword = 100, + SuperKeyword = 101, + SwitchKeyword = 102, + ThisKeyword = 103, + ThrowKeyword = 104, + TrueKeyword = 105, + TryKeyword = 106, + TypeOfKeyword = 107, + VarKeyword = 108, + VoidKeyword = 109, + WhileKeyword = 110, + WithKeyword = 111, + ImplementsKeyword = 112, + InterfaceKeyword = 113, + LetKeyword = 114, + PackageKeyword = 115, + PrivateKeyword = 116, + ProtectedKeyword = 117, + PublicKeyword = 118, + StaticKeyword = 119, + YieldKeyword = 120, + AbstractKeyword = 121, + AsKeyword = 122, + AssertsKeyword = 123, + AnyKeyword = 124, + AsyncKeyword = 125, + AwaitKeyword = 126, + BooleanKeyword = 127, + ConstructorKeyword = 128, + DeclareKeyword = 129, + GetKeyword = 130, + InferKeyword = 131, + IsKeyword = 132, + KeyOfKeyword = 133, + ModuleKeyword = 134, + NamespaceKeyword = 135, + NeverKeyword = 136, + ReadonlyKeyword = 137, + RequireKeyword = 138, + NumberKeyword = 139, + ObjectKeyword = 140, + SetKeyword = 141, + StringKeyword = 142, + SymbolKeyword = 143, + TypeKeyword = 144, + UndefinedKeyword = 145, + UniqueKeyword = 146, + UnknownKeyword = 147, + FromKeyword = 148, + GlobalKeyword = 149, + BigIntKeyword = 150, + OfKeyword = 151, + QualifiedName = 152, + ComputedPropertyName = 153, + TypeParameter = 154, + Parameter = 155, + Decorator = 156, + PropertySignature = 157, + PropertyDeclaration = 158, + MethodSignature = 159, + MethodDeclaration = 160, + Constructor = 161, + GetAccessor = 162, + SetAccessor = 163, + CallSignature = 164, + ConstructSignature = 165, + IndexSignature = 166, + TypePredicate = 167, + TypeReference = 168, + FunctionType = 169, + ConstructorType = 170, + TypeQuery = 171, + TypeLiteral = 172, + ArrayType = 173, + TupleType = 174, + OptionalType = 175, + RestType = 176, + UnionType = 177, + IntersectionType = 178, + ConditionalType = 179, + InferType = 180, + ParenthesizedType = 181, + ThisType = 182, + TypeOperator = 183, + IndexedAccessType = 184, + MappedType = 185, + LiteralType = 186, + ImportType = 187, + ObjectBindingPattern = 188, + ArrayBindingPattern = 189, + BindingElement = 190, + ArrayLiteralExpression = 191, + ObjectLiteralExpression = 192, + PropertyAccessExpression = 193, + ElementAccessExpression = 194, + CallExpression = 195, + NewExpression = 196, + TaggedTemplateExpression = 197, + TypeAssertionExpression = 198, + ParenthesizedExpression = 199, + FunctionExpression = 200, + ArrowFunction = 201, + DeleteExpression = 202, + TypeOfExpression = 203, + VoidExpression = 204, + AwaitExpression = 205, + PrefixUnaryExpression = 206, + PostfixUnaryExpression = 207, + BinaryExpression = 208, + ConditionalExpression = 209, + TemplateExpression = 210, + YieldExpression = 211, + SpreadElement = 212, + ClassExpression = 213, + OmittedExpression = 214, + ExpressionWithTypeArguments = 215, + AsExpression = 216, + NonNullExpression = 217, + MetaProperty = 218, + SyntheticExpression = 219, + TemplateSpan = 220, + SemicolonClassElement = 221, + Block = 222, + EmptyStatement = 223, + VariableStatement = 224, + ExpressionStatement = 225, + IfStatement = 226, + DoStatement = 227, + WhileStatement = 228, + ForStatement = 229, + ForInStatement = 230, + ForOfStatement = 231, + ContinueStatement = 232, + BreakStatement = 233, + ReturnStatement = 234, + WithStatement = 235, + SwitchStatement = 236, + LabeledStatement = 237, + ThrowStatement = 238, + TryStatement = 239, + DebuggerStatement = 240, + VariableDeclaration = 241, + VariableDeclarationList = 242, + FunctionDeclaration = 243, + ClassDeclaration = 244, + InterfaceDeclaration = 245, + TypeAliasDeclaration = 246, + EnumDeclaration = 247, + ModuleDeclaration = 248, + ModuleBlock = 249, + CaseBlock = 250, + NamespaceExportDeclaration = 251, + ImportEqualsDeclaration = 252, + ImportDeclaration = 253, + ImportClause = 254, + NamespaceImport = 255, + NamedImports = 256, + ImportSpecifier = 257, + ExportAssignment = 258, + ExportDeclaration = 259, + NamedExports = 260, + ExportSpecifier = 261, + MissingDeclaration = 262, + ExternalModuleReference = 263, + JsxElement = 264, + JsxSelfClosingElement = 265, + JsxOpeningElement = 266, + JsxClosingElement = 267, + JsxFragment = 268, + JsxOpeningFragment = 269, + JsxClosingFragment = 270, + JsxAttribute = 271, + JsxAttributes = 272, + JsxSpreadAttribute = 273, + JsxExpression = 274, + CaseClause = 275, + DefaultClause = 276, + HeritageClause = 277, + CatchClause = 278, + PropertyAssignment = 279, + ShorthandPropertyAssignment = 280, + SpreadAssignment = 281, + EnumMember = 282, + UnparsedPrologue = 283, + UnparsedPrepend = 284, + UnparsedText = 285, + UnparsedInternalText = 286, + UnparsedSyntheticReference = 287, + SourceFile = 288, + Bundle = 289, + UnparsedSource = 290, + InputFiles = 291, + JSDocTypeExpression = 292, + JSDocAllType = 293, + JSDocUnknownType = 294, + JSDocNullableType = 295, + JSDocNonNullableType = 296, + JSDocOptionalType = 297, + JSDocFunctionType = 298, + JSDocVariadicType = 299, + JSDocNamepathType = 300, + JSDocComment = 301, + JSDocTypeLiteral = 302, + JSDocSignature = 303, + JSDocTag = 304, + JSDocAugmentsTag = 305, + JSDocAuthorTag = 306, + JSDocClassTag = 307, + JSDocCallbackTag = 308, + JSDocEnumTag = 309, + JSDocParameterTag = 310, + JSDocReturnTag = 311, + JSDocThisTag = 312, + JSDocTypeTag = 313, + JSDocTemplateTag = 314, + JSDocTypedefTag = 315, + JSDocPropertyTag = 316, + SyntaxList = 317, + NotEmittedStatement = 318, + PartiallyEmittedExpression = 319, + CommaListExpression = 320, + MergeDeclarationMarker = 321, + EndOfDeclarationMarker = 322, + SyntheticReferenceExpression = 323, + Count = 324, + FirstAssignment = 62, + LastAssignment = 74, + FirstCompoundAssignment = 63, + LastCompoundAssignment = 74, + FirstReservedWord = 76, + LastReservedWord = 111, + FirstKeyword = 76, + LastKeyword = 151, + FirstFutureReservedWord = 112, + LastFutureReservedWord = 120, + FirstTypeNode = 167, + LastTypeNode = 187, FirstPunctuation = 18, - LastPunctuation = 72, + LastPunctuation = 74, FirstToken = 0, - LastToken = 148, + LastToken = 151, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, LastLiteralToken = 14, FirstTemplateToken = 14, LastTemplateToken = 17, - FirstBinaryOperator = 28, - LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 312, - FirstJSDocTagNode = 300, - LastJSDocTagNode = 312, - } - enum NodeFlags { + FirstBinaryOperator = 29, + LastBinaryOperator = 74, + FirstStatement = 224, + LastStatement = 240, + FirstNode = 152, + FirstJSDocNode = 292, + LastJSDocNode = 316, + FirstJSDocTagNode = 304, + LastJSDocTagNode = 316, + } + export enum NodeFlags { None = 0, Let = 1, Const = 2, NestedNamespace = 4, Synthesized = 8, Namespace = 16, - ExportContext = 32, - ContainsThis = 64, - HasImplicitReturn = 128, - HasExplicitReturn = 256, - GlobalAugmentation = 512, - HasAsyncFunctions = 1024, - DisallowInContext = 2048, - YieldContext = 4096, - DecoratorContext = 8192, - AwaitContext = 16384, - ThisNodeHasError = 32768, - JavaScriptFile = 65536, - ThisNodeOrAnySubNodesHasError = 131072, - HasAggregatedChildData = 262144, - JSDoc = 2097152, - JsonFile = 16777216, + OptionalChain = 32, + ExportContext = 64, + ContainsThis = 128, + HasImplicitReturn = 256, + HasExplicitReturn = 512, + GlobalAugmentation = 1024, + HasAsyncFunctions = 2048, + DisallowInContext = 4096, + YieldContext = 8192, + DecoratorContext = 16384, + AwaitContext = 32768, + ThisNodeHasError = 65536, + JavaScriptFile = 131072, + ThisNodeOrAnySubNodesHasError = 262144, + HasAggregatedChildData = 524288, + JSDoc = 4194304, + JsonFile = 33554432, BlockScoped = 3, - ReachabilityCheckFlags = 384, - ReachabilityAndEmitFlags = 1408, - ContextFlags = 12679168, - TypeExcludesFlags = 20480, + ReachabilityCheckFlags = 768, + ReachabilityAndEmitFlags = 2816, + ContextFlags = 25358336, + TypeExcludesFlags = 40960, } - enum ModifierFlags { + export enum ModifierFlags { None = 0, Export = 1, Ambient = 2, @@ -477,7 +485,7 @@ declare namespace ts { ExportDefault = 513, All = 3071 } - enum JsxFlags { + export enum JsxFlags { None = 0, /** An element from a named property of the JSX.IntrinsicElements interface */ IntrinsicNamedElement = 1, @@ -485,40 +493,43 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3 } - interface Node extends TextRange { + export interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; decorators?: NodeArray; modifiers?: ModifiersArray; parent: Node; } - interface JSDocContainer { + export interface JSDocContainer { } - type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; - type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; - type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; - type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; - interface NodeArray extends ReadonlyArray, TextRange { + export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; + export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; + export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; + export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; + export interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; } - interface Token extends Node { + export interface Token extends Node { kind: TKind; } - type DotDotDotToken = Token; - type QuestionToken = Token; - type ExclamationToken = Token; - type ColonToken = Token; - type EqualsToken = Token; - type AsteriskToken = Token; - type EqualsGreaterThanToken = Token; - type EndOfFileToken = Token & JSDocContainer; - type ReadonlyToken = Token; - type AwaitKeywordToken = Token; - type PlusToken = Token; - type MinusToken = Token; - type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; - type ModifiersArray = NodeArray; - interface Identifier extends PrimaryExpression, Declaration { + export type DotToken = Token; + export type DotDotDotToken = Token; + export type QuestionToken = Token; + export type QuestionDotToken = Token; + export type ExclamationToken = Token; + export type ColonToken = Token; + export type EqualsToken = Token; + export type AsteriskToken = Token; + export type EqualsGreaterThanToken = Token; + export type EndOfFileToken = Token & JSDocContainer; + export type ReadonlyToken = Token; + export type AwaitKeywordToken = Token; + export type PlusToken = Token; + export type MinusToken = Token; + export type AssertsToken = Token; + export type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; + export type ModifiersArray = NodeArray; + export interface Identifier extends PrimaryExpression, Declaration { kind: SyntaxKind.Identifier; /** * Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.) @@ -528,37 +539,37 @@ declare namespace ts { originalKeywordKind?: SyntaxKind; isInJSDocNamespace?: boolean; } - interface TransientIdentifier extends Identifier { + export interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } - interface QualifiedName extends Node { + export interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } - type EntityName = Identifier | QualifiedName; - type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; - interface Declaration extends Node { + export type EntityName = Identifier | QualifiedName; + export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; + export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression; + export interface Declaration extends Node { _declarationBrand: any; } - interface NamedDeclaration extends Declaration { + export interface NamedDeclaration extends Declaration { name?: DeclarationName; } - interface DeclarationStatement extends NamedDeclaration, Statement { + export interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } - interface ComputedPropertyName extends Node { + export interface ComputedPropertyName extends Node { parent: Declaration; kind: SyntaxKind.ComputedPropertyName; expression: Expression; } - interface Decorator extends Node { + export interface Decorator extends Node { kind: SyntaxKind.Decorator; parent: NamedDeclaration; expression: LeftHandSideExpression; } - interface TypeParameterDeclaration extends NamedDeclaration { + export interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; parent: DeclarationWithTypeParameterChildren | InferTypeNode; name: Identifier; @@ -567,22 +578,22 @@ declare namespace ts { default?: TypeNode; expression?: Expression; } - interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { + export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; type?: TypeNode; } - type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; - interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; + export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } - interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } - type BindingName = Identifier | BindingPattern; - interface VariableDeclaration extends NamedDeclaration { + export type BindingName = Identifier | BindingPattern; + export interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; parent: VariableDeclarationList | CatchClause; name: BindingName; @@ -590,12 +601,12 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface VariableDeclarationList extends Node { + export interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; parent: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } - interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { + export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; @@ -604,7 +615,7 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface BindingElement extends NamedDeclaration { + export interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; parent: BindingPattern; propertyName?: PropertyName; @@ -612,14 +623,14 @@ declare namespace ts { name: BindingName; initializer?: Expression; } - interface PropertySignature extends TypeElement, JSDocContainer { + export interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } - interface PropertyDeclaration extends ClassElement, JSDocContainer { + export interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; parent: ClassLikeDeclaration; name: PropertyName; @@ -628,20 +639,20 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface ObjectLiteralElement extends NamedDeclaration { + export interface ObjectLiteralElement extends NamedDeclaration { _objectLiteralBrand: any; name?: PropertyName; } /** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */ - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; - interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; + export interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; initializer: Expression; } - interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; @@ -650,27 +661,27 @@ declare namespace ts { equalsToken?: Token; objectAssignmentInitializer?: Expression; } - interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { + export interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } - type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; - interface PropertyLikeDeclaration extends NamedDeclaration { + export type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; + export interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; } - interface ObjectBindingPattern extends Node { + export interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - interface ArrayBindingPattern extends Node { + export interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; - type ArrayBindingElement = BindingElement | OmittedExpression; + export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; + export type ArrayBindingElement = BindingElement | OmittedExpression; /** * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclarationBase. @@ -679,298 +690,299 @@ declare namespace ts { * - MethodDeclaration * - AccessorDeclaration */ - interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { + export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; exclamationToken?: ExclamationToken; body?: Block | Expression; } - type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; + export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; /** @deprecated Use SignatureDeclaration */ - type FunctionLike = SignatureDeclaration; - interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { + export type FunctionLike = SignatureDeclaration; + export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.FunctionDeclaration; name?: Identifier; body?: FunctionBody; } - interface MethodSignature extends SignatureDeclarationBase, TypeElement { + export interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; parent: ObjectTypeDeclaration; name: PropertyName; } - interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { + export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent: ClassLikeDeclaration; body?: FunctionBody; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ - interface SemicolonClassElement extends ClassElement { + export interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; parent: ClassLikeDeclaration; } - interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { + export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; + export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent: ObjectTypeDeclaration; } - interface TypeNode extends Node { + export interface TypeNode extends Node { _typeNodeBrand: any; } - interface KeywordTypeNode extends TypeNode { + export interface KeywordTypeNode extends TypeNode { 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 { + export interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; } - interface ThisTypeNode extends TypeNode { + export interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } - type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { + export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; + export interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; type: TypeNode; } - interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.ConstructorType; } - interface NodeWithTypeArguments extends TypeNode { + export interface NodeWithTypeArguments extends TypeNode { typeArguments?: NodeArray; } - type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; - interface TypeReferenceNode extends NodeWithTypeArguments { + export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; + export interface TypeReferenceNode extends NodeWithTypeArguments { kind: SyntaxKind.TypeReference; typeName: EntityName; } - interface TypePredicateNode extends TypeNode { + export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; + assertsModifier?: AssertsToken; parameterName: Identifier | ThisTypeNode; - type: TypeNode; + type?: TypeNode; } - interface TypeQueryNode extends TypeNode { + export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; exprName: EntityName; } - interface TypeLiteralNode extends TypeNode, Declaration { + export interface TypeLiteralNode extends TypeNode, Declaration { kind: SyntaxKind.TypeLiteral; members: NodeArray; } - interface ArrayTypeNode extends TypeNode { + export interface ArrayTypeNode extends TypeNode { kind: SyntaxKind.ArrayType; elementType: TypeNode; } - interface TupleTypeNode extends TypeNode { + export interface TupleTypeNode extends TypeNode { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } - interface OptionalTypeNode extends TypeNode { + export interface OptionalTypeNode extends TypeNode { kind: SyntaxKind.OptionalType; type: TypeNode; } - interface RestTypeNode extends TypeNode { + export interface RestTypeNode extends TypeNode { kind: SyntaxKind.RestType; type: TypeNode; } - type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; - interface UnionTypeNode extends TypeNode { + export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; + export interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; types: NodeArray; } - interface IntersectionTypeNode extends TypeNode { + export interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; types: NodeArray; } - interface ConditionalTypeNode extends TypeNode { + export interface ConditionalTypeNode extends TypeNode { kind: SyntaxKind.ConditionalType; checkType: TypeNode; extendsType: TypeNode; trueType: TypeNode; falseType: TypeNode; } - interface InferTypeNode extends TypeNode { + export interface InferTypeNode extends TypeNode { kind: SyntaxKind.InferType; typeParameter: TypeParameterDeclaration; } - interface ParenthesizedTypeNode extends TypeNode { + export interface ParenthesizedTypeNode extends TypeNode { kind: SyntaxKind.ParenthesizedType; type: TypeNode; } - interface TypeOperatorNode extends TypeNode { + export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword; type: TypeNode; } - interface IndexedAccessTypeNode extends TypeNode { + export interface IndexedAccessTypeNode extends TypeNode { kind: SyntaxKind.IndexedAccessType; objectType: TypeNode; indexType: TypeNode; } - interface MappedTypeNode extends TypeNode, Declaration { + export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; readonlyToken?: ReadonlyToken | PlusToken | MinusToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken | PlusToken | MinusToken; type?: TypeNode; } - interface LiteralTypeNode extends TypeNode { + export interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - interface StringLiteral extends LiteralExpression { + export interface StringLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.StringLiteral; } - type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; - interface Expression extends Node { + export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; + export interface Expression extends Node { _expressionBrand: any; } - interface OmittedExpression extends Expression { + export interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } - interface PartiallyEmittedExpression extends LeftHandSideExpression { + export interface PartiallyEmittedExpression extends LeftHandSideExpression { kind: SyntaxKind.PartiallyEmittedExpression; expression: Expression; } - interface UnaryExpression extends Expression { + export interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } /** Deprecated, please use UpdateExpression */ - type IncrementExpression = UpdateExpression; - interface UpdateExpression extends UnaryExpression { + export type IncrementExpression = UpdateExpression; + export interface UpdateExpression extends UnaryExpression { _updateExpressionBrand: any; } - type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; - interface PrefixUnaryExpression extends UpdateExpression { + export type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; + export interface PrefixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: PrefixUnaryOperator; operand: UnaryExpression; } - type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; - interface PostfixUnaryExpression extends UpdateExpression { + export type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; + export interface PostfixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface LeftHandSideExpression extends UpdateExpression { + export interface LeftHandSideExpression extends UpdateExpression { _leftHandSideExpressionBrand: any; } - interface MemberExpression extends LeftHandSideExpression { + export interface MemberExpression extends LeftHandSideExpression { _memberExpressionBrand: any; } - interface PrimaryExpression extends MemberExpression { + export interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } - interface NullLiteral extends PrimaryExpression, TypeNode { + export interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } - interface BooleanLiteral extends PrimaryExpression, TypeNode { + export interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - interface ThisExpression extends PrimaryExpression, KeywordTypeNode { + export interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } - interface SuperExpression extends PrimaryExpression { + export interface SuperExpression extends PrimaryExpression { kind: SyntaxKind.SuperKeyword; } - interface ImportExpression extends PrimaryExpression { + export interface ImportExpression extends PrimaryExpression { kind: SyntaxKind.ImportKeyword; } - interface DeleteExpression extends UnaryExpression { + export interface DeleteExpression extends UnaryExpression { kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; } - interface TypeOfExpression extends UnaryExpression { + export interface TypeOfExpression extends UnaryExpression { kind: SyntaxKind.TypeOfExpression; expression: UnaryExpression; } - interface VoidExpression extends UnaryExpression { + export interface VoidExpression extends UnaryExpression { kind: SyntaxKind.VoidExpression; expression: UnaryExpression; } - interface AwaitExpression extends UnaryExpression { + export interface AwaitExpression extends UnaryExpression { kind: SyntaxKind.AwaitExpression; expression: UnaryExpression; } - interface YieldExpression extends Expression { + export interface YieldExpression extends Expression { kind: SyntaxKind.YieldExpression; asteriskToken?: AsteriskToken; expression?: Expression; } - interface SyntheticExpression extends Expression { + export interface SyntheticExpression extends Expression { kind: SyntaxKind.SyntheticExpression; isSpread: boolean; type: Type; } - type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; - type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; - type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; - type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; - type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; - type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; - type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; - type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; - type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; - type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; - type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; - type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; - type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; - type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; - type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; - type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; - type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; - type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; - type BinaryOperatorToken = Token; - interface BinaryExpression extends Expression, Declaration { + export type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; + export type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; + export type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; + export type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; + export type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; + export type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; + export type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; + export type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; + export type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; + export type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; + export type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; + export type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; + export type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; + export type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; + export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; + export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; + export type AssignmentOperatorOrHigher = SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | AssignmentOperator; + export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; + export type BinaryOperatorToken = Token; + export interface BinaryExpression extends Expression, Declaration { kind: SyntaxKind.BinaryExpression; left: Expression; operatorToken: BinaryOperatorToken; right: Expression; } - type AssignmentOperatorToken = Token; - interface AssignmentExpression extends BinaryExpression { + export type AssignmentOperatorToken = Token; + export interface AssignmentExpression extends BinaryExpression { left: LeftHandSideExpression; operatorToken: TOperator; } - interface ObjectDestructuringAssignment extends AssignmentExpression { + export interface ObjectDestructuringAssignment extends AssignmentExpression { left: ObjectLiteralExpression; } - interface ArrayDestructuringAssignment extends AssignmentExpression { + export interface ArrayDestructuringAssignment extends AssignmentExpression { left: ArrayLiteralExpression; } - type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; - type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; - type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; - type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; - type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; - type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; - type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; - type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; - interface ConditionalExpression extends Expression { + export type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; + export type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; + export type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; + export type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; + export type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; + export type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; + export type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; + export type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; + export interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; questionToken: QuestionToken; @@ -978,34 +990,37 @@ declare namespace ts { colonToken: ColonToken; whenFalse: Expression; } - type FunctionBody = Block; - type ConciseBody = FunctionBody | Expression; - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { + export type FunctionBody = Block; + export type ConciseBody = FunctionBody | Expression; + export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } - interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { + export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; name: never; } - interface LiteralLikeNode extends Node { + export interface LiteralLikeNode extends Node { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; } - interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { + export interface TemplateLiteralLikeNode extends LiteralLikeNode { + rawText?: string; + } + export interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; } - interface RegularExpressionLiteral extends LiteralExpression { + export interface RegularExpressionLiteral extends LiteralExpression { kind: SyntaxKind.RegularExpressionLiteral; } - interface NoSubstitutionTemplateLiteral extends LiteralExpression { + export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode, Declaration { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } - enum TokenFlags { + export enum TokenFlags { None = 0, Scientific = 16, Octal = 32, @@ -1013,45 +1028,45 @@ declare namespace ts { BinarySpecifier = 128, OctalSpecifier = 256, } - interface NumericLiteral extends LiteralExpression { + export interface NumericLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.NumericLiteral; } - interface BigIntLiteral extends LiteralExpression { + export interface BigIntLiteral extends LiteralExpression { kind: SyntaxKind.BigIntLiteral; } - interface TemplateHead extends LiteralLikeNode { + export interface TemplateHead extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateHead; parent: TemplateExpression; } - interface TemplateMiddle extends LiteralLikeNode { + export interface TemplateMiddle extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateMiddle; parent: TemplateSpan; } - interface TemplateTail extends LiteralLikeNode { + export interface TemplateTail extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateTail; parent: TemplateSpan; } - type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; - interface TemplateExpression extends PrimaryExpression { + export type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; + export interface TemplateExpression extends PrimaryExpression { kind: SyntaxKind.TemplateExpression; head: TemplateHead; templateSpans: NodeArray; } - interface TemplateSpan extends Node { + export interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; parent: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } - interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { + export interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } - interface ArrayLiteralExpression extends PrimaryExpression { + export interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; } - interface SpreadElement extends Expression { + export interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; parent: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; @@ -1062,413 +1077,426 @@ declare namespace ts { * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) */ - interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { + export interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { properties: NodeArray; } - interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { + export interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; } - type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; - type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; - interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { + export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; + export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; name: Identifier; } - interface SuperPropertyAccessExpression extends PropertyAccessExpression { + export interface PropertyAccessChain extends PropertyAccessExpression { + _optionalChainBrand: any; + } + export interface SuperPropertyAccessExpression extends PropertyAccessExpression { expression: SuperExpression; } /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ - interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { + export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { _propertyAccessExpressionLikeQualifiedNameBrand?: any; expression: EntityNameExpression; } - interface ElementAccessExpression extends MemberExpression { + export interface ElementAccessExpression extends MemberExpression { kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; argumentExpression: Expression; } - interface SuperElementAccessExpression extends ElementAccessExpression { + export interface ElementAccessChain extends ElementAccessExpression { + _optionalChainBrand: any; + } + export interface SuperElementAccessExpression extends ElementAccessExpression { expression: SuperExpression; } - type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; - interface CallExpression extends LeftHandSideExpression, Declaration { + export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; + export interface CallExpression extends LeftHandSideExpression, Declaration { kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; typeArguments?: NodeArray; arguments: NodeArray; } - interface SuperCall extends CallExpression { + export interface CallChain extends CallExpression { + _optionalChainBrand: any; + } + export type OptionalChain = PropertyAccessChain | ElementAccessChain | CallChain; + export interface SuperCall extends CallExpression { expression: SuperExpression; } - interface ImportCall extends CallExpression { + export interface ImportCall extends CallExpression { expression: ImportExpression; } - interface ExpressionWithTypeArguments extends NodeWithTypeArguments { + export interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; parent: HeritageClause | JSDocAugmentsTag; expression: LeftHandSideExpression; } - interface NewExpression extends PrimaryExpression, Declaration { + export interface NewExpression extends PrimaryExpression, Declaration { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments?: NodeArray; } - interface TaggedTemplateExpression extends MemberExpression { + export interface TaggedTemplateExpression extends MemberExpression { kind: SyntaxKind.TaggedTemplateExpression; tag: LeftHandSideExpression; typeArguments?: NodeArray; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; - interface AsExpression extends Expression { + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; + export interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; type: TypeNode; } - interface TypeAssertion extends UnaryExpression { + export interface TypeAssertion extends UnaryExpression { kind: SyntaxKind.TypeAssertionExpression; type: TypeNode; expression: UnaryExpression; } - type AssertionExpression = TypeAssertion | AsExpression; - interface NonNullExpression extends LeftHandSideExpression { + export type AssertionExpression = TypeAssertion | AsExpression; + export interface NonNullExpression extends LeftHandSideExpression { kind: SyntaxKind.NonNullExpression; expression: Expression; } - interface MetaProperty extends PrimaryExpression { + export interface MetaProperty extends PrimaryExpression { kind: SyntaxKind.MetaProperty; keywordToken: SyntaxKind.NewKeyword | SyntaxKind.ImportKeyword; name: Identifier; } - interface JsxElement extends PrimaryExpression { + export interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; - interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; + export type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + export interface JsxTagNamePropertyAccess extends PropertyAccessExpression { expression: JsxTagNameExpression; } - interface JsxAttributes extends ObjectLiteralExpressionBase { + export interface JsxAttributes extends ObjectLiteralExpressionBase { kind: SyntaxKind.JsxAttributes; parent: JsxOpeningLikeElement; } - interface JsxOpeningElement extends Expression { + export interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; parent: JsxElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxSelfClosingElement extends PrimaryExpression { + export interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxFragment extends PrimaryExpression { + export interface JsxFragment extends PrimaryExpression { kind: SyntaxKind.JsxFragment; openingFragment: JsxOpeningFragment; children: NodeArray; closingFragment: JsxClosingFragment; } - interface JsxOpeningFragment extends Expression { + export interface JsxOpeningFragment extends Expression { kind: SyntaxKind.JsxOpeningFragment; parent: JsxFragment; } - interface JsxClosingFragment extends Expression { + export interface JsxClosingFragment extends Expression { kind: SyntaxKind.JsxClosingFragment; parent: JsxFragment; } - interface JsxAttribute extends ObjectLiteralElement { + export interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; parent: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends ObjectLiteralElement { + export interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; parent: JsxAttributes; expression: Expression; } - interface JsxClosingElement extends Node { + export interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; parent: JsxElement; tagName: JsxTagNameExpression; } - interface JsxExpression extends Expression { + export interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; parent: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } - interface JsxText extends LiteralLikeNode { + export interface JsxText extends LiteralLikeNode { kind: SyntaxKind.JsxText; containsOnlyTriviaWhiteSpaces: boolean; parent: JsxElement; } - type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; - interface Statement extends Node { + export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; + export interface Statement extends Node { _statementBrand: any; } - interface NotEmittedStatement extends Statement { + export interface NotEmittedStatement extends Statement { kind: SyntaxKind.NotEmittedStatement; } /** * A list of comma-separated expressions. This node is only created by transformations. */ - interface CommaListExpression extends Expression { + export interface CommaListExpression extends Expression { kind: SyntaxKind.CommaListExpression; elements: NodeArray; } - interface EmptyStatement extends Statement { + export interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } - interface DebuggerStatement extends Statement { + export interface DebuggerStatement extends Statement { kind: SyntaxKind.DebuggerStatement; } - interface MissingDeclaration extends DeclarationStatement { + export interface MissingDeclaration extends DeclarationStatement { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; - interface Block extends Statement { + export type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; + export interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; } - interface VariableStatement extends Statement, JSDocContainer { + export interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } - interface ExpressionStatement extends Statement, JSDocContainer { + export interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } - interface IfStatement extends Statement { + export interface IfStatement extends Statement { kind: SyntaxKind.IfStatement; expression: Expression; thenStatement: Statement; elseStatement?: Statement; } - interface IterationStatement extends Statement { + export interface IterationStatement extends Statement { statement: Statement; } - interface DoStatement extends IterationStatement { + export interface DoStatement extends IterationStatement { kind: SyntaxKind.DoStatement; expression: Expression; } - interface WhileStatement extends IterationStatement { + export interface WhileStatement extends IterationStatement { kind: SyntaxKind.WhileStatement; expression: Expression; } - type ForInitializer = VariableDeclarationList | Expression; - interface ForStatement extends IterationStatement { + export type ForInitializer = VariableDeclarationList | Expression; + export interface ForStatement extends IterationStatement { kind: SyntaxKind.ForStatement; initializer?: ForInitializer; condition?: Expression; incrementor?: Expression; } - type ForInOrOfStatement = ForInStatement | ForOfStatement; - interface ForInStatement extends IterationStatement { + export type ForInOrOfStatement = ForInStatement | ForOfStatement; + export interface ForInStatement extends IterationStatement { kind: SyntaxKind.ForInStatement; initializer: ForInitializer; expression: Expression; } - interface ForOfStatement extends IterationStatement { + export interface ForOfStatement extends IterationStatement { kind: SyntaxKind.ForOfStatement; awaitModifier?: AwaitKeywordToken; initializer: ForInitializer; expression: Expression; } - interface BreakStatement extends Statement { + export interface BreakStatement extends Statement { kind: SyntaxKind.BreakStatement; label?: Identifier; } - interface ContinueStatement extends Statement { + export interface ContinueStatement extends Statement { kind: SyntaxKind.ContinueStatement; label?: Identifier; } - type BreakOrContinueStatement = BreakStatement | ContinueStatement; - interface ReturnStatement extends Statement { + export type BreakOrContinueStatement = BreakStatement | ContinueStatement; + export interface ReturnStatement extends Statement { kind: SyntaxKind.ReturnStatement; expression?: Expression; } - interface WithStatement extends Statement { + export interface WithStatement extends Statement { kind: SyntaxKind.WithStatement; expression: Expression; statement: Statement; } - interface SwitchStatement extends Statement { + export interface SwitchStatement extends Statement { kind: SyntaxKind.SwitchStatement; expression: Expression; caseBlock: CaseBlock; possiblyExhaustive?: boolean; } - interface CaseBlock extends Node { + export interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; parent: SwitchStatement; clauses: NodeArray; } - interface CaseClause extends Node { + export interface CaseClause extends Node { kind: SyntaxKind.CaseClause; parent: CaseBlock; expression: Expression; statements: NodeArray; } - interface DefaultClause extends Node { + export interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; parent: CaseBlock; statements: NodeArray; } - type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement, JSDocContainer { + export type CaseOrDefaultClause = CaseClause | DefaultClause; + export interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; } - interface ThrowStatement extends Statement { + export interface ThrowStatement extends Statement { kind: SyntaxKind.ThrowStatement; expression?: Expression; } - interface TryStatement extends Statement { + export interface TryStatement extends Statement { kind: SyntaxKind.TryStatement; tryBlock: Block; catchClause?: CatchClause; finallyBlock?: Block; } - interface CatchClause extends Node { + export interface CatchClause extends Node { kind: SyntaxKind.CatchClause; parent: TryStatement; variableDeclaration?: VariableDeclaration; block: Block; } - type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; - type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; - interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { + export type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; + export type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + export type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; + export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { + export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; /** May be undefined in `export default class { ... }`. */ name?: Identifier; } - interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { + export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } - type ClassLikeDeclaration = ClassDeclaration | ClassExpression; - interface ClassElement extends NamedDeclaration { + export type ClassLikeDeclaration = ClassDeclaration | ClassExpression; + export interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; } - interface TypeElement extends NamedDeclaration { + export interface TypeElement extends NamedDeclaration { _typeElementBrand: any; name?: PropertyName; questionToken?: QuestionToken; } - interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { + export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface HeritageClause extends Node { + export interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; parent: InterfaceDeclaration | ClassLikeDeclaration; token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } - interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { + export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } - interface EnumMember extends NamedDeclaration, JSDocContainer { + export interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent: EnumDeclaration; name: PropertyName; initializer?: Expression; } - interface EnumDeclaration extends DeclarationStatement, JSDocContainer { + export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } - type ModuleName = Identifier | StringLiteral; - type ModuleBody = NamespaceBody | JSDocNamespaceBody; - interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { + export type ModuleName = Identifier | StringLiteral; + export type ModuleBody = NamespaceBody | JSDocNamespaceBody; + export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent: ModuleBody | SourceFile; name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration; } - type NamespaceBody = ModuleBlock | NamespaceDeclaration; - interface NamespaceDeclaration extends ModuleDeclaration { + export type NamespaceBody = ModuleBlock | NamespaceDeclaration; + export interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; body: NamespaceBody; } - type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; - interface JSDocNamespaceDeclaration extends ModuleDeclaration { + export type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; + export interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; body?: JSDocNamespaceBody; } - interface ModuleBlock extends Node, Statement { + export interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; parent: ModuleDeclaration; statements: NodeArray; } - type ModuleReference = EntityName | ExternalModuleReference; + export type ModuleReference = EntityName | ExternalModuleReference; /** * One of: * - import x = require("mod"); * - import x = M.x; */ - interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { + export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } - interface ExternalModuleReference extends Node { + export interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; parent: ImportEqualsDeclaration; expression: Expression; } - interface ImportDeclaration extends Statement { + export interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; parent: SourceFile | ModuleBlock; importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; } - type NamedImportBindings = NamespaceImport | NamedImports; - interface ImportClause extends NamedDeclaration { + export type NamedImportBindings = NamespaceImport | NamedImports; + export interface ImportClause extends NamedDeclaration { kind: SyntaxKind.ImportClause; parent: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } - interface NamespaceImport extends NamedDeclaration { + export interface NamespaceImport extends NamedDeclaration { kind: SyntaxKind.NamespaceImport; parent: ImportClause; name: Identifier; } - interface NamespaceExportDeclaration extends DeclarationStatement { + export interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; } - interface ExportDeclaration extends DeclarationStatement, JSDocContainer { + export interface ExportDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ExportDeclaration; parent: SourceFile | ModuleBlock; /** Will not be assigned in the case of `export * from "foo";` */ @@ -1476,161 +1504,166 @@ declare namespace ts { /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier?: Expression; } - interface NamedImports extends Node { + export interface NamedImports extends Node { kind: SyntaxKind.NamedImports; parent: ImportClause; elements: NodeArray; } - interface NamedExports extends Node { + export interface NamedExports extends Node { kind: SyntaxKind.NamedExports; parent: ExportDeclaration; elements: NodeArray; } - type NamedImportsOrExports = NamedImports | NamedExports; - interface ImportSpecifier extends NamedDeclaration { + export type NamedImportsOrExports = NamedImports | NamedExports; + export interface ImportSpecifier extends NamedDeclaration { kind: SyntaxKind.ImportSpecifier; parent: NamedImports; propertyName?: Identifier; name: Identifier; } - interface ExportSpecifier extends NamedDeclaration { + export interface ExportSpecifier extends NamedDeclaration { kind: SyntaxKind.ExportSpecifier; parent: NamedExports; propertyName?: Identifier; name: Identifier; } - type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; + export type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; /** * This is either an `export =` or an `export default` declaration. * Unless `isExportEquals` is set, this node was parsed as an `export default`. */ - interface ExportAssignment extends DeclarationStatement { + export interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; parent: SourceFile; isExportEquals?: boolean; expression: Expression; } - interface FileReference extends TextRange { + export interface FileReference extends TextRange { fileName: string; } - interface CheckJsDirective extends TextRange { + export interface CheckJsDirective extends TextRange { enabled: boolean; } - type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; - interface CommentRange extends TextRange { + export type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; + export interface CommentRange extends TextRange { hasTrailingNewLine?: boolean; kind: CommentKind; } - interface SynthesizedComment extends CommentRange { + export interface SynthesizedComment extends CommentRange { text: string; pos: -1; end: -1; } - interface JSDocTypeExpression extends TypeNode { + export interface JSDocTypeExpression extends TypeNode { kind: SyntaxKind.JSDocTypeExpression; type: TypeNode; } - interface JSDocType extends TypeNode { + export interface JSDocType extends TypeNode { _jsDocTypeBrand: any; } - interface JSDocAllType extends JSDocType { + export interface JSDocAllType extends JSDocType { kind: SyntaxKind.JSDocAllType; } - interface JSDocUnknownType extends JSDocType { + export interface JSDocUnknownType extends JSDocType { kind: SyntaxKind.JSDocUnknownType; } - interface JSDocNonNullableType extends JSDocType { + export interface JSDocNonNullableType extends JSDocType { kind: SyntaxKind.JSDocNonNullableType; type: TypeNode; } - interface JSDocNullableType extends JSDocType { + export interface JSDocNullableType extends JSDocType { kind: SyntaxKind.JSDocNullableType; type: TypeNode; } - interface JSDocOptionalType extends JSDocType { + export interface JSDocOptionalType extends JSDocType { kind: SyntaxKind.JSDocOptionalType; type: TypeNode; } - interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { + export interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { kind: SyntaxKind.JSDocFunctionType; } - interface JSDocVariadicType extends JSDocType { + export interface JSDocVariadicType extends JSDocType { kind: SyntaxKind.JSDocVariadicType; type: TypeNode; } - type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; - interface JSDoc extends Node { + export interface JSDocNamepathType extends JSDocType { + kind: SyntaxKind.JSDocNamepathType; + type: TypeNode; + } + export type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; + export interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; parent: HasJSDoc; tags?: NodeArray; comment?: string; } - interface JSDocTag extends Node { + export interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; tagName: Identifier; comment?: string; } - interface JSDocUnknownTag extends JSDocTag { + export interface JSDocUnknownTag extends JSDocTag { kind: SyntaxKind.JSDocTag; } /** * Note that `@extends` is a synonym of `@augments`. * Both tags are represented by this interface. */ - interface JSDocAugmentsTag extends JSDocTag { + export interface JSDocAugmentsTag extends JSDocTag { kind: SyntaxKind.JSDocAugmentsTag; class: ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression; }; } - interface JSDocAuthorTag extends JSDocTag { + export interface JSDocAuthorTag extends JSDocTag { kind: SyntaxKind.JSDocAuthorTag; } - interface JSDocClassTag extends JSDocTag { + export interface JSDocClassTag extends JSDocTag { kind: SyntaxKind.JSDocClassTag; } - interface JSDocEnumTag extends JSDocTag { + export interface JSDocEnumTag extends JSDocTag, Declaration { + parent: JSDoc; kind: SyntaxKind.JSDocEnumTag; typeExpression?: JSDocTypeExpression; } - interface JSDocThisTag extends JSDocTag { + export interface JSDocThisTag extends JSDocTag { kind: SyntaxKind.JSDocThisTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTemplateTag extends JSDocTag { + export interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; constraint: JSDocTypeExpression | undefined; typeParameters: NodeArray; } - interface JSDocReturnTag extends JSDocTag { + export interface JSDocReturnTag extends JSDocTag { kind: SyntaxKind.JSDocReturnTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTypeTag extends JSDocTag { + export interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; typeExpression: JSDocTypeExpression; } - interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { + export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocTypedefTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression?: JSDocTypeExpression | JSDocTypeLiteral; } - interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { + export interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocCallbackTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression: JSDocSignature; } - interface JSDocSignature extends JSDocType, Declaration { + export interface JSDocSignature extends JSDocType, Declaration { kind: SyntaxKind.JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly JSDocTemplateTag[]; + parameters: readonly JSDocParameterTag[]; type: JSDocReturnTag | undefined; } - interface JSDocPropertyLikeTag extends JSDocTag, Declaration { + export interface JSDocPropertyLikeTag extends JSDocTag, Declaration { parent: JSDoc; name: EntityName; typeExpression?: JSDocTypeExpression; @@ -1638,19 +1671,19 @@ declare namespace ts { isNameFirst: boolean; isBracketed: boolean; } - interface JSDocPropertyTag extends JSDocPropertyLikeTag { + export interface JSDocPropertyTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocPropertyTag; } - interface JSDocParameterTag extends JSDocPropertyLikeTag { + export interface JSDocParameterTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocParameterTag; } - interface JSDocTypeLiteral extends JSDocType { + export interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; - jsDocPropertyTags?: ReadonlyArray; + jsDocPropertyTags?: readonly JSDocPropertyLikeTag[]; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } - enum FlowFlags { + export enum FlowFlags { Unreachable = 1, Start = 2, BranchLabel = 4, @@ -1660,72 +1693,77 @@ declare namespace ts { FalseCondition = 64, SwitchClause = 128, ArrayMutation = 256, - Referenced = 512, - Shared = 1024, - PreFinally = 2048, - AfterFinally = 4096, + Call = 512, + Referenced = 1024, + Shared = 2048, + PreFinally = 4096, + AfterFinally = 8192, Label = 12, Condition = 96 } - interface FlowLock { + export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation; + export interface FlowNodeBase { + flags: FlowFlags; + id?: number; + } + export interface FlowLock { locked?: boolean; } - interface AfterFinallyFlow extends FlowNodeBase, FlowLock { + export interface AfterFinallyFlow extends FlowNodeBase, FlowLock { antecedent: FlowNode; } - interface PreFinallyFlow extends FlowNodeBase { + export interface PreFinallyFlow extends FlowNodeBase { antecedent: FlowNode; lock: FlowLock; } - type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - interface FlowNodeBase { - flags: FlowFlags; - id?: number; - } - interface FlowStart extends FlowNodeBase { - container?: FunctionExpression | ArrowFunction | MethodDeclaration; + export interface FlowStart extends FlowNodeBase { + node?: FunctionExpression | ArrowFunction | MethodDeclaration; } - interface FlowLabel extends FlowNodeBase { + export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; } - interface FlowAssignment extends FlowNodeBase { + export interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } - interface FlowCondition extends FlowNodeBase { - expression: Expression; + export interface FlowCall extends FlowNodeBase { + node: CallExpression; + antecedent: FlowNode; + } + export interface FlowCondition extends FlowNodeBase { + node: Expression; antecedent: FlowNode; } - interface FlowSwitchClause extends FlowNodeBase { + export interface FlowSwitchClause extends FlowNodeBase { switchStatement: SwitchStatement; clauseStart: number; clauseEnd: number; antecedent: FlowNode; } - interface FlowArrayMutation extends FlowNodeBase { + export interface FlowArrayMutation extends FlowNodeBase { node: CallExpression | BinaryExpression; antecedent: FlowNode; } - type FlowType = Type | IncompleteType; - interface IncompleteType { + export type FlowType = Type | IncompleteType; + export interface IncompleteType { flags: TypeFlags; type: Type; } - interface AmdDependency { + export interface AmdDependency { path: string; name?: string; } - interface SourceFile extends Declaration { + export interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; statements: NodeArray; endOfFileToken: Token; fileName: string; text: string; - amdDependencies: ReadonlyArray; + amdDependencies: readonly AmdDependency[]; moduleName?: string; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray; - libReferenceDirectives: ReadonlyArray; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly FileReference[]; + libReferenceDirectives: readonly FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -1739,12 +1777,12 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } - interface Bundle extends Node { + export interface Bundle extends Node { kind: SyntaxKind.Bundle; - prepends: ReadonlyArray; - sourceFiles: ReadonlyArray; + prepends: readonly (InputFiles | UnparsedSource)[]; + sourceFiles: readonly SourceFile[]; } - interface InputFiles extends Node { + export interface InputFiles extends Node { kind: SyntaxKind.InputFiles; javascriptPath?: string; javascriptText: string; @@ -1755,70 +1793,70 @@ declare namespace ts { declarationMapPath?: string; declarationMapText?: string; } - interface UnparsedSource extends Node { + export interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; fileName: string; text: string; - prologues: ReadonlyArray; - helpers: ReadonlyArray | undefined; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray | undefined; - libReferenceDirectives: ReadonlyArray; + prologues: readonly UnparsedPrologue[]; + helpers: readonly UnscopedEmitHelper[] | undefined; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly string[] | undefined; + libReferenceDirectives: readonly FileReference[]; hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; - syntheticReferences?: ReadonlyArray; - texts: ReadonlyArray; + syntheticReferences?: readonly UnparsedSyntheticReference[]; + texts: readonly UnparsedSourceText[]; } - type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; - type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; - interface UnparsedSection extends Node { + export type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; + export type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; + export interface UnparsedSection extends Node { kind: SyntaxKind; data?: string; parent: UnparsedSource; } - interface UnparsedPrologue extends UnparsedSection { + export interface UnparsedPrologue extends UnparsedSection { kind: SyntaxKind.UnparsedPrologue; data: string; parent: UnparsedSource; } - interface UnparsedPrepend extends UnparsedSection { + export interface UnparsedPrepend extends UnparsedSection { kind: SyntaxKind.UnparsedPrepend; data: string; parent: UnparsedSource; - texts: ReadonlyArray; + texts: readonly UnparsedTextLike[]; } - interface UnparsedTextLike extends UnparsedSection { + export interface UnparsedTextLike extends UnparsedSection { kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; parent: UnparsedSource; } - interface UnparsedSyntheticReference extends UnparsedSection { + export interface UnparsedSyntheticReference extends UnparsedSection { kind: SyntaxKind.UnparsedSyntheticReference; parent: UnparsedSource; } - interface JsonSourceFile extends SourceFile { + export interface JsonSourceFile extends SourceFile { statements: NodeArray; } - interface TsConfigSourceFile extends JsonSourceFile { + export interface TsConfigSourceFile extends JsonSourceFile { extendedSourceFiles?: string[]; } - interface JsonMinusNumericLiteral extends PrefixUnaryExpression { + export interface JsonMinusNumericLiteral extends PrefixUnaryExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: SyntaxKind.MinusToken; operand: NumericLiteral; } - interface JsonObjectExpressionStatement extends ExpressionStatement { + export interface JsonObjectExpressionStatement extends ExpressionStatement { expression: ObjectLiteralExpression | ArrayLiteralExpression | JsonMinusNumericLiteral | NumericLiteral | StringLiteral | BooleanLiteral | NullLiteral; } - interface ScriptReferenceHost { + export interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile | undefined; getSourceFileByPath(path: Path): SourceFile | undefined; getCurrentDirectory(): string; } - interface ParseConfigHost { + export interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; + readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[]; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. @@ -1832,26 +1870,26 @@ declare namespace ts { * specified like "./blah" to an absolute path to an actual * tsconfig file, e.g. "/root/blah/tsconfig.json" */ - type ResolvedConfigFileName = string & { + export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray) => void; - class OperationCanceledException { + export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; + export class OperationCanceledException { } - interface CancellationToken { + export interface CancellationToken { isCancellationRequested(): boolean; /** @throws OperationCanceledException if isCancellationRequested is true */ throwIfCancellationRequested(): void; } - interface Program extends ScriptReferenceHost { + export interface Program extends ScriptReferenceHost { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): ReadonlyArray; + getRootFileNames(): readonly string[]; /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -1863,33 +1901,42 @@ declare namespace ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** The first time this is called, it will return global diagnostics (no location). */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + getRelationCacheSizes(): { + assignable: number; + identity: number; + subtype: number; + }; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; - getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; + getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; } - interface ResolvedProjectReference { + export interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; - references?: ReadonlyArray; + references?: readonly (ResolvedProjectReference | undefined)[]; } - type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; - interface CustomTransformer { + export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; + export interface CustomTransformer { transformSourceFile(node: SourceFile): SourceFile; transformBundle(node: Bundle): Bundle; } - interface CustomTransformers { + export interface CustomTransformers { /** Custom transformers to evaluate before built-in .js transformations. */ before?: (TransformerFactory | CustomTransformerFactory)[]; /** Custom transformers to evaluate after built-in .js transformations. */ @@ -1897,7 +1944,7 @@ declare namespace ts { /** Custom transformers to evaluate after built-in .d.ts transformations. */ afterDeclarations?: (TransformerFactory | CustomTransformerFactory)[]; } - interface SourceMapSpan { + export interface SourceMapSpan { /** Line number in the .js file. */ emittedLine: number; /** Column number in the .js file. */ @@ -1912,25 +1959,26 @@ declare namespace ts { sourceIndex: number; } /** Return code used by getEmitOutput function to indicate status of the function */ - enum ExitStatus { + export enum ExitStatus { Success = 0, DiagnosticsPresent_OutputsSkipped = 1, DiagnosticsPresent_OutputsGenerated = 2, - InvalidProject_OutputsSkipped = 3 + InvalidProject_OutputsSkipped = 3, + ProjectReferenceCycle_OutputsSkupped = 4 } - interface EmitResult { + export interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; emittedFiles?: string[]; } - interface TypeChecker { + export interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; + getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1938,6 +1986,7 @@ declare namespace ts { getReturnTypeOfSignature(signature: Signature): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; + getTypeArguments(type: TypeReference): readonly Type[]; /** Note that the resulting nodes cannot be checked. */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ @@ -1984,7 +2033,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): ReadonlyArray; + getRootSymbols(symbol: Symbol): readonly Symbol[]; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -2016,7 +2065,7 @@ declare namespace ts { */ runWithCancellationToken(token: CancellationToken, cb: (checker: TypeChecker) => T): T; } - enum NodeBuilderFlags { + export enum NodeBuilderFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2047,7 +2096,7 @@ declare namespace ts { InInitialEntityName = 16777216, InReverseMappedType = 33554432 } - enum TypeFormatFlags { + export enum TypeFormatFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2070,31 +2119,49 @@ declare namespace ts { /** @deprecated */ WriteOwnNameForAnyLike = 0, NodeBuilderFlagsMask = 9469291 } - enum SymbolFormatFlags { + export enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8, } - enum TypePredicateKind { + export enum TypePredicateKind { This = 0, - Identifier = 1 + Identifier = 1, + AssertsThis = 2, + AssertsIdentifier = 3 } - interface TypePredicateBase { + export interface TypePredicateBase { kind: TypePredicateKind; - type: Type; + type: Type | undefined; } - interface ThisTypePredicate extends TypePredicateBase { + export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; + parameterName: undefined; + parameterIndex: undefined; + type: Type; } - interface IdentifierTypePredicate extends TypePredicateBase { + export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; + type: Type; + } + export interface AssertsThisTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsThis; + parameterName: undefined; + parameterIndex: undefined; + type: Type | undefined; + } + export interface AssertsIdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsIdentifier; + parameterName: string; + parameterIndex: number; + type: Type | undefined; } - type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - enum SymbolFlags { + export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate; + export enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, @@ -2126,28 +2193,28 @@ declare namespace ts { ModuleExports = 134217728, Enum = 384, Variable = 3, - Value = 67220415, - Type = 67897832, + Value = 111551, + Type = 788968, Namespace = 1920, Module = 1536, Accessor = 98304, - FunctionScopedVariableExcludes = 67220414, - BlockScopedVariableExcludes = 67220415, - ParameterExcludes = 67220415, + FunctionScopedVariableExcludes = 111550, + BlockScopedVariableExcludes = 111551, + ParameterExcludes = 111551, PropertyExcludes = 0, - EnumMemberExcludes = 68008959, - FunctionExcludes = 67219887, - ClassExcludes = 68008383, - InterfaceExcludes = 67897736, - RegularEnumExcludes = 68008191, - ConstEnumExcludes = 68008831, + EnumMemberExcludes = 900095, + FunctionExcludes = 110991, + ClassExcludes = 899503, + InterfaceExcludes = 788872, + RegularEnumExcludes = 899327, + ConstEnumExcludes = 899967, ValueModuleExcludes = 110735, NamespaceModuleExcludes = 0, - MethodExcludes = 67212223, - GetAccessorExcludes = 67154879, - SetAccessorExcludes = 67187647, - TypeParameterExcludes = 67635688, - TypeAliasExcludes = 67897832, + MethodExcludes = 103359, + GetAccessorExcludes = 46015, + SetAccessorExcludes = 78783, + TypeParameterExcludes = 526824, + TypeAliasExcludes = 788968, AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, @@ -2155,7 +2222,7 @@ declare namespace ts { PropertyOrAccessor = 98308, ClassMember = 106500, } - interface Symbol { + export interface Symbol { flags: SymbolFlags; escapedName: __String; declarations: Declaration[]; @@ -2164,7 +2231,7 @@ declare namespace ts { exports?: SymbolTable; globalExports?: SymbolTable; } - enum InternalSymbolName { + export enum InternalSymbolName { Call = "__call", Constructor = "__constructor", New = "__new", @@ -2191,13 +2258,13 @@ declare namespace ts { * with a normal string (which is good, it cannot be misused on assignment or on usage), * while still being comparable with a normal string via === (also good) and castable from a string. */ - type __String = (string & { + export type __String = (string & { __escapedIdentifier: void; }) | (void & { __escapedIdentifier: void; }) | InternalSymbolName; /** ReadonlyMap where keys are `__String`s. */ - interface ReadonlyUnderscoreEscapedMap { + export interface ReadonlyUnderscoreEscapedMap { get(key: __String): T | undefined; has(key: __String): boolean; forEach(action: (value: T, key: __String) => void): void; @@ -2207,14 +2274,14 @@ declare namespace ts { entries(): Iterator<[__String, T]>; } /** Map where keys are `__String`s. */ - interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { + export interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { set(key: __String, value: T): this; delete(key: __String): boolean; clear(): void; } /** SymbolTable based on ES6 Map interface. */ - type SymbolTable = UnderscoreEscapedMap; - enum TypeFlags { + export type SymbolTable = UnderscoreEscapedMap; + export enum TypeFlags { Any = 1, Unknown = 2, String = 4, @@ -2263,35 +2330,35 @@ declare namespace ts { Narrowable = 133970943, NotUnionOrUnit = 67637251, } - type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; - interface Type { + export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + export interface Type { flags: TypeFlags; symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: ReadonlyArray; + aliasTypeArguments?: readonly Type[]; } - interface LiteralType extends Type { + export interface LiteralType extends Type { value: string | number | PseudoBigInt; freshType: LiteralType; regularType: LiteralType; } - interface UniqueESSymbolType extends Type { + export interface UniqueESSymbolType extends Type { symbol: Symbol; escapedName: __String; } - interface StringLiteralType extends LiteralType { + export interface StringLiteralType extends LiteralType { value: string; } - interface NumberLiteralType extends LiteralType { + export interface NumberLiteralType extends LiteralType { value: number; } - interface BigIntLiteralType extends LiteralType { + export interface BigIntLiteralType extends LiteralType { value: PseudoBigInt; } - interface EnumType extends Type { + export interface EnumType extends Type { } - enum ObjectFlags { + export enum ObjectFlags { Class = 1, Interface = 2, Reference = 4, @@ -2311,18 +2378,18 @@ declare namespace ts { ArrayLiteral = 65536, ClassOrInterface = 3, } - interface ObjectType extends Type { + export interface ObjectType extends Type { objectFlags: ObjectFlags; } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ - interface InterfaceType extends ObjectType { + export interface InterfaceType extends ObjectType { typeParameters: TypeParameter[] | undefined; outerTypeParameters: TypeParameter[] | undefined; localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; } - type BaseType = ObjectType | IntersectionType; - interface InterfaceTypeWithDeclaredMembers extends InterfaceType { + export type BaseType = ObjectType | IntersectionType | TypeVariable; + export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; @@ -2339,49 +2406,51 @@ declare namespace ts { * if the class or interface has no type parameters and the reference isn't specifying an * explicit "this" argument. */ - interface TypeReference extends ObjectType { + export interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: ReadonlyArray; + node?: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; + } + export interface DeferredTypeReference extends TypeReference { } - interface GenericType extends InterfaceType, TypeReference { + export interface GenericType extends InterfaceType, TypeReference { } - interface TupleType extends GenericType { + export interface TupleType extends GenericType { minLength: number; hasRestElement: boolean; readonly: boolean; associatedNames?: __String[]; } - interface TupleTypeReference extends TypeReference { + export interface TupleTypeReference extends TypeReference { target: TupleType; } - interface UnionOrIntersectionType extends Type { + export interface UnionOrIntersectionType extends Type { types: Type[]; } - interface UnionType extends UnionOrIntersectionType { + export interface UnionType extends UnionOrIntersectionType { } - interface IntersectionType extends UnionOrIntersectionType { + export interface IntersectionType extends UnionOrIntersectionType { } - type StructuredType = ObjectType | UnionType | IntersectionType; - interface EvolvingArrayType extends ObjectType { + export type StructuredType = ObjectType | UnionType | IntersectionType; + export interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; } - interface InstantiableType extends Type { + export interface InstantiableType extends Type { } - interface TypeParameter extends InstantiableType { + export interface TypeParameter extends InstantiableType { } - interface IndexedAccessType extends InstantiableType { + export interface IndexedAccessType extends InstantiableType { objectType: Type; indexType: Type; constraint?: Type; simplifiedForReading?: Type; simplifiedForWriting?: Type; } - type TypeVariable = TypeParameter | IndexedAccessType; - interface IndexType extends InstantiableType { + export type TypeVariable = TypeParameter | IndexedAccessType; + export interface IndexType extends InstantiableType { type: InstantiableType | UnionOrIntersectionType; } - interface ConditionalRoot { + export interface ConditionalRoot { node: ConditionalTypeNode; checkType: Type; extendsType: Type; @@ -2394,36 +2463,36 @@ declare namespace ts { aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } - interface ConditionalType extends InstantiableType { + export interface ConditionalType extends InstantiableType { root: ConditionalRoot; checkType: Type; extendsType: Type; resolvedTrueType: Type; resolvedFalseType: Type; } - interface SubstitutionType extends InstantiableType { + export interface SubstitutionType extends InstantiableType { typeVariable: TypeVariable; substitute: Type; } - enum SignatureKind { + export enum SignatureKind { Call = 0, Construct = 1 } - interface Signature { + export interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly TypeParameter[]; + parameters: readonly Symbol[]; } - enum IndexKind { + export enum IndexKind { String = 0, Number = 1 } - interface IndexInfo { + export interface IndexInfo { type: Type; isReadonly: boolean; declaration?: IndexSignatureDeclaration; } - enum InferencePriority { + export enum InferencePriority { NakedTypeVariable = 1, HomomorphicMappedType = 2, PartialHomomorphicMappedType = 4, @@ -2432,16 +2501,18 @@ declare namespace ts { LiteralKeyof = 32, NoConstraints = 64, AlwaysStrict = 128, - PriorityImpliesCombination = 56 + MaxValue = 256, + PriorityImpliesCombination = 56, + Circularity = -1 } /** @deprecated Use FileExtensionInfo instead. */ - type JsFileExtensionInfo = FileExtensionInfo; - interface FileExtensionInfo { + export type JsFileExtensionInfo = FileExtensionInfo; + export interface FileExtensionInfo { extension: string; isMixedContent: boolean; scriptKind?: ScriptKind; } - interface DiagnosticMessage { + export interface DiagnosticMessage { key: string; category: DiagnosticCategory; code: number; @@ -2454,19 +2525,19 @@ declare namespace ts { * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, * the difference is that messages are all preformatted in DMC. */ - interface DiagnosticMessageChain { + export interface DiagnosticMessageChain { messageText: string; category: DiagnosticCategory; code: number; next?: DiagnosticMessageChain[]; } - interface Diagnostic extends DiagnosticRelatedInformation { + export interface Diagnostic extends DiagnosticRelatedInformation { /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } - interface DiagnosticRelatedInformation { + export interface DiagnosticRelatedInformation { category: DiagnosticCategory; code: number; file: SourceFile | undefined; @@ -2474,25 +2545,25 @@ declare namespace ts { length: number | undefined; messageText: string | DiagnosticMessageChain; } - interface DiagnosticWithLocation extends Diagnostic { + export interface DiagnosticWithLocation extends Diagnostic { file: SourceFile; start: number; length: number; } - enum DiagnosticCategory { + export enum DiagnosticCategory { Warning = 0, Error = 1, Suggestion = 2, Message = 3 } - enum ModuleResolutionKind { + export enum ModuleResolutionKind { Classic = 1, NodeJs = 2 } - interface PluginImport { + export interface PluginImport { name: string; } - interface ProjectReference { + export interface ProjectReference { /** A normalized path on disk */ path: string; /** The path as the user originally wrote it */ @@ -2502,8 +2573,8 @@ declare namespace ts { /** True if it is intended that this reference form a circularity */ circular?: boolean; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; - interface CompilerOptions { + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; + export interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; allowUmdGlobalAccess?: boolean; @@ -2518,6 +2589,7 @@ declare namespace ts { emitDeclarationOnly?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + disableSourceOfProjectReferenceRedirect?: boolean; downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; @@ -2584,16 +2656,21 @@ declare namespace ts { /** Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; + useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } - interface TypeAcquisition { + export interface TypeAcquisition { + /** + * @deprecated typingOptions.enableAutoDiscovery + * Use typeAcquisition.enable instead. + */ enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; exclude?: string[]; [option: string]: string[] | boolean | undefined; } - enum ModuleKind { + export enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, @@ -2602,22 +2679,22 @@ declare namespace ts { ES2015 = 5, ESNext = 99 } - enum JsxEmit { + export enum JsxEmit { None = 0, Preserve = 1, React = 2, ReactNative = 3 } - enum NewLineKind { + export enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1 } - interface LineAndCharacter { + export interface LineAndCharacter { /** 0-based. */ line: number; character: number; } - enum ScriptKind { + export enum ScriptKind { Unknown = 0, JS = 1, JSX = 2, @@ -2631,7 +2708,7 @@ declare namespace ts { */ Deferred = 7 } - enum ScriptTarget { + export enum ScriptTarget { ES3 = 0, ES5 = 1, ES2015 = 2, @@ -2644,38 +2721,38 @@ declare namespace ts { JSON = 100, Latest = 99 } - enum LanguageVariant { + export enum LanguageVariant { Standard = 0, JSX = 1 } /** Either a parsed command line or a parsed tsconfig.json */ - interface ParsedCommandLine { + export interface ParsedCommandLine { options: CompilerOptions; typeAcquisition?: TypeAcquisition; fileNames: string[]; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; compileOnSave?: boolean; } - enum WatchDirectoryFlags { + export enum WatchDirectoryFlags { None = 0, Recursive = 1 } - interface ExpandResult { + export interface ExpandResult { fileNames: string[]; wildcardDirectories: MapLike; } - interface CreateProgramOptions { - rootNames: ReadonlyArray; + export interface CreateProgramOptions { + rootNames: readonly string[]; options: CompilerOptions; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; oldProgram?: Program; - configFileParsingDiagnostics?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; } - interface ModuleResolutionHost { + export interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string | undefined; trace?(s: string): void; @@ -2695,7 +2772,7 @@ declare namespace ts { * * Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred. */ - interface ResolvedModule { + export interface ResolvedModule { /** Path of the file the module was resolved to. */ resolvedFileName: string; /** True if `resolvedFileName` comes from `node_modules`. */ @@ -2706,7 +2783,7 @@ declare namespace ts { * Prefer this over `ResolvedModule`. * If changing this, remember to change `moduleResolutionIsEqualTo`. */ - interface ResolvedModuleFull extends ResolvedModule { + export interface ResolvedModuleFull extends ResolvedModule { /** * Extension of resolvedFileName. This must match what's at the end of resolvedFileName. * This is optional for backwards-compatibility, but will be added if not provided. @@ -2718,7 +2795,7 @@ declare namespace ts { * Unique identifier with a package name and version. * If changing this, remember to change `packageIdIsEqual`. */ - interface PackageId { + export interface PackageId { /** * Name of the package. * Should not include `@types`. @@ -2733,7 +2810,7 @@ declare namespace ts { /** Version of the package, e.g. "1.2.3" */ version: string; } - enum Extension { + export enum Extension { Ts = ".ts", Tsx = ".tsx", Dts = ".d.ts", @@ -2742,21 +2819,21 @@ declare namespace ts { Json = ".json", TsBuildInfo = ".tsbuildinfo" } - interface ResolvedModuleWithFailedLookupLocations { + export interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; } - interface ResolvedTypeReferenceDirective { + export interface ResolvedTypeReferenceDirective { primary: boolean; resolvedFileName: string | undefined; packageId?: PackageId; /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; } - interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { + export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: ReadonlyArray; + readonly failedLookupLocations: readonly string[]; } - interface CompilerHost extends ModuleResolutionHost { + export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getCancellationToken?(): CancellationToken; @@ -2767,25 +2844,25 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; - readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (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, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } - interface SourceMapRange extends TextRange { + export interface SourceMapRange extends TextRange { source?: SourceMapSource; } - interface SourceMapSource { + export interface SourceMapSource { fileName: string; text: string; skipTrivia?: (pos: number) => number; } - enum EmitFlags { + export enum EmitFlags { None = 0, SingleLine = 1, AdviseOnEmitNode = 2, @@ -2816,18 +2893,18 @@ declare namespace ts { Iterator = 8388608, NoAsciiEscaping = 16777216, } - interface EmitHelper { + export interface EmitHelper { readonly name: string; readonly scoped: boolean; readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; } - interface UnscopedEmitHelper extends EmitHelper { + export interface UnscopedEmitHelper extends EmitHelper { readonly scoped: false; readonly text: string; } - type EmitHelperUniqueNameCallback = (name: string) => string; - enum EmitHint { + export type EmitHelperUniqueNameCallback = (name: string) => string; + export enum EmitHint { SourceFile = 0, Expression = 1, IdentifierName = 2, @@ -2835,7 +2912,7 @@ declare namespace ts { Unspecified = 4, EmbeddedStatement = 5 } - interface TransformationContext { + export interface TransformationContext { /** Gets the compiler options supplied to the transformer. */ getCompilerOptions(): CompilerOptions; /** Starts a new lexical environment. */ @@ -2885,7 +2962,7 @@ declare namespace ts { */ onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; } - interface TransformationResult { + export interface TransformationResult { /** Gets the transformed source files. */ transformed: T[]; /** Gets diagnostics for the transformation. */ @@ -2914,17 +2991,17 @@ declare namespace ts { * A function that is used to initialize and return a `Transformer` callback, which in turn * will be used to transform one or more nodes. */ - type TransformerFactory = (context: TransformationContext) => Transformer; + export type TransformerFactory = (context: TransformationContext) => Transformer; /** * A function that transforms a node. */ - type Transformer = (node: T) => T; + export type Transformer = (node: T) => T; /** * A function that accepts and possibly transforms a node. */ - type Visitor = (node: Node) => VisitResult; - type VisitResult = T | T[] | undefined; - interface Printer { + export type Visitor = (node: Node) => VisitResult; + export type VisitResult = T | T[] | undefined; + export interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. * @param hint A value indicating the purpose of a node. This is primarily used to @@ -2952,7 +3029,7 @@ declare namespace ts { */ printBundle(bundle: Bundle): string; } - interface PrintHandlers { + export interface PrintHandlers { /** * A hook used by the Printer when generating unique names to avoid collisions with * globally defined names that exist outside of the current source file. @@ -2995,28 +3072,33 @@ declare namespace ts { */ substituteNode?(hint: EmitHint, node: Node): Node; } - interface PrinterOptions { + export interface PrinterOptions { removeComments?: boolean; newLine?: NewLineKind; omitTrailingSemicolon?: boolean; noEmitHelpers?: boolean; } - interface GetEffectiveTypeRootsHost { + export interface GetEffectiveTypeRootsHost { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - interface TextSpan { + export interface ModuleSpecifierResolutionHost extends GetEffectiveTypeRootsHost { + useCaseSensitiveFileNames?(): boolean; + fileExists?(path: string): boolean; + readFile?(path: string): string | undefined; + } + export interface TextSpan { start: number; length: number; } - interface TextChangeRange { + export interface TextChangeRange { span: TextSpan; newLength: number; } - interface SyntaxList extends Node { + export interface SyntaxList extends Node { _children: Node[]; } - enum ListFormat { + export enum ListFormat { None = 0, SingleLine = 0, MultiLine = 1, @@ -3083,7 +3165,7 @@ declare namespace ts { IndexSignatureParameters = 8848, JSDocComment = 33 } - interface UserPreferences { + export interface UserPreferences { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; @@ -3095,22 +3177,23 @@ declare namespace ts { readonly providePrefixAndSuffixTextForRename?: boolean; } /** Represents a bigint literal value without requiring bigint support */ - interface PseudoBigInt { + export interface PseudoBigInt { negative: boolean; base10Value: string; } + export {}; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; declare namespace ts { - enum FileWatcherEventKind { + export enum FileWatcherEventKind { Created = 0, Changed = 1, Deleted = 2 } - type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; - type DirectoryWatcherCallback = (fileName: string) => void; - interface System { + export type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; + export type DirectoryWatcherCallback = (fileName: string) => void; + export interface System { args: string[]; newLine: string; useCaseSensitiveFileNames: boolean; @@ -3132,7 +3215,7 @@ declare namespace ts { getExecutingFilePath(): string; getCurrentDirectory(): string; getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; @@ -3151,11 +3234,12 @@ declare namespace ts { base64decode?(input: string): string; base64encode?(input: string): string; } - interface FileWatcher { + export interface FileWatcher { close(): void; } - function getNodeMajorVersion(): number | undefined; - let sys: System; + export function getNodeMajorVersion(): number | undefined; + export let sys: System; + export {}; } declare namespace ts { type ErrorCallback = (message: DiagnosticMessage, length: number) => void; @@ -3166,6 +3250,7 @@ declare namespace ts { getTokenPos(): number; getTokenText(): string; getTokenValue(): string; + hasUnicodeEscape(): boolean; hasExtendedUnicodeEscape(): boolean; hasPrecedingLineBreak(): boolean; isIdentifier(): boolean; @@ -3178,6 +3263,7 @@ declare namespace ts { scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; + reScanQuestionToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; @@ -3215,7 +3301,7 @@ declare namespace ts { } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; + function sortAndDeduplicateDiagnostics(diagnostics: readonly T[]): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3244,13 +3330,13 @@ declare namespace ts { * This function will then merge those changes into a single change range valid between V1 and * Vn. */ - function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: readonly TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; name: Identifier; }; - function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; + function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; @@ -3316,7 +3402,7 @@ declare namespace ts { * * For binding patterns, parameter tags are matched by position. */ - function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray; + function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[]; /** * Gets the JSDoc type parameter tags for the node if present. * @@ -3327,7 +3413,7 @@ declare namespace ts { * node are returned first, so in the previous example, the template * tag on the containing function expression would be first. */ - function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray; + function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[]; /** * Return true if the node has JSDoc parameter tags. * @@ -3369,14 +3455,14 @@ declare namespace ts { */ function getJSDocReturnType(node: Node): TypeNode | undefined; /** Get all JSDoc tags related to a node, including those on parent nodes. */ - function getJSDocTags(node: Node): ReadonlyArray; + function getJSDocTags(node: Node): readonly JSDocTag[]; /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ - function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray; + function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. */ - function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray; + function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; } declare namespace ts { @@ -3430,8 +3516,12 @@ declare namespace ts { function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression; function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression; function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression; + function isPropertyAccessChain(node: Node): node is PropertyAccessChain; function isElementAccessExpression(node: Node): node is ElementAccessExpression; + function isElementAccessChain(node: Node): node is ElementAccessChain; function isCallExpression(node: Node): node is CallExpression; + function isCallChain(node: Node): node is CallChain; + function isOptionalChain(node: Node): node is PropertyAccessChain | ElementAccessChain | CallChain; function isNewExpression(node: Node): node is NewExpression; function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression; function isTypeAssertion(node: Node): node is TypeAssertion; @@ -3529,7 +3619,7 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; - function isJSDocAllType(node: JSDocAllType): node is JSDocAllType; + function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType; @@ -3601,7 +3691,7 @@ declare namespace ts { function isStringLiteralLike(node: Node): node is StringLiteralLike; } declare namespace ts { - function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; + export function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, @@ -3615,25 +3705,26 @@ declare namespace ts { * @remarks `forEachChild` must visit the children of a node in the order * that they appear in the source code. The language service depends on this property to locate nodes by position. */ - function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; - function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; - function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; + export function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; + export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; + export function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; /** * Parse json text into SyntaxTree and return node and parse errors if any * @param fileName * @param sourceText */ - function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; - function isExternalModule(file: SourceFile): boolean; - function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; + export function isExternalModule(file: SourceFile): boolean; + export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export {}; } declare namespace ts { - function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; - type DiagnosticReporter = (diagnostic: Diagnostic) => void; + export function parseCommandLine(commandLine: readonly string[], readFile?: (path: string) => string | undefined): ParsedCommandLine; + export type DiagnosticReporter = (diagnostic: Diagnostic) => void; /** * Reports config file diagnostics */ - interface ConfigFileDiagnosticsReporter { + export interface ConfigFileDiagnosticsReporter { /** * Reports unrecoverable error when parsing config file */ @@ -3642,18 +3733,18 @@ declare namespace ts { /** * Interface extending ParseConfigHost to support ParseConfigFile that reads config file and reports errors */ - interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { + export interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { getCurrentDirectory(): string; } /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; + export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { + export function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { config?: any; error?: Diagnostic; }; @@ -3662,7 +3753,7 @@ declare namespace ts { * @param fileName The path to the config file * @param jsonText The text of the config file */ - function parseConfigFileTextToJson(fileName: string, jsonText: string): { + export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic; }; @@ -3670,11 +3761,11 @@ declare namespace ts { * Read tsconfig.json file * @param fileName The path to the config file */ - function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; + export function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; /** * Convert the json syntax tree into the json value */ - function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; + export function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -3682,7 +3773,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3690,8 +3781,8 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; - interface ParsedTsconfig { + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; + export interface ParsedTsconfig { raw: any; options?: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -3700,18 +3791,19 @@ declare namespace ts { */ extendedConfigPath?: string; } - interface ExtendedConfigCacheEntry { + export interface ExtendedConfigCacheEntry { extendedResult: TsConfigSourceFile; extendedConfig: ParsedTsconfig | undefined; } - function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; }; - function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypeAcquisition; errors: Diagnostic[]; }; + export {}; } declare namespace ts { function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; @@ -3755,7 +3847,7 @@ declare namespace ts { 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; + function createNodeArray(elements?: readonly T[], 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 | PseudoBigInt): NumericLiteral; @@ -3793,62 +3885,64 @@ declare namespace ts { function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - function createParameter(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + function createParameter(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createPropertySignature(modifiers: ReadonlyArray | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function updatePropertySignature(node: PropertySignature, modifiers: ReadonlyArray | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function createProperty(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function createMethodSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createProperty(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function createMethodSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; - function createMethod(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function createConstructor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function createGetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function createSetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function createCallSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createMethod(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; - function createConstructSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - function createIndexSignature(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; - function updateIndexSignature(node: IndexSignatureDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; + function createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; - function createTypeReferenceNode(typeName: string | EntityName, typeArguments: ReadonlyArray | undefined): TypeReferenceNode; + function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode; function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; - function createFunctionTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): FunctionTypeNode; + function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; - function createConstructorTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructorTypeNode; + function createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; + function createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; - function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createTupleTypeNode(elementTypes: readonly TypeNode[]): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]): TupleTypeNode; function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; function createRestTypeNode(type: TypeNode): RestTypeNode; function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; - function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; + function createUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; - function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; + function createIntersectionTypeNode(types: readonly TypeNode[]): IntersectionTypeNode; function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray): IntersectionTypeNode; - function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: ReadonlyArray): UnionOrIntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: readonly TypeNode[]): UnionOrIntersectionTypeNode; function createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; @@ -3861,36 +3955,42 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; - function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ReadonlyArray): ArrayBindingPattern; + function createObjectBindingPattern(elements: readonly BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: readonly BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: readonly ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: readonly ArrayBindingElement[]): ArrayBindingPattern; function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; - function createArrayLiteral(elements?: ReadonlyArray, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; - function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; + function createArrayLiteral(elements?: readonly Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier): PropertyAccessChain; + function updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier): PropertyAccessChain; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; - function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; + function createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain; + function updateElementAccessChain(node: ElementAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, argumentExpression: Expression): ElementAccessChain; + function createCall(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallExpression; + function createCallChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallChain; + function updateCallChain(node: CallChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallChain; + function createNew(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; /** @deprecated */ function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; /** @deprecated */ function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; - function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -3908,22 +4008,22 @@ declare namespace ts { /** @deprecated */ function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function createTemplateHead(text: string): TemplateHead; - function createTemplateMiddle(text: string): TemplateMiddle; - function createTemplateTail(text: string): TemplateTail; - function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; + function createTemplateExpression(head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function createTemplateHead(text: string, rawText?: string): TemplateHead; + function createTemplateMiddle(text: string, rawText?: string): TemplateMiddle; + function createTemplateTail(text: string, rawText?: string): TemplateTail; + function createNoSubstitutionTemplateLiteral(text: string, rawText?: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3933,10 +4033,10 @@ declare namespace ts { function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; - function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function updateBlock(node: Block, statements: ReadonlyArray): Block; - function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; + function createBlock(statements: readonly Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: readonly Statement[]): Block; + function createVariableStatement(modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; function createExpressionStatement(expression: Expression): ExpressionStatement; function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; @@ -3975,76 +4075,76 @@ declare namespace ts { function createDebuggerStatement(): DebuggerStatement; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - function createVariableDeclarationList(declarations: ReadonlyArray, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; - function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function createEnumDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, members: ReadonlyArray): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, members: ReadonlyArray): EnumDeclaration; - function createModuleDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; - function createModuleBlock(statements: ReadonlyArray): ModuleBlock; - function updateModuleBlock(node: ModuleBlock, statements: ReadonlyArray): ModuleBlock; - function createCaseBlock(clauses: ReadonlyArray): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: ReadonlyArray): CaseBlock; + function createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; + function createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + function createModuleBlock(statements: readonly Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; + function createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ReadonlyArray): NamedImports; - function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; + function createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; - function createNamedExports(elements: ReadonlyArray): NamedExports; - function updateNamedExports(node: NamedExports, elements: ReadonlyArray): NamedExports; + function createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; + function createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; - function createJsxElement(openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; + function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxFragment(openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function createJsxFragment(openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxText(text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function updateJsxText(node: JsxText, text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function createJsxOpeningFragment(): JsxOpeningFragment; function createJsxJsxClosingFragment(): JsxClosingFragment; - function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxAttributes(properties: ReadonlyArray): JsxAttributes; - function updateJsxAttributes(node: JsxAttributes, properties: ReadonlyArray): JsxAttributes; + function createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; - function createCaseClause(expression: Expression, statements: ReadonlyArray): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: ReadonlyArray): CaseClause; - function createDefaultClause(statements: ReadonlyArray): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; - function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; + function createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; + function createDefaultClause(statements: readonly Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause; + function createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause; function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; @@ -4055,7 +4155,7 @@ declare namespace ts { function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; - function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; + function updateSourceFileNode(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; /** * Creates a shallow, memberwise clone of a node for mutation. */ @@ -4077,20 +4177,20 @@ declare namespace ts { */ function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createCommaList(elements: ReadonlyArray): CommaListExpression; - function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; + function createCommaList(elements: readonly Expression[]): CommaListExpression; + function updateCommaList(node: CommaListExpression, elements: readonly Expression[]): CommaListExpression; + function createBundle(sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; - function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; + function updateBundle(node: Bundle, sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -4102,6 +4202,7 @@ declare namespace ts { function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createNullishCoalesce(left: Expression, right: Expression): BinaryExpression; function createLogicalNot(operand: Expression): PrefixUnaryExpression; function createVoidZero(): VoidExpression; function createExportDefault(expression: Expression): ExportAssignment; @@ -4158,7 +4259,7 @@ declare namespace ts { /** * Sets the constant value to emit for an expression. */ - function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): PropertyAccessExpression | ElementAccessExpression; + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): ElementAccessExpression | PropertyAccessExpression; /** * Adds an EmitHelper to a node. */ @@ -4263,23 +4364,25 @@ declare namespace ts { function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; } declare namespace ts { + function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined; + function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[]; function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } 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): ReadonlyArray; - interface FormatDiagnosticsHost { + export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; + export function resolveTripleslashReference(moduleName: string, containingFile: string): string; + export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + export interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; getNewLine(): string; } - function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; - function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; - function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + export function formatDiagnostics(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; + export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; + export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4290,7 +4393,7 @@ declare namespace ts { * @param createProgramOptions - The options for creating a program. * @returns A 'Program' object. */ - function createProgram(createProgramOptions: CreateProgramOptions): Program; + export function createProgram(createProgramOptions: CreateProgramOptions): Program; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4305,16 +4408,17 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; - /** @deprecated */ interface ResolveProjectReferencePathHost { + export function createProgram(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): Program; + /** @deprecated */ export interface ResolveProjectReferencePathHost { fileExists(fileName: string): boolean; } /** * Returns the target config filename of a project reference. * Note: The file might not exist. */ - function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; - /** @deprecated */ function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; + /** @deprecated */ export function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export {}; } declare namespace ts { interface EmitOutput { @@ -4366,31 +4470,31 @@ declare namespace ts { /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Get the diagnostics for compiler options */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics that dont belong to any file */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics from config file parsing */ - getConfigFileParsingDiagnostics(): ReadonlyArray; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Get the syntax diagnostics, for all source files if source file is not supplied */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the declaration diagnostics, for all source files if source file is not supplied */ - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** * Get all the dependencies of the file */ - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; + getAllDependencies(sourceFile: SourceFile): readonly string[]; /** * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program * The semantic diagnostics are cached and managed here @@ -4399,7 +4503,7 @@ declare namespace ts { * In case of SemanticDiagnosticsBuilderProgram if the source file is not provided, * it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Emits the JavaScript and declaration files. * When targetSource file is specified, emits the files corresponding to that source file, @@ -4425,7 +4529,7 @@ declare namespace ts { * Gets the semantic diagnostics from the program for the next affected file and caches it * Returns undefined if the iteration is complete */ - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; } /** * The builder that can handle the changes in program and iterate through changed file to emit the files @@ -4442,19 +4546,19 @@ declare namespace ts { /** * Create the builder to manage semantic diagnostics and cache them */ - function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ - function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ - function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): BuilderProgram; + function createAbstractBuilder(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram; } declare namespace ts { interface ReadBuildProgramHost { @@ -4465,21 +4569,21 @@ declare namespace ts { function readBuilderProgram(compilerOptions: CompilerOptions, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram | undefined; function createIncrementalCompilerHost(options: CompilerOptions, system?: System): CompilerHost; interface IncrementalProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - configFileParsingDiagnostics?: ReadonlyArray; - projectReferences?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; createProgram?: CreateProgram; } function createIncrementalProgram({ rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram }: IncrementalProgramOptions): T; - type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; + type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number) => void; /** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */ - type CreateProgram = (rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray | undefined) => T; + type CreateProgram = (rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[] | undefined) => T; /** Host that has watch functionality used in --watch mode */ interface WatchHost { /** If provided, called with Diagnostic message that informs about change in watch status */ - onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions): void; + onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number): void; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4515,7 +4619,7 @@ declare namespace ts { /** If provided, used in resolutions as well as handling directory structure */ getDirectories?(path: string): string[]; /** If provided, used to cache and handle directory structure modifications */ - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; /** Symbol links resolution */ realpath?(path: string): string; /** If provided would be used to write log about compilation */ @@ -4523,9 +4627,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[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; } interface WatchCompilerHost extends ProgramHost, WatchHost { /** If provided, callback to invoke after every new program creation */ @@ -4540,7 +4644,7 @@ declare namespace ts { /** Compiler options */ options: CompilerOptions; /** Project References */ - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; } /** * Host to create watch with config file @@ -4554,7 +4658,7 @@ declare namespace ts { * Used to generate source file names from the config file and its include, exclude, files rules * and also to cache the directory stucture */ - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; } interface Watch { /** Synchronize with host and get updated program */ @@ -4578,7 +4682,7 @@ declare namespace ts { * Create the watch compiler host for either configFile or fileNames and its options */ function createWatchCompilerHost(configFileName: string, optionsToExtend: CompilerOptions | undefined, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfConfigFile; - function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray): WatchCompilerHostOfFilesAndCompilerOptions; + function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions; /** * Creates the watch from the host for root files and compiler options */ @@ -4631,8 +4735,8 @@ declare namespace ts { function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter; function createSolutionBuilderHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary): SolutionBuilderHost; function createSolutionBuilderWithWatchHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): SolutionBuilderWithWatchHost; - function createSolutionBuilder(host: SolutionBuilderHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; - function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilder(host: SolutionBuilderHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; enum InvalidatedProjectKind { Build = 0, UpdateBundle = 1, @@ -4657,14 +4761,14 @@ declare namespace ts { getBuilderProgram(): T | undefined; getProgram(): Program | undefined; getSourceFile(fileName: string): SourceFile | undefined; - getSourceFiles(): ReadonlyArray; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSourceFiles(): readonly SourceFile[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getAllDependencies(sourceFile: SourceFile): readonly string[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } interface UpdateBundleProject extends InvalidatedProjectBase { @@ -4727,7 +4831,7 @@ declare namespace ts.server { readonly kind: EventBeginInstallTypes | EventEndInstallTypes; readonly eventId: number; readonly typingsInstallerVersion: string; - readonly packagesToInstall: ReadonlyArray; + readonly packagesToInstall: readonly string[]; } interface BeginInstallTypes extends InstallTypes { readonly kind: EventBeginInstallTypes; @@ -4780,8 +4884,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): ReadonlyArray; - getConstructSignatures(): ReadonlyArray; + getCallSignatures(): readonly Signature[]; + getConstructSignatures(): readonly Signature[]; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4809,7 +4913,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): ReadonlyArray; + getLineStarts(): readonly number[]; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -4858,7 +4962,7 @@ declare namespace ts { fileName: Path; packageName: string; } - interface LanguageServiceHost extends GetEffectiveTypeRootsHost { + interface LanguageServiceHost extends ModuleSpecifierResolutionHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; getProjectVersion?(): string; @@ -4866,7 +4970,7 @@ declare namespace ts { getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; - getProjectReferences?(): ReadonlyArray | undefined; + getProjectReferences?(): readonly ProjectReference[] | undefined; getLocalizedDiagnosticMessages?(): any; getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; @@ -4874,15 +4978,14 @@ declare namespace ts { log?(s: string): void; trace?(s: string): void; error?(s: string): void; - useCaseSensitiveFileNames?(): boolean; - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. @@ -4920,17 +5023,17 @@ 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, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined; getSmartSelectionRange(fileName: string, position: number): SelectionRange; - getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; - getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): readonly ImplementationLocation[] | 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): ReadonlyArray | undefined; + getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4950,7 +5053,7 @@ declare namespace ts { getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: FormatCodeSettings, preferences: UserPreferences): readonly CodeFixAction[]; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise; applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise; @@ -4963,8 +5066,8 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined; - organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; + organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program | undefined; dispose(): void; @@ -5113,8 +5216,8 @@ declare namespace ts { fixAllDescription?: string; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray; + changes: readonly FileTextChanges[]; + commands?: readonly CodeActionCommand[]; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -5235,6 +5338,11 @@ declare namespace ts { Block = 1, Smart = 2 } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorOptions { BaseIndentSize?: number; IndentSize: number; @@ -5287,6 +5395,7 @@ declare namespace ts { readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; readonly insertSpaceBeforeTypeAnnotation?: boolean; readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly semicolons?: SemicolonPreference; } function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; interface DefinitionInfo extends DocumentSpan { @@ -5296,7 +5405,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions?: ReadonlyArray; + definitions?: readonly DefinitionInfo[]; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -5665,6 +5774,7 @@ declare namespace ts { } } declare namespace ts { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier(): Classifier; } declare namespace ts { diff --git a/lib/typescript.js b/lib/typescript.js index b93aa3daff63c..50f34fef1fb57 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -14,6 +14,13 @@ and limitations under the License. ***************************************************************************** */ "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -73,7 +80,7 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -91,7 +98,7 @@ var ts; ts.emptyArray = []; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -126,7 +133,7 @@ var ts; } ts.createMapFromTemplate = createMapFromTemplate; // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name + // eslint-disable-next-line no-in-operator ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { @@ -190,7 +197,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -287,6 +294,21 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Like `forEach`, but iterates in reverse order. + */ + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ function firstDefined(array, callback) { if (array === undefined) { @@ -783,7 +805,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -840,6 +862,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1230,6 +1253,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1368,6 +1403,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1427,7 +1468,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1461,7 +1502,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1935,11 +1976,33 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2016,8 +2079,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2066,6 +2131,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2081,7 +2147,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2189,6 +2255,9 @@ var ts; Debug.assertNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1 /* Normal */) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -2369,6 +2438,47 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + // require() will throw an exception if the module is not installed + // It may also return undefined if not installed properly + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { // https://semver.org/#spec-item-2 // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative @@ -2767,358 +2877,366 @@ var ts; 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"; + SyntaxKind[SyntaxKind["QuestionDotToken"] = 28] = "QuestionDotToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 29] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 30] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 31] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 32] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 33] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 34] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 35] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 36] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 37] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 38] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 39] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 40] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 41] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 42] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 43] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 44] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 45] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 46] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 47] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 49] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 50] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 51] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 52] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 53] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 54] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 55] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 56] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 57] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 58] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 59] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - SyntaxKind[SyntaxKind["BacktickToken"] = 59] = "BacktickToken"; + SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 60] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 61] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 62] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 63] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 64] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 65] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 66] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 67] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 69] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 70] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 71] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 72] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 74] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 73] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 75] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 74] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 75] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 76] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 77] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 78] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 79] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 80] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 81] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 82] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 83] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 84] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 85] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 86] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 87] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 88] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 89] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 90] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 91] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 92] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 93] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 94] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 95] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 96] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 97] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 98] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 99] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 100] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 101] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 102] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 103] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 104] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 105] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 106] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 107] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 108] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 109] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 76] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 77] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 78] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 79] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 80] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 81] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 82] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 83] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 84] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 85] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 86] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 87] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 88] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 89] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 90] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 91] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 92] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 93] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 94] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 95] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 96] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 97] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 98] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 99] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 100] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 101] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 102] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 103] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 104] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 105] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 106] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 107] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 108] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 109] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 110] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 111] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 110] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 111] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 112] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 113] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 114] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 115] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 116] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 117] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 118] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 112] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 113] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 114] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 115] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 116] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 117] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 118] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 119] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 120] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 119] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 120] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 121] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 122] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 123] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 124] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 125] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 126] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 127] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 128] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 129] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 130] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 131] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 132] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 133] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 134] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 135] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 136] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 137] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 138] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 139] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 140] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 141] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 142] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 143] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 144] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 121] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 122] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 123] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 124] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 125] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 126] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 127] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 128] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 129] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 130] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 131] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 132] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 133] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 134] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 135] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 136] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 137] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 138] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 139] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 140] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 141] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 142] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 143] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 144] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 145] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 146] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 147] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 148] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 149] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 150] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 151] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 152] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 153] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 154] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 155] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 156] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 157] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 158] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 159] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 160] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 161] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 162] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 163] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 164] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 165] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 166] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 167] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 168] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 169] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 170] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 171] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 172] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 173] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 174] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 175] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 176] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 177] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 178] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 179] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 180] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 181] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 182] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 183] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 184] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 185] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 186] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 187] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 188] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 189] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 190] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 191] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 192] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 193] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 194] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 195] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 196] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 197] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 198] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 199] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 200] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 201] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 202] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 203] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 204] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 205] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 206] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 207] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 208] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 209] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 210] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 211] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 212] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 213] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 214] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 215] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 216] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 217] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 218] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 219] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 220] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 221] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 222] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 223] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 224] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 225] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 226] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 227] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 228] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 229] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 230] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 231] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 232] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 233] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 234] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 235] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 236] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 237] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 238] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 239] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 240] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 241] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 242] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 243] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 244] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 245] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 246] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 247] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 248] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 249] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 250] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 251] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 252] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 253] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 254] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 255] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 256] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 257] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 258] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 259] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 260] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 261] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 262] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 263] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 264] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 265] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 266] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 267] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 268] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 269] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 270] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 271] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 272] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 273] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 274] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 275] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 276] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 277] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 278] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 279] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 280] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 281] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 282] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 283] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 284] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 285] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 286] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 287] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 288] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 289] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 290] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 291] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 292] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 293] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 297] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 298] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 299] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 300] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 301] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 302] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 303] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 304] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 305] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 306] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 307] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 308] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 309] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 310] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 311] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 312] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 294] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 295] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 296] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 297] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 298] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 299] = "JSDocVariadicType"; + // https://jsdoc.app/about-namepaths.html + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 300] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 301] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 302] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 303] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 304] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 305] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 306] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 307] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 308] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 309] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 310] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 311] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 312] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 313] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 314] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 315] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 316] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 313] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 317] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 314] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 315] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 316] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 317] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 318] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 318] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 319] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 320] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 321] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 322] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 323] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 319] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 324] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 61] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 72] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 74] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 74] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 76] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 111] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 76] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 151] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 112] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 120] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 167] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 187] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 74] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 151] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 312] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 300] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 312] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 74] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 224] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 240] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 152] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 292] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 316] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 304] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 316] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 121] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 151] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3128,20 +3246,21 @@ var ts; NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain"; + NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 1024] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2048] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4096] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData"; // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid // walking the tree if the flags are not set. However, these flags are just a approximation // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. @@ -3151,23 +3270,23 @@ var ts; // removal, it is likely that users will add the import anyway. // The advantage of this approach is its simplicity. For the case of batch compilation, // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta"; - NodeFlags[NodeFlags["JSDoc"] = 2097152] = "JSDoc"; - /* @internal */ NodeFlags[NodeFlags["Ambient"] = 4194304] = "Ambient"; - /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 8388608] = "InWithStatement"; - NodeFlags[NodeFlags["JsonFile"] = 16777216] = "JsonFile"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta"; + NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc"; + /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient"; + /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement"; + NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 12679168] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags"; // Represents all flags that are potentially set once and // never cleared on SourceFiles which get re-used in between incremental parses. // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. - /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags"; + /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -3206,7 +3325,10 @@ var ts; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; - RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + RelationComparisonResult[RelationComparisonResult["Reported"] = 4] = "Reported"; + RelationComparisonResult[RelationComparisonResult["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable"; + RelationComparisonResult[RelationComparisonResult["ReportsUnreliable"] = 16] = "ReportsUnreliable"; + RelationComparisonResult[RelationComparisonResult["ReportsMask"] = 24] = "ReportsMask"; })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ var GeneratedIdentifierFlags; @@ -3242,6 +3364,8 @@ var ts; /* @internal */ TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator"; /* @internal */ + TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; + /* @internal */ TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; @@ -3257,12 +3381,13 @@ var ts; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; - FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Call"] = 512] = "Call"; + FlowFlags[FlowFlags["Referenced"] = 1024] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 2048] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 4096] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 8192] = "AfterFinally"; /** @internal */ - FlowFlags[FlowFlags["Cached"] = 8192] = "Cached"; + FlowFlags[FlowFlags["Cached"] = 16384] = "Cached"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -3272,6 +3397,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3292,6 +3424,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3357,7 +3491,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3407,27 +3540,40 @@ var ts; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + TypePredicateKind[TypePredicateKind["AssertsThis"] = 2] = "AssertsThis"; + TypePredicateKind[TypePredicateKind["AssertsIdentifier"] = 3] = "AssertsIdentifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3465,32 +3611,32 @@ var ts; SymbolFlags[SymbolFlags["All"] = 67108863] = "All"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 67220415] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 67897832] = "Type"; + SymbolFlags[SymbolFlags["Value"] = 111551] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 788968] = "Type"; SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; // Variables can be redeclared, but can not redeclare a block-scoped declaration with the // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 67220414] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 111550] = "FunctionScopedVariableExcludes"; // Block-scoped declarations are not allowed to be re-declared // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 67220415] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 67220415] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 111551] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 111551] = "ParameterExcludes"; SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 68008959] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 67219887] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 68008383] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 67897736] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 68008191] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 68008831] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 110991] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899503] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 788872] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 110735] = "ValueModuleExcludes"; SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 67212223] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 67154879] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 67187647] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 67635688] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 67897832] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 103359] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 46015] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 78783] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 526824] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 788968] = "TypeAliasExcludes"; SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; @@ -3498,11 +3644,15 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; /* @internal */ + SymbolFlags[SymbolFlags["ExportSupportsDefaultModifier"] = 112] = "ExportSupportsDefaultModifier"; + /* @internal */ + SymbolFlags[SymbolFlags["ExportDoesNotSupportDefaultModifier"] = -113] = "ExportDoesNotSupportDefaultModifier"; + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable"; /* @internal */ - SymbolFlags[SymbolFlags["LateBindingContainer"] = 6240] = "LateBindingContainer"; + SymbolFlags[SymbolFlags["LateBindingContainer"] = 6256] = "LateBindingContainer"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ var EnumKind; @@ -3740,7 +3890,9 @@ var ts; InferencePriority[InferencePriority["LiteralKeyof"] = 32] = "LiteralKeyof"; InferencePriority[InferencePriority["NoConstraints"] = 64] = "NoConstraints"; InferencePriority[InferencePriority["AlwaysStrict"] = 128] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 256] = "MaxValue"; InferencePriority[InferencePriority["PriorityImpliesCombination"] = 56] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ var InferenceFlags; @@ -3818,6 +3970,9 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + // NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind. + // Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES + // module kind). ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); @@ -4402,7 +4557,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -4556,6 +4711,38 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + /* @internal */ + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; /** * Returns true if file status changed */ @@ -4582,6 +4769,8 @@ var ts; ts.getFileWatcherEventKind = getFileWatcherEventKind; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + /*@internal*/ + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4686,6 +4875,32 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + /** + * patch writefile to create folder before writing the file + */ + /*@internal*/ + function patchWriteFileEnsuringDirectory(sys) { + // patch writefile to create folder before writing the file + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -4702,12 +4917,14 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does // not actually work. var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -4719,9 +4936,12 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; + var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); var FileSystemEntryKind; @@ -4732,6 +4952,7 @@ var ts; var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -4798,8 +5019,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -4825,6 +5048,90 @@ var ts; base64encode: function (input) { return bufferFrom(input).toString("base64"); }, }; return nodeSystem; + /** + * Uses the builtin inspector APIs to capture a CPU profile + * See https://nodejs.org/api/inspector.html#inspector_example_usage for details + */ + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + /** + * Strips non-TS paths from the profile, so users with private projects shouldn't + * need to worry about leaking paths by submitting a cpu profile to us + */ + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + // do nothing and ignore fallible fs operation + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + // do nothing and ignore fallible fs operation + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { // See https://github.com/Microsoft/TypeScript/issues/25652 return Buffer.from && Buffer.from !== Int8Array.from @@ -4868,7 +5175,7 @@ var ts; return useNonPollingWatchers ? createNonPollingWatchFile() : // Default to do not use polling interval as it is before this experiment branch - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, /*pollingInterval*/ undefined); }; } function getWatchDirectory() { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows @@ -4942,7 +5249,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -5000,6 +5307,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } /** Watcher for the file system entry depending on whether it is missing or present */ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : @@ -5016,6 +5329,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -5040,7 +5354,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); // Watch the missing file or directory or error presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; @@ -5052,11 +5368,23 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations + // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } /** * Watch the file or directory using fs.watchFile since fs.watch threw exception * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } /** @@ -5089,7 +5417,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -5117,7 +5445,14 @@ var ts; // Default is UTF-8 with no byte order mark return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); // If a BOM is required, emit one if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; @@ -5134,6 +5469,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -5189,6 +5525,7 @@ var ts; return fileSystemEntryExists(path, 1 /* Directory */); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } function realpath(path) { @@ -5266,16 +5603,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -5287,14 +5614,7 @@ var ts; } if (sys) { // patch writefile to create folder before writing the file - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -5313,10 +5633,9 @@ var ts; /* @internal */ var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; } - // tslint:disable-next-line variable-name ts.Diagnostics = { Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), @@ -5379,7 +5698,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -5434,7 +5752,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -5532,6 +5849,7 @@ var ts; A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -5564,7 +5882,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -5578,6 +5896,16 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(1359, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_1359", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(1360, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_1360", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), 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."), @@ -5621,7 +5949,7 @@ var ts; Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), @@ -5869,6 +6197,9 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -5991,6 +6322,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), 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}'."), @@ -6077,6 +6416,9 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -6087,6 +6429,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -6112,6 +6455,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -6299,6 +6643,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + 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}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -6317,9 +6662,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), 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}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -6358,6 +6705,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -6444,6 +6793,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -6473,6 +6824,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6590,6 +6942,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -6600,94 +6960,95 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 73 /* Identifier */; + return token >= 75 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119 /* AbstractKeyword */, - any: 121 /* AnyKeyword */, - as: 120 /* AsKeyword */, - bigint: 147 /* BigIntKeyword */, - boolean: 124 /* BooleanKeyword */, - break: 74 /* BreakKeyword */, - case: 75 /* CaseKeyword */, - catch: 76 /* CatchKeyword */, - class: 77 /* ClassKeyword */, - continue: 79 /* ContinueKeyword */, - const: 78 /* ConstKeyword */ + abstract: 121 /* AbstractKeyword */, + any: 124 /* AnyKeyword */, + as: 122 /* AsKeyword */, + asserts: 123 /* AssertsKeyword */, + bigint: 150 /* BigIntKeyword */, + boolean: 127 /* BooleanKeyword */, + break: 76 /* BreakKeyword */, + case: 77 /* CaseKeyword */, + catch: 78 /* CatchKeyword */, + class: 79 /* ClassKeyword */, + continue: 81 /* ContinueKeyword */, + const: 80 /* ConstKeyword */ }, - _a["" + "constructor"] = 125 /* ConstructorKeyword */, - _a.debugger = 80 /* DebuggerKeyword */, - _a.declare = 126 /* DeclareKeyword */, - _a.default = 81 /* DefaultKeyword */, - _a.delete = 82 /* DeleteKeyword */, - _a.do = 83 /* DoKeyword */, - _a.else = 84 /* ElseKeyword */, - _a.enum = 85 /* EnumKeyword */, - _a.export = 86 /* ExportKeyword */, - _a.extends = 87 /* ExtendsKeyword */, - _a.false = 88 /* FalseKeyword */, - _a.finally = 89 /* FinallyKeyword */, - _a.for = 90 /* ForKeyword */, - _a.from = 145 /* FromKeyword */, - _a.function = 91 /* FunctionKeyword */, - _a.get = 127 /* GetKeyword */, - _a.if = 92 /* IfKeyword */, - _a.implements = 110 /* ImplementsKeyword */, - _a.import = 93 /* ImportKeyword */, - _a.in = 94 /* InKeyword */, - _a.infer = 128 /* InferKeyword */, - _a.instanceof = 95 /* InstanceOfKeyword */, - _a.interface = 111 /* InterfaceKeyword */, - _a.is = 129 /* IsKeyword */, - _a.keyof = 130 /* KeyOfKeyword */, - _a.let = 112 /* LetKeyword */, - _a.module = 131 /* ModuleKeyword */, - _a.namespace = 132 /* NamespaceKeyword */, - _a.never = 133 /* NeverKeyword */, - _a.new = 96 /* NewKeyword */, - _a.null = 97 /* NullKeyword */, - _a.number = 136 /* NumberKeyword */, - _a.object = 137 /* ObjectKeyword */, - _a.package = 113 /* PackageKeyword */, - _a.private = 114 /* PrivateKeyword */, - _a.protected = 115 /* ProtectedKeyword */, - _a.public = 116 /* PublicKeyword */, - _a.readonly = 134 /* ReadonlyKeyword */, - _a.require = 135 /* RequireKeyword */, - _a.global = 146 /* GlobalKeyword */, - _a.return = 98 /* ReturnKeyword */, - _a.set = 138 /* SetKeyword */, - _a.static = 117 /* StaticKeyword */, - _a.string = 139 /* StringKeyword */, - _a.super = 99 /* SuperKeyword */, - _a.switch = 100 /* SwitchKeyword */, - _a.symbol = 140 /* SymbolKeyword */, - _a.this = 101 /* ThisKeyword */, - _a.throw = 102 /* ThrowKeyword */, - _a.true = 103 /* TrueKeyword */, - _a.try = 104 /* TryKeyword */, - _a.type = 141 /* TypeKeyword */, - _a.typeof = 105 /* TypeOfKeyword */, - _a.undefined = 142 /* UndefinedKeyword */, - _a.unique = 143 /* UniqueKeyword */, - _a.unknown = 144 /* UnknownKeyword */, - _a.var = 106 /* VarKeyword */, - _a.void = 107 /* VoidKeyword */, - _a.while = 108 /* WhileKeyword */, - _a.with = 109 /* WithKeyword */, - _a.yield = 118 /* YieldKeyword */, - _a.async = 122 /* AsyncKeyword */, - _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a["" + "constructor"] = 128 /* ConstructorKeyword */, + _a.debugger = 82 /* DebuggerKeyword */, + _a.declare = 129 /* DeclareKeyword */, + _a.default = 83 /* DefaultKeyword */, + _a.delete = 84 /* DeleteKeyword */, + _a.do = 85 /* DoKeyword */, + _a.else = 86 /* ElseKeyword */, + _a.enum = 87 /* EnumKeyword */, + _a.export = 88 /* ExportKeyword */, + _a.extends = 89 /* ExtendsKeyword */, + _a.false = 90 /* FalseKeyword */, + _a.finally = 91 /* FinallyKeyword */, + _a.for = 92 /* ForKeyword */, + _a.from = 148 /* FromKeyword */, + _a.function = 93 /* FunctionKeyword */, + _a.get = 130 /* GetKeyword */, + _a.if = 94 /* IfKeyword */, + _a.implements = 112 /* ImplementsKeyword */, + _a.import = 95 /* ImportKeyword */, + _a.in = 96 /* InKeyword */, + _a.infer = 131 /* InferKeyword */, + _a.instanceof = 97 /* InstanceOfKeyword */, + _a.interface = 113 /* InterfaceKeyword */, + _a.is = 132 /* IsKeyword */, + _a.keyof = 133 /* KeyOfKeyword */, + _a.let = 114 /* LetKeyword */, + _a.module = 134 /* ModuleKeyword */, + _a.namespace = 135 /* NamespaceKeyword */, + _a.never = 136 /* NeverKeyword */, + _a.new = 98 /* NewKeyword */, + _a.null = 99 /* NullKeyword */, + _a.number = 139 /* NumberKeyword */, + _a.object = 140 /* ObjectKeyword */, + _a.package = 115 /* PackageKeyword */, + _a.private = 116 /* PrivateKeyword */, + _a.protected = 117 /* ProtectedKeyword */, + _a.public = 118 /* PublicKeyword */, + _a.readonly = 137 /* ReadonlyKeyword */, + _a.require = 138 /* RequireKeyword */, + _a.global = 149 /* GlobalKeyword */, + _a.return = 100 /* ReturnKeyword */, + _a.set = 141 /* SetKeyword */, + _a.static = 119 /* StaticKeyword */, + _a.string = 142 /* StringKeyword */, + _a.super = 101 /* SuperKeyword */, + _a.switch = 102 /* SwitchKeyword */, + _a.symbol = 143 /* SymbolKeyword */, + _a.this = 103 /* ThisKeyword */, + _a.throw = 104 /* ThrowKeyword */, + _a.true = 105 /* TrueKeyword */, + _a.try = 106 /* TryKeyword */, + _a.type = 144 /* TypeKeyword */, + _a.typeof = 107 /* TypeOfKeyword */, + _a.undefined = 145 /* UndefinedKeyword */, + _a.unique = 146 /* UniqueKeyword */, + _a.unknown = 147 /* UnknownKeyword */, + _a.var = 108 /* VarKeyword */, + _a.void = 109 /* VoidKeyword */, + _a.while = 110 /* WhileKeyword */, + _a.with = 111 /* WithKeyword */, + _a.yield = 120 /* YieldKeyword */, + _a.async = 125 /* AsyncKeyword */, + _a.await = 126 /* AwaitKeyword */, + _a.of = 151 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - 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 */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 74 /* CaretEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6734,6 +7095,14 @@ var ts; */ 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,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 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, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 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, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 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, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 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, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + /** + * Generated by scripts/regenerate-unicode-identifier-parts.js on node v12.4.0 with unicode 12.1 + * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords + * unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and + * unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start + */ + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 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, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 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, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 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, 2809, 2809, 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, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 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, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 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, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 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, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 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, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 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, 43824, 43866, 43868, 43879, 43888, 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, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 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, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -6760,15 +7129,17 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -6941,6 +7312,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7264,11 +7636,12 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -7292,17 +7665,18 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */; }, + isIdentifier: function () { return token === 75 /* Identifier */ || token > 111 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -7312,6 +7686,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -7326,6 +7701,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7425,7 +7809,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -7633,6 +8017,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024 /* UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: @@ -7715,21 +8100,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92 /* backslash */) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024 /* UnicodeEscape */; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters pos += 6; start = pos; @@ -7753,7 +8158,7 @@ var ts; } } } - return token = 73 /* Identifier */; + return token = 75 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -7817,14 +8222,14 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); // Special handling for shebang if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); @@ -7888,12 +8293,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 34 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* ExclamationEqualsToken */; } pos++; - return token = 52 /* ExclamationToken */; + return token = 53 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -7902,19 +8307,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* PercentEqualsToken */; + return pos += 2, token = 68 /* PercentEqualsToken */; } pos++; - return token = 43 /* PercentToken */; + return token = 44 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 54 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* AmpersandEqualsToken */; + return pos += 2, token = 72 /* AmpersandEqualsToken */; } pos++; - return token = 49 /* AmpersandToken */; + return token = 50 /* AmpersandToken */; case 40 /* openParen */: pos++; return token = 20 /* OpenParenToken */; @@ -7923,13 +8328,13 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AsteriskEqualsToken */; + return pos += 2, token = 65 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 41 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -7937,28 +8342,28 @@ var ts; asteriskSeen = true; continue; } - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 44 /* PlusPlusToken */; + return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* PlusEqualsToken */; + return pos += 2, token = 63 /* PlusEqualsToken */; } pos++; - return token = 38 /* PlusToken */; + return token = 39 /* PlusToken */; case 44 /* comma */: pos++; return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 45 /* MinusMinusToken */; + return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* MinusEqualsToken */; + return pos += 2, token = 64 /* MinusEqualsToken */; } pos++; - return token = 39 /* MinusToken */; + return token = 40 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -8019,10 +8424,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* SlashEqualsToken */; + return pos += 2, token = 67 /* SlashEqualsToken */; } pos++; - return token = 42 /* SlashToken */; + return token = 43 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -8080,7 +8485,7 @@ var ts; return token; case 58 /* colon */: pos++; - return token = 57 /* ColonToken */; + return token = 58 /* ColonToken */; case 59 /* semicolon */: pos++; return token = 26 /* SemicolonToken */; @@ -8096,20 +8501,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 46 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 31 /* LessThanEqualsToken */; + return pos += 2, token = 32 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 29 /* LessThanSlashToken */; + return pos += 2, token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8122,15 +8527,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 33 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 37 /* EqualsGreaterThanToken */; + return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8142,10 +8547,18 @@ var ts; } } pos++; - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 56 /* QuestionToken */; + if (text.charCodeAt(pos) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28 /* QuestionDotToken */; + } + if (text.charCodeAt(pos) === 63 /* question */) { + pos++; + return token = 60 /* QuestionQuestionToken */; + } + return token = 57 /* QuestionToken */; case 91 /* openBracket */: pos++; return token = 22 /* OpenBracketToken */; @@ -8154,10 +8567,10 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* CaretEqualsToken */; + return pos += 2, token = 74 /* CaretEqualsToken */; } pos++; - return token = 51 /* CaretToken */; + return token = 52 /* CaretToken */; case 123 /* openBrace */: pos++; return token = 18 /* OpenBraceToken */; @@ -8172,26 +8585,34 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 55 /* BarBarToken */; + return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* BarEqualsToken */; + return pos += 2, token = 73 /* BarEqualsToken */; } pos++; - return token = 50 /* BarToken */; + return token = 51 /* BarToken */; case 125 /* closeBrace */: pos++; return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 53 /* TildeToken */; + return token = 54 /* TildeToken */; case 64 /* at */: pos++; - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 92 /* backslash */: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -8200,9 +8621,9 @@ var ts; return token = 0 /* Unknown */; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { tokenValue += scanIdentifierParts(); @@ -8210,44 +8631,44 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1 /* PrecedingLineBreak */; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0 /* Unknown */; } } } function reScanGreaterToken() { - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 47 /* GreaterThanGreaterThanToken */; + return token = 48 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 32 /* GreaterThanEqualsToken */; + return token = 33 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 42 /* SlashToken */ || token === 65 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -8309,12 +8730,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46 /* LessThanLessThanToken */) { + if (token === 47 /* LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57 /* QuestionToken */; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -8324,10 +8750,10 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 29 /* LessThanSlashToken */; + return token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; @@ -8336,7 +8762,7 @@ var ts; // First non-whitespace character on this line. var firstNonWhitespace = 0; // These initial values are special because the first line is: - // firstNonWhitespace = 0 to indicate that we want leading whitspace, + // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { @@ -8370,17 +8796,22 @@ var ts; // they allow dashes function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; + // An identifier or keyword has already been parsed - check for a `-` and then append it and everything after it to the token + // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token + // Any caller should be expecting this behavior and should only read the pos or token value after calling it. while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45 /* minus */) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -8398,12 +8829,12 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9 /* tab */: case 11 /* verticalTab */: @@ -8414,13 +8845,13 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 123 /* openBrace */: return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: @@ -8430,23 +8861,44 @@ var ts; case 93 /* closeBracket */: return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 62 /* greaterThan */: - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 44 /* comma */: return token = 27 /* CommaToken */; case 46 /* dot */: return token = 24 /* DotToken */; case 96 /* backtick */: - return token = 59 /* BacktickToken */; - } - if (isIdentifierStart(ch, 99 /* Latest */)) { - while (isIdentifierPart(text.charCodeAt(pos), 99 /* Latest */) && pos < end) { + return token = 61 /* BacktickToken */; + case 92 /* backslash */: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0 /* Unknown */; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -8522,13 +8974,40 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; } } ts.createScanner = createScanner; + /* @internal */ + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt + var size = str.length; + // Account for out-of-bounds indices: + if (i < 0 || i >= size) { + return undefined; // String.codePointAt returns `undefined` for OOB indexes + } + // Get the first code unit + var first = str.charCodeAt(i); + // check if it’s the start of a surrogate pair + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { // high surrogate and there is a next code unit + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + /* @internal */ + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -8608,6 +9087,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str += " "; }, @@ -8695,7 +9176,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -8783,28 +9264,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144 /* HasAggregatedChildData */)) { + if (!(node.flags & 524288 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 262144 /* HasAggregatedChildData */; + node.flags |= 524288 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 288 /* SourceFile */) { node = node.parent; } return node; @@ -8812,11 +9293,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return true; } return false; @@ -8901,7 +9382,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -8984,7 +9465,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 === 313 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 317 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9003,7 +9484,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9049,6 +9530,8 @@ var ts; ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } + // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text + // had to include a backslash: `not \${a} substitution`. 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. @@ -9061,15 +9544,21 @@ var ts; return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } case 14 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings - return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings - return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 17 /* TemplateTail */: - return "}" + escapeText(node.text, 96 /* backtick */) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + switch (node.kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + return "`" + rawText + "`"; + case 15 /* TemplateHead */: + return "`" + rawText + "${"; + case 16 /* TemplateMiddle */: + return "}" + rawText + "${"; + case 17 /* TemplateTail */: + return "}" + rawText + "`"; + } + break; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 13 /* RegularExpressionLiteral */: @@ -9095,7 +9584,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 241 /* VariableDeclaration */ && node.parent.kind === 278 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9127,16 +9616,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 248 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 288 /* SourceFile */ || + node.kind === 248 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -9148,9 +9637,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 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9164,24 +9653,61 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /** + * Returns whether the source file will be treated as if it were in strict mode at runtime. + */ + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + // We can only verify strict mode for JS/TS files + switch (node.scriptKind) { + case 1 /* JS */: + case 3 /* TS */: + case 2 /* JSX */: + case 4 /* TSX */: + break; + default: + return false; + } + // Strict mode does not matter for declaration files. + if (node.isDeclarationFile) { + return false; + } + // If `alwaysStrict` is set, then treat the file as strict. + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + // Starting with a "use strict" directive indicates the file is strict. + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + // ECMAScript Modules are always strict. + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + // Other modules are strict unless otherwise specified. + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 278 /* CatchClause */: + case 248 /* ModuleDeclaration */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 219 /* Block */: + case 222 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9191,9 +9717,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 299 /* JSDocSignature */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 303 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9203,25 +9729,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9231,8 +9757,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9241,15 +9767,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 224 /* VariableStatement */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -9279,13 +9805,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -9296,11 +9822,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9345,7 +9871,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 222 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9359,7 +9885,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* 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 @@ -9368,25 +9894,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 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9394,6 +9920,7 @@ var ts; // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9423,7 +9950,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -9435,19 +9962,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 101 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 95 /* ImportKeyword */; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 95 /* ImportKeyword */ + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 225 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9456,11 +9989,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 155 /* Parameter */ || + node.kind === 154 /* TypeParameter */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 201 /* ArrowFunction */ || + node.kind === 199 /* 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 '/**/' @@ -9476,48 +10009,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= node.kind && node.kind <= 187 /* LastTypeNode */) { return true; } switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: return true; - case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + case 109 /* VoidKeyword */: + return node.parent.kind !== 204 /* VoidExpression */; + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 154 /* TypeParameter */: + return node.parent.kind === 185 /* MappedType */ || node.parent.kind === 180 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 73 /* Identifier */: + case 75 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 193 /* 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 === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */ || node.kind === 193 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: - case 101 /* ThisKeyword */: { + case 152 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 103 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 171 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 187 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9526,40 +10059,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 (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= parent.kind && parent.kind <= 187 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return node === parent.constraint; - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9584,23 +10117,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 250 /* CaseBlock */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9610,26 +10143,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* 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 === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* 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); @@ -9652,10 +10185,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 173 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 168 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9665,12 +10198,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 172 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return node.properties; } } @@ -9678,14 +10211,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 282 /* EnumMember */: + case 155 /* Parameter */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 241 /* VariableDeclaration */: return true; } } @@ -9697,8 +10230,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 242 /* VariableDeclarationList */ + && node.parent.parent.kind === 224 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9709,13 +10242,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return true; } return false; @@ -9726,7 +10259,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 237 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9734,17 +10267,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 222 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 160 /* MethodDeclaration */ && node.parent.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 160 /* MethodDeclaration */ && + (node.parent.kind === 192 /* ObjectLiteralExpression */ || + node.parent.kind === 213 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9757,7 +10290,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9798,14 +10331,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 288 /* 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 150 /* ComputedPropertyName */: + case 153 /* 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 @@ -9820,9 +10353,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* 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; @@ -9833,26 +10366,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 248 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 247 /* EnumDeclaration */: + case 288 /* SourceFile */: return node; } } @@ -9862,9 +10395,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return container; } } @@ -9886,27 +10419,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* 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; @@ -9922,21 +10455,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 200 /* FunctionExpression */ || func.kind === 201 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 199 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 195 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 /* SuperKeyword */ + return node.kind === 101 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -9945,8 +10478,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 99 /* SuperKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 101 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -9954,20 +10487,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 101 /* ThisKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 103 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: return node; } return undefined; @@ -9975,10 +10508,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9987,25 +10520,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 244 /* ClassDeclaration */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* 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 === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 244 /* ClassDeclaration */; + case 155 /* 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 === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 161 /* Constructor */ + || parent.kind === 160 /* MethodDeclaration */ + || parent.kind === 163 /* SetAccessor */) + && grandparent.kind === 244 /* ClassDeclaration */; } return false; } @@ -10021,10 +10554,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10033,9 +10566,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 266 /* JsxOpeningElement */ || + parent.kind === 265 /* JsxSelfClosingElement */ || + parent.kind === 267 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10043,57 +10576,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 216 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 212 /* SpreadElement */: + case 210 /* TemplateExpression */: + case 214 /* OmittedExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 211 /* YieldExpression */: + case 205 /* AwaitExpression */: + case 218 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 152 /* QualifiedName */: + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); - case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node); + case 75 /* Identifier */: + if (node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -10103,49 +10636,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 190 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 225 /* ExpressionStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 234 /* ReturnStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 238 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 229 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 156 /* Decorator */: + case 274 /* JsxExpression */: + case 273 /* JsxSpreadAttribute */: + case 281 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10153,7 +10686,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10162,7 +10695,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 263 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10174,15 +10707,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 131072 /* JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 4194304 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10190,15 +10723,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 /* StringKeyword */ || node.typeArguments[0].kind === 136 /* NumberKeyword */); + (node.typeArguments[0].kind === 142 /* StringKeyword */ || node.typeArguments[0].kind === 139 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + if (callExpression.kind !== 195 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 75 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -10229,21 +10762,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - 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 === 60 /* EqualsToken */ && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 /* EqualsToken */ && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -10253,13 +10790,14 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(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 === 55 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -10273,14 +10811,20 @@ var ts; } 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); }); + 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 === 60 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -10306,11 +10850,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 200 /* FunctionExpression */ || e.kind === 201 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 200 /* FunctionExpression */ || + initializer.kind === 213 /* ClassExpression */ || + initializer.kind === 201 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10327,14 +10871,16 @@ 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 === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && 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 === 60 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -10342,8 +10888,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 === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -10362,19 +10908,20 @@ var ts; * my.app = self.my.app || class { } */ function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 /* ThisKeyword */ || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -10389,10 +10936,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { @@ -10407,55 +10957,116 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0]); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */) || + isEntityNameExpression(node.expression) || + isBindableStaticElementAccessExpression(node.expression, /*excludeThisKeyword*/ true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */ || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0 /* None */; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8 /* ObjectDefinePropertyExports */; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9 /* ObjectDefinePrototypeProperty */; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 60 /* EqualsToken */ || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left)) { return 0 /* None */; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } return 6 /* Prototype */; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); } + /** + * Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions + * throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand) + */ + /* @internal */ + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; + } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; + } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101 /* ThisKeyword */) { + if (lhs.expression.kind === 103 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") { // exports.name = expr OR module.exports.name = expr return 1 /* ExportsProperty */; } @@ -10478,7 +11089,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 225 /* ExpressionStatement */ && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10487,7 +11099,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10496,14 +11108,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 186 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10513,12 +11125,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 252 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 263 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 187 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10527,11 +11139,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10539,19 +11151,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 253 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 155 /* Parameter */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 280 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10565,7 +11177,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 /* JSDocTypedefTag */ || node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 315 /* JSDocTypedefTag */ || node.kind === 308 /* JSDocCallbackTag */ || node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10575,7 +11187,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 /* EqualsToken */ + node.expression.operatorToken.kind === 62 /* EqualsToken */ ? node.expression.right : undefined; } @@ -10584,18 +11196,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 /* BarBarToken */ + (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return node.initializer; } } @@ -10606,7 +11218,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 248 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10621,11 +11233,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 154 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10636,12 +11248,12 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 279 /* PropertyAssignment */ || + parent.kind === 258 /* ExportAssignment */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 225 /* ExpressionStatement */ && node.kind === 193 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10652,7 +11264,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10675,7 +11287,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10700,7 +11312,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10710,7 +11322,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 === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10723,31 +11335,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 62 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 191 /* ArrayLiteralExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10774,22 +11386,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 222 /* Block */: + case 224 /* VariableStatement */: + case 235 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return true; } return false; @@ -10806,33 +11418,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 181 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 199 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* 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 !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 202 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10854,11 +11466,12 @@ var ts; var parent = name.parent; switch (name.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -10881,8 +11494,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10890,32 +11503,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 193 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 152 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 171 /* TypeQuery */ || parent.kind === 168 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 190 /* BindingElement */: + case 257 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 261 /* ExportSpecifier */: + case 271 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10931,22 +11544,39 @@ var ts; // export = // export default // module.exports = + // {} + // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); + return node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 251 /* NamespaceExportDeclaration */ || + node.kind === 254 /* ImportClause */ && !!node.name || + node.kind === 255 /* NamespaceImport */ || + node.kind === 257 /* ImportSpecifier */ || + node.kind === 261 /* ExportSpecifier */ || + node.kind === 258 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 280 /* ShorthandPropertyAssignment */ || + node.kind === 279 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 279 /* PropertyAssignment */ ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -10960,24 +11590,24 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 112 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -11004,22 +11634,31 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 76 /* FirstKeyword */ <= token && token <= 151 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 121 /* FirstContextualKeyword */ <= token && token <= 151 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 112 /* FirstFutureReservedWord */ <= token && token <= 120 /* LastFutureReservedWord */; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -11043,14 +11682,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11064,10 +11703,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11080,7 +11719,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 /* PlusToken */ || node.operator === 39 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -11100,10 +11739,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 /* ComputedPropertyName */ || name.kind === 194 /* ElementAccessExpression */)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; /** @@ -11117,12 +11759,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11138,7 +11780,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -11149,11 +11791,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 75 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -11168,7 +11810,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 75 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -11177,11 +11819,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 155 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 190 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11189,15 +11831,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 161 /* Constructor */ + || kind === 200 /* FunctionExpression */ + || kind === 243 /* FunctionDeclaration */ + || kind === 201 /* ArrowFunction */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 248 /* ModuleDeclaration */ + || kind === 288 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11216,38 +11858,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operator) { - case 41 /* AsteriskAsteriskToken */: - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 42 /* AsteriskAsteriskToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 1 /* Right */; } } @@ -11256,15 +11898,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 208 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 206 /* PrefixUnaryExpression */ || expression.kind === 207 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11274,73 +11916,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 197 /* TaggedTemplateExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 19; - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 73 /* Identifier */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 75 /* Identifier */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 210 /* TemplateExpression */: + case 199 /* ParenthesizedExpression */: + case 214 /* OmittedExpression */: return 20; default: return -1; @@ -11349,41 +11991,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: + return 4; + case 56 /* BarBarToken */: return 5; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return 6; - case 50 /* BarToken */: + case 51 /* BarToken */: return 7; - case 51 /* CaretToken */: + case 52 /* CaretToken */: return 8; - case 49 /* AmpersandToken */: + case 50 /* AmpersandToken */: return 9; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return 10; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: return 11; - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 38 /* PlusToken */: - case 39 /* MinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: return 13; - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: return 14; - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -11460,6 +12104,10 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -11467,7 +12115,8 @@ var ts; // There is no reason for this other than that JSON.stringify does not handle it either. var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + // Template strings should be preserved as much as possible + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -11496,22 +12145,23 @@ var ts; } ts.escapeString = escapeString; /** - * Strip off existed single quotes or double quotes from a given string + * Strip off existed surrounding single quotes, double quotes, or backticks from a given string * * @return non-quoted string */ function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 /* singleQuote */ || + charCode === 34 /* doubleQuote */ || + charCode === 96 /* backtick */; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0 /* nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); @@ -11562,6 +12212,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -11573,7 +12224,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -11583,17 +12234,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -11607,6 +12270,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -11626,6 +12290,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -11640,12 +12306,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -11653,7 +12319,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -11709,7 +12375,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -11828,6 +12494,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; /** Get the type annotation for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); @@ -11849,11 +12516,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 75 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101 /* ThisKeyword */; + return id.originalKeywordKind === 103 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -11864,10 +12531,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 163 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11887,10 +12554,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 162 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 163 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11936,7 +12603,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 === 297 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12176,7 +12843,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 73 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 75 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -12184,29 +12851,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117 /* StaticKeyword */: return 32 /* Static */; - case 116 /* PublicKeyword */: return 4 /* Public */; - case 115 /* ProtectedKeyword */: return 16 /* Protected */; - case 114 /* PrivateKeyword */: return 8 /* Private */; - case 119 /* AbstractKeyword */: return 128 /* Abstract */; - case 86 /* ExportKeyword */: return 1 /* Export */; - case 126 /* DeclareKeyword */: return 2 /* Ambient */; - case 78 /* ConstKeyword */: return 2048 /* Const */; - case 81 /* DefaultKeyword */: return 512 /* Default */; - case 122 /* AsyncKeyword */: return 256 /* Async */; - case 134 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 119 /* StaticKeyword */: return 32 /* Static */; + case 118 /* PublicKeyword */: return 4 /* Public */; + case 117 /* ProtectedKeyword */: return 16 /* Protected */; + case 116 /* PrivateKeyword */: return 8 /* Private */; + case 121 /* AbstractKeyword */: return 128 /* Abstract */; + case 88 /* ExportKeyword */: return 1 /* Export */; + case 129 /* DeclareKeyword */: return 2 /* Ambient */; + case 80 /* ConstKeyword */: return 2048 /* Const */; + case 83 /* DefaultKeyword */: return 512 /* Default */; + case 125 /* AsyncKeyword */: return 256 /* Async */; + case 137 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 /* BarBarToken */ - || token === 54 /* AmpersandAmpersandToken */ - || token === 52 /* ExclamationToken */; + return token === 56 /* BarBarToken */ + || token === 55 /* AmpersandAmpersandToken */ + || token === 53 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 /* FirstAssignment */ && token <= 72 /* LastAssignment */; + return token >= 62 /* FirstAssignment */ && token <= 74 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -12219,14 +12886,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 /* EqualsToken */ + ? node.operatorToken.kind === 62 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -12234,8 +12901,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 192 /* ObjectLiteralExpression */ + || kind === 191 /* ArrayLiteralExpression */; } return false; } @@ -12245,9 +12912,15 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function isDottedName(node) { + return node.kind === 75 /* Identifier */ || node.kind === 103 /* ThisKeyword */ || + node.kind === 193 /* PropertyAccessExpression */ && isDottedName(node.expression) || + node.kind === 199 /* ParenthesizedExpression */ && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -12263,21 +12936,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 192 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 191 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12575,8 +13248,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12653,35 +13326,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 208 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 279 /* 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 277 /* ShorthandPropertyAssignment */: + case 280 /* 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 188 /* ArrayLiteralExpression */: + case 191 /* 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 === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12727,8 +13400,8 @@ var ts; /** * Mutates the map with newMap such that keys in map will be same as newMap. */ - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; // Needs update map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); @@ -12742,6 +13415,15 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + /** + * Mutates the map with newMap such that keys in map will be same as newMap. + */ + function mutateMap(map, newMap, options) { + // Needs update + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; // Add new values that are not already present newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { @@ -12751,7 +13433,6 @@ var ts; }); } ts.mutateMap = mutateMap; - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -12836,32 +13517,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) - || kind === 121 /* AnyKeyword */ - || kind === 144 /* UnknownKeyword */ - || kind === 136 /* NumberKeyword */ - || kind === 147 /* BigIntKeyword */ - || kind === 137 /* ObjectKeyword */ - || kind === 124 /* BooleanKeyword */ - || kind === 139 /* StringKeyword */ - || kind === 140 /* SymbolKeyword */ - || kind === 101 /* ThisKeyword */ - || kind === 107 /* VoidKeyword */ - || kind === 142 /* UndefinedKeyword */ - || kind === 97 /* NullKeyword */ - || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + return (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) + || kind === 124 /* AnyKeyword */ + || kind === 147 /* UnknownKeyword */ + || kind === 139 /* NumberKeyword */ + || kind === 150 /* BigIntKeyword */ + || kind === 140 /* ObjectKeyword */ + || kind === 127 /* BooleanKeyword */ + || kind === 142 /* StringKeyword */ + || kind === 143 /* SymbolKeyword */ + || kind === 103 /* ThisKeyword */ + || kind === 109 /* VoidKeyword */ + || kind === 145 /* UndefinedKeyword */ + || kind === 99 /* NullKeyword */ + || kind === 136 /* NeverKeyword */ + || kind === 215 /* ExpressionWithTypeArguments */ + || kind === 293 /* JSDocAllType */ + || kind === 294 /* JSDocUnknownType */ + || kind === 295 /* JSDocNullableType */ + || kind === 296 /* JSDocNonNullableType */ + || kind === 297 /* JSDocOptionalType */ + || kind === 298 /* JSDocFunctionType */ + || kind === 299 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */ || node.kind === 194 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -12874,6 +13555,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -12981,7 +13666,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13098,17 +13783,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 154 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245 /* InterfaceDeclaration */) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 161 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13138,14 +13823,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 241 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 242 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 224 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13209,7 +13894,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13291,27 +13977,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: var expr = hostNode.expression; + if (expr.kind === 208 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + expr = expr.left; + } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13323,6 +14012,17 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + /** @internal */ + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -13335,39 +14035,46 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return declaration; - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: { + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 152 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: case 4 /* ThisProperty */: case 5 /* Property */: case 3 /* PrototypeProperty */: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 309 /* JSDocEnumTag */: + return nameForNamelessJSDocTypedef(declaration); + case 258 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194 /* ElementAccessExpression */: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -13390,8 +14097,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -13569,7 +14276,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 301 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13589,10 +14296,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13637,198 +14343,216 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73 /* Identifier */; + return node.kind === 75 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 152 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 153 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 154 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 155 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 157 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 158 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 159 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 161 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 164 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 165 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 166 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 163 /* SetAccessor */ || node.kind === 162 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 167 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 168 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 169 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 170 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 171 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 172 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 173 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 174 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 177 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 178 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 179 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 180 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 181 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 182 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 183 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 184 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 185 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 186 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 187 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 188 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 189 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 190 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 191 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 194 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 195 /* CallExpression */; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + return isPropertyAccessChain(node) + || isElementAccessChain(node) + || isCallChain(node); + } + ts.isOptionalChain = isOptionalChain; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 196 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 197 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 198 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -13837,376 +14561,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 199 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315 /* PartiallyEmittedExpression */) { + while (node.kind === 319 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 200 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 201 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 202 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 203 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 204 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 205 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 206 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 207 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 208 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 209 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 210 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 211 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 212 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 213 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 214 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 216 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 217 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 218 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 220 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 221 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 222 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 224 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 223 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 225 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 226 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 227 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 228 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 229 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 230 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 231 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 232 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 233 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 233 /* BreakStatement */ || node.kind === 232 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 234 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 235 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 236 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 237 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 238 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 239 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 240 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 241 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 242 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 243 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 244 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 245 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 246 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 247 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 248 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 249 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 250 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 251 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 252 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 253 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 254 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 255 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 256 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 257 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 258 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 259 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 260 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 261 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 262 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 264 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 265 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 266 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 267 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 268 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 269 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 270 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 271 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 272 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 273 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 274 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 275 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 276 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 277 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 278 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 279 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 280 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 281 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 288 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 289 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 290 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 284 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return true; default: return false; @@ -14215,105 +14939,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 283 /* UnparsedPrologue */ || + node.kind === 287 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 292 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 293 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 294 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 295 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 296 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 297 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 298 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 299 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297 /* JSDocComment */; + return node.kind === 301 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302 /* JSDocAuthorTag */; + return node.kind === 306 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301 /* JSDocAugmentsTag */; + return node.kind === 305 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303 /* JSDocClassTag */; + return node.kind === 307 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305 /* JSDocEnumTag */; + return node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308 /* JSDocThisTag */; + return node.kind === 312 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307 /* JSDocReturnTag */; + return node.kind === 311 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309 /* JSDocTypeTag */; + return node.kind === 313 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310 /* JSDocTemplateTag */; + return node.kind === 314 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311 /* JSDocTypedefTag */; + return node.kind === 315 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312 /* JSDocPropertyTag */; + return node.kind === 316 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 /* JSDocPropertyTag */ || node.kind === 306 /* JSDocParameterTag */; + return node.kind === 316 /* JSDocPropertyTag */ || node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298 /* JSDocTypeLiteral */; + return node.kind === 302 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 308 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299 /* JSDocSignature */; + return node.kind === 303 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14324,7 +15048,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 313 /* SyntaxList */; + return n.kind === 317 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14334,7 +15058,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 152 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14343,7 +15067,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 <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 151 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14396,17 +15120,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 81 /* DefaultKeyword */: - case 86 /* ExportKeyword */: - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 117 /* StaticKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 83 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 119 /* StaticKeyword */: return true; } return false; @@ -14419,7 +15143,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 119 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -14428,23 +15152,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ + return kind === 75 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 153 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + return kind === 75 /* Identifier */ + || kind === 188 /* ObjectBindingPattern */ + || kind === 189 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14459,13 +15183,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: return false; @@ -14474,14 +15198,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 170 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14496,29 +15220,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 161 /* Constructor */ + || kind === 158 /* PropertyDeclaration */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 166 /* IndexSignature */ + || kind === 221 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; default: return false; @@ -14528,11 +15252,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 165 /* ConstructSignature */ + || kind === 164 /* CallSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */ + || kind === 166 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14541,12 +15265,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 279 /* PropertyAssignment */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 281 /* SpreadAssignment */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14561,8 +15285,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return true; } return false; @@ -14573,8 +15297,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 189 /* ArrayBindingPattern */ + || kind === 188 /* ObjectBindingPattern */; } return false; } @@ -14582,15 +15306,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 191 /* ArrayLiteralExpression */ + || kind === 192 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 190 /* BindingElement */ + || kind === 214 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14599,9 +15323,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: return true; } return false; @@ -14622,8 +15346,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return true; } return false; @@ -14635,8 +15359,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return true; } return false; @@ -14645,26 +15369,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */ + || kind === 187 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 156 /* Decorator */: return true; default: return false; @@ -14672,12 +15396,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 195 /* CallExpression */ || node.kind === 196 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 210 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14688,34 +15412,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 73 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 197 /* TaggedTemplateExpression */: + case 191 /* ArrayLiteralExpression */: + case 199 /* ParenthesizedExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 75 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 103 /* TrueKeyword */: - case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: - case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 210 /* TemplateExpression */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 105 /* TrueKeyword */: + case 101 /* SuperKeyword */: + case 217 /* NonNullExpression */: + case 218 /* MetaProperty */: + case 95 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -14728,13 +15452,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 198 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14743,11 +15467,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 44 /* PlusPlusToken */ || - expr.operator === 45 /* MinusMinusToken */; + case 206 /* PrefixUnaryExpression */: + return expr.operator === 45 /* PlusPlusToken */ || + expr.operator === 46 /* MinusMinusToken */; default: return false; } @@ -14764,15 +15488,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 316 /* CommaListExpression */: - case 315 /* PartiallyEmittedExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: + case 201 /* ArrowFunction */: + case 208 /* BinaryExpression */: + case 212 /* SpreadElement */: + case 216 /* AsExpression */: + case 214 /* OmittedExpression */: + case 320 /* CommaListExpression */: + case 319 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14780,21 +15504,26 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 198 /* TypeAssertionExpression */ + || kind === 216 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 315 /* PartiallyEmittedExpression */; + return node.kind === 319 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 314 /* NotEmittedStatement */; + return node.kind === 318 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ + function isSyntheticReference(node) { + return node.kind === 323 /* SyntheticReferenceExpression */; + } + ts.isSyntheticReference = isSyntheticReference; + /* @internal */ function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -14802,21 +15531,42 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; /* @internal */ + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + /* @internal */ + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + /* @internal */ + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + /* @internal */ + function isExternalModuleIndicator(result) { + // Exported top-level member indicates moduleness + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; + /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 230 /* ForInStatement */ || node.kind === 231 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14840,113 +15590,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ - || kind === 73 /* Identifier */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */ + || kind === 75 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + return kind === 75 /* Identifier */ + || kind === 248 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 256 /* NamedImports */ + || kind === 255 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 248 /* ModuleDeclaration */ || node.kind === 247 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 311 /* JSDocTypedefTag */ - || kind === 304 /* JSDocCallbackTag */ - || kind === 312 /* JSDocPropertyTag */; + return kind === 201 /* ArrowFunction */ + || kind === 190 /* BindingElement */ + || kind === 244 /* ClassDeclaration */ + || kind === 213 /* ClassExpression */ + || kind === 161 /* Constructor */ + || kind === 247 /* EnumDeclaration */ + || kind === 282 /* EnumMember */ + || kind === 261 /* ExportSpecifier */ + || kind === 243 /* FunctionDeclaration */ + || kind === 200 /* FunctionExpression */ + || kind === 162 /* GetAccessor */ + || kind === 254 /* ImportClause */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 257 /* ImportSpecifier */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 271 /* JsxAttribute */ + || kind === 160 /* MethodDeclaration */ + || kind === 159 /* MethodSignature */ + || kind === 248 /* ModuleDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 255 /* NamespaceImport */ + || kind === 155 /* Parameter */ + || kind === 279 /* PropertyAssignment */ + || kind === 158 /* PropertyDeclaration */ + || kind === 157 /* PropertySignature */ + || kind === 163 /* SetAccessor */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 154 /* TypeParameter */ + || kind === 241 /* VariableDeclaration */ + || kind === 315 /* JSDocTypedefTag */ + || kind === 308 /* JSDocCallbackTag */ + || kind === 316 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 243 /* FunctionDeclaration */ + || kind === 262 /* MissingDeclaration */ + || kind === 244 /* ClassDeclaration */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 247 /* EnumDeclaration */ + || kind === 248 /* ModuleDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 258 /* ExportAssignment */ + || kind === 251 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 314 /* NotEmittedStatement */ - || kind === 318 /* EndOfDeclarationMarker */ - || kind === 317 /* MergeDeclarationMarker */; + return kind === 233 /* BreakStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 227 /* DoStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 223 /* EmptyStatement */ + || kind === 230 /* ForInStatement */ + || kind === 231 /* ForOfStatement */ + || kind === 229 /* ForStatement */ + || kind === 226 /* IfStatement */ + || kind === 237 /* LabeledStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 236 /* SwitchStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 239 /* TryStatement */ + || kind === 224 /* VariableStatement */ + || kind === 228 /* WhileStatement */ + || kind === 235 /* WithStatement */ + || kind === 318 /* NotEmittedStatement */ + || kind === 322 /* EndOfDeclarationMarker */ + || kind === 321 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 310 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 154 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 314 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14973,10 +15723,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 222 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 239 /* TryStatement */ || node.parent.kind === 278 /* CatchClause */) { return false; } } @@ -14986,83 +15736,88 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 263 /* ExternalModuleReference */ + || kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 /* ThisKeyword */ - || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + return kind === 103 /* ThisKeyword */ + || kind === 75 /* Identifier */ + || kind === 193 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 264 /* JsxElement */ + || kind === 274 /* JsxExpression */ + || kind === 265 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 268 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 271 /* JsxAttribute */ + || kind === 273 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 274 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 266 /* JsxOpeningElement */ + || kind === 265 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 275 /* CaseClause */ + || kind === 276 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 312 /* LastJSDocNode */; + return node.kind >= 292 /* FirstJSDocNode */ && node.kind <= 316 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 297 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 /* 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 >= 300 /* FirstJSDocTagNode */ && node.kind <= 312 /* LastJSDocTagNode */; + return node.kind >= 304 /* FirstJSDocTagNode */ && node.kind <= 316 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; + /* @internal */ + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; + } + ts.isOptionalChainRoot = isOptionalChainRoot; /** True if has jsdoc nodes attached to it. */ /* @internal */ // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times @@ -15090,12 +15845,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 271 /* JsxAttribute */ || node.kind === 273 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 168 /* TypeReference */ || node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15131,7 +15886,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 256 /* NamedImports */ || node.kind === 260 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15149,7 +15904,7 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature() { } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15166,6 +15921,7 @@ var ts; this.text = text; this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } + // eslint-disable-next-line prefer-const ts.objectAllocator = { getNodeConstructor: function () { return Node; }, getTokenConstructor: function () { return Node; }, @@ -15612,7 +16368,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } /** * Parse a path into an array containing a root component (at index 0) and zero or more path @@ -15690,6 +16446,37 @@ var ts; return ""; return pathComponents.slice(1).join(ts.directorySeparator); } + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); + } + return result; + } + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); + } + return [getPathFromPathComponents(aParts), getPathFromPathComponents(bParts)]; + } + // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. + // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); + } })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -15712,7 +16499,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -15793,7 +16580,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -16232,14 +17019,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; ts.supportedJSAndJsonExtensions = [".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json" /* Json */]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json" /* Json */]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -16253,7 +17040,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json" /* Json */]); + return __spreadArrays(supportedExtensions, [".json" /* Json */]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -16565,14 +17352,17 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { + function skipTypeChecking(sourceFile, options, host) { // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a // '/// ' directive. - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16676,17 +17466,15 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 288 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73 /* Identifier */) { + else if (kind === 75 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -16735,19 +17523,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 <= 148 /* LastToken */) { + if (!node || node.kind <= 151 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16755,9 +17543,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -16765,7 +17553,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16773,51 +17561,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 157 /* 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 276 /* PropertyAssignment */: + case 279 /* 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 238 /* VariableDeclaration */: + case 241 /* 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 187 /* BindingElement */: + case 190 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -16829,345 +17617,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || + case 167 /* TypePredicate */: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 174 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 180 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 187 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 181 /* ParenthesizedType */: + case 183 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 185 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 156 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* 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 242 /* InterfaceDeclaration */: + case 245 /* 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 243 /* TypeAliasDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 292 /* JSDocTypeExpression */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 297 /* JSDocOptionalType */: + case 299 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297 /* JSDocComment */: + case 301 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302 /* JSDocAuthorTag */: + case 306 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 292 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocSignature */: + case 303 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 300 /* JSDocTag */: - case 303 /* JSDocClassTag */: + case 304 /* JSDocTag */: + case 307 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17176,12 +17969,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100 /* JSON */) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -17219,7 +18014,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -17248,14 +18043,12 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; + var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17265,6 +18058,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; // Flags that dictate what parsing context we're in. For example: // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is // that some tokens that would be considered identifiers may be considered keywords. @@ -17385,18 +18179,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(225 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 39 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -17405,7 +18199,7 @@ var ts; break; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -17421,6 +18215,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17446,10 +18243,10 @@ var ts; switch (scriptKind) { case 1 /* JS */: case 2 /* JSX */: - contextFlags = 65536 /* JavaScriptFile */; + contextFlags = 131072 /* JavaScriptFile */; break; case 6 /* JSON */: - contextFlags = 65536 /* JavaScriptFile */ | 16777216 /* JsonFile */; + contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */; break; default: contextFlags = 0 /* None */; @@ -17472,11 +18269,12 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304 /* Ambient */; + contextFlags |= 8388608 /* Ambient */; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -17541,7 +18339,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(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(288 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17562,16 +18360,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048 /* DisallowInContext */); + setContextFlag(val, 4096 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 4096 /* YieldContext */); + setContextFlag(val, 8192 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 8192 /* DecoratorContext */); + setContextFlag(val, 16384 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 16384 /* AwaitContext */); + setContextFlag(val, 32768 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -17612,40 +18410,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(2048 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(4096 /* YieldContext */, func); + return doInsideOfContext(8192 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384 /* AwaitContext */, func); + return doInsideOfContext(32768 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); + return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096 /* YieldContext */); + return inContext(8192 /* YieldContext */); } function inDisallowInContext() { - return inContext(2048 /* DisallowInContext */); + return inContext(4096 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(8192 /* DecoratorContext */); + return inContext(16384 /* DecoratorContext */); } function inAwaitContext() { - return inContext(16384 /* AwaitContext */); + return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -17681,9 +18479,17 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + // if the keyword had an escape + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + // issue a parse error for the escape + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -17752,20 +18558,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 73 /* Identifier */) { + if (token() === 75 /* 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() === 118 /* YieldKeyword */ && inYieldContext()) { + if (token() === 120 /* 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() === 123 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 126 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 109 /* LastReservedWord */; + return token() > 111 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -17853,7 +18659,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 73 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 75 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -17883,7 +18689,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768 /* ThisNodeHasError */; + node.flags |= 65536 /* ThisNodeHasError */; } return node; } @@ -17895,7 +18701,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73 /* Identifier */) { + if (kind === 75 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -17916,18 +18722,18 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73 /* Identifier */); + var node = createNode(75 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 73 /* Identifier */) { + if (token() !== 75 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(73 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -17958,7 +18764,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(153 /* 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 @@ -17979,20 +18785,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 85 /* EnumKeyword */; - case 86 /* ExportKeyword */: + return nextToken() === 87 /* EnumKeyword */; + case 88 /* ExportKeyword */: nextToken(); - if (token() === 81 /* DefaultKeyword */) { + if (token() === 83 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 /* AsteriskToken */ && token() !== 120 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); - case 81 /* DefaultKeyword */: + return token() !== 41 /* AsteriskToken */ && token() !== 122 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 83 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 117 /* StaticKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + case 119 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -18005,16 +18811,16 @@ var ts; function canFollowModifier() { return token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */ - || token() === 40 /* AsteriskToken */ + || token() === 41 /* AsteriskToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 /* ClassKeyword */ || token() === 91 /* FunctionKeyword */ || - token() === 111 /* InterfaceKeyword */ || - (token() === 119 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 /* ClassKeyword */ || token() === 93 /* FunctionKeyword */ || + token() === 113 /* InterfaceKeyword */ || + (token() === 121 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -18034,7 +18840,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -18050,7 +18856,7 @@ var ts; case 12 /* ObjectLiteralMembers */: switch (token()) { case 22 /* OpenBracketToken */: - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; @@ -18120,7 +18926,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 87 /* ExtendsKeyword */ || next === 110 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 89 /* ExtendsKeyword */ || next === 112 /* ImplementsKeyword */; } return true; } @@ -18137,8 +18943,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 /* ImplementsKeyword */ || - token() === 87 /* ExtendsKeyword */) { + if (token() === 112 /* ImplementsKeyword */ || + token() === 89 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -18168,14 +18974,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -18194,9 +19000,9 @@ var ts; case 22 /* HeritageClauses */: return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; + return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -18216,7 +19022,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() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -18291,7 +19097,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 12679168 /* ContextFlags */; + var nodeContextFlags = node.flags & 25358336 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -18392,20 +19198,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 161 /* Constructor */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 221 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 160 /* 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 === 73 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 125 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 75 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 128 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -18414,8 +19220,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: return true; } } @@ -18424,58 +19230,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 224 /* VariableStatement */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 225 /* ExpressionStatement */: + case 238 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 236 /* SwitchStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 223 /* EmptyStatement */: + case 239 /* TryStatement */: + case 237 /* LabeledStatement */: + case 227 /* DoStatement */: + case 240 /* DebuggerStatement */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 157 /* PropertySignature */: + case 164 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 241 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18496,7 +19302,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 155 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18563,7 +19369,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18601,6 +19407,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18621,7 +19430,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24 /* DotToken */)) { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -18632,7 +19441,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(152 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18663,13 +19472,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(210 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18681,7 +19490,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(220 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -18710,6 +19519,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -18731,24 +19550,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 169 /* FunctionType */: + case 170 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -18756,20 +19575,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(167 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(182 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(293 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(297 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18777,7 +19596,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(296 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18798,63 +19617,80 @@ var ts; if (token() === 27 /* CommaToken */ || token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || - token() === 30 /* GreaterThanToken */ || - token() === 60 /* EqualsToken */ || - token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + token() === 31 /* GreaterThanToken */ || + token() === 62 /* EqualsToken */ || + token() === 51 /* BarToken */) { + var result = createNode(294 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(295 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(298 /* JSDocFunctionType */); nextToken(); - fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(58 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { + var parameter = createNode(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */ || token() === 98 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(134 /* ModuleKeyword */); + if (moduleSpecifier) { + var moduleTag = createNode(300 /* JSDocNamepathType */, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + case 27 /* CommaToken */: + case 5 /* WhitespaceTrivia */: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(299 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + if (token() === 62 /* EqualsToken */) { + return createPostfixType(297 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); - parseExpected(105 /* TypeOfKeyword */); + var node = createNode(171 /* TypeQuery */); + parseExpected(107 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(87 /* ExtendsKeyword */)) { + if (parseOptional(89 /* 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 @@ -18873,18 +19709,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60 /* EqualsToken */)) { + if (parseOptional(62 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (token() === 29 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(57 /* ColonToken */)) { + if (parseOptional(58 /* ColonToken */)) { return parseType(); } return undefined; @@ -18893,12 +19729,12 @@ var ts; return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 /* AtToken */ || + token() === 59 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */) { + var node = createNodeWithJSDoc(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); @@ -18920,7 +19756,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.questionToken = parseOptionalToken(57 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -18942,16 +19778,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(57 /* ColonToken */)) { + else if (parseOptional(58 /* ColonToken */)) { return true; } - else if (isType && token() === 37 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); nextToken(); return true; } @@ -18998,10 +19834,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { - parseExpected(96 /* NewKeyword */); + if (kind === 165 /* ConstructSignature */) { + parseExpected(98 /* NewKeyword */); } - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -19045,21 +19881,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* 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() !== 56 /* QuestionToken */) { + if (token() !== 57 /* 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() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 166 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19067,17 +19903,17 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + node.kind = 159 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 157 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* 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. @@ -19089,7 +19925,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return true; } var idToken = false; @@ -19111,20 +19947,20 @@ var ts; // the start of a member declaration if (idToken) { return token() === 20 /* OpenParenToken */ || - token() === 28 /* LessThanToken */ || - token() === 56 /* QuestionToken */ || - token() === 57 /* ColonToken */ || + token() === 29 /* LessThanToken */ || + token() === 57 /* QuestionToken */ || + token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + return parseSignatureMember(164 /* CallSignature */); } - if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + if (token() === 98 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19135,7 +19971,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; } function nextTokenIsDot() { return nextToken() === 24 /* DotToken */; @@ -19143,14 +19979,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20 /* OpenParenToken */: - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(172 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19167,37 +20003,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { - return nextToken() === 134 /* ReadonlyKeyword */; + if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + return nextToken() === 137 /* ReadonlyKeyword */; } - if (token() === 134 /* ReadonlyKeyword */) { + if (token() === 137 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 96 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(94 /* InKeyword */); + parseExpected(96 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(185 /* MappedType */); parseExpected(18 /* OpenBraceToken */); - if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 137 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { - parseExpectedToken(134 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { + parseExpectedToken(137 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); parseExpected(23 /* CloseBracketToken */); - if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56 /* QuestionToken */) { - parseExpectedToken(56 /* QuestionToken */); + if (node.questionToken.kind !== 57 /* QuestionToken */) { + parseExpectedToken(57 /* QuestionToken */); } } node.type = parseTypeAnnotation(); @@ -19208,23 +20044,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(176 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 4194304 /* JSDoc */) && type.kind === 295 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 175 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(174 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(181 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19232,9 +20068,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(98 /* NewKeyword */) ? 170 /* ConstructorType */ : 169 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(38 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -19242,14 +20078,14 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(186 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 39 /* MinusToken */; + unaryMinusExpression = createNode(206 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 40 /* MinusToken */; nextToken(); } - var expression = token() === 103 /* TrueKeyword */ || token() === 88 /* FalseKeyword */ + var expression = token() === 105 /* TrueKeyword */ || token() === 90 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -19262,23 +20098,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93 /* ImportKeyword */; + return token() === 95 /* ImportKeyword */; } function parseImportType() { - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); - if (parseOptional(105 /* TypeOfKeyword */)) { + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; + var node = createNode(187 /* ImportType */); + if (parseOptional(107 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); node.argument = parseType(); parseExpected(21 /* CloseParenToken */); if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } @@ -19288,50 +20124,54 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 140 /* SymbolKeyword */: - case 124 /* BooleanKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 143 /* SymbolKeyword */: + case 127 /* BooleanKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 63 /* AsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 56 /* QuestionToken */: + case 60 /* QuestionQuestionToken */: + // If there is '??', consider that is prefix '?' in JSDoc type. + scanner.reScanQuestionToken(); + // falls through + case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseLiteralTypeNode(); - case 39 /* MinusToken */: + case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 107 /* VoidKeyword */: - case 97 /* NullKeyword */: + case 109 /* VoidKeyword */: + case 99 /* NullKeyword */: return parseTokenNode(); - case 101 /* ThisKeyword */: { + case 103 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -19339,51 +20179,54 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportType(); + case 123 /* AssertsKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 134 /* ReadonlyKeyword */: - case 140 /* SymbolKeyword */: - case 143 /* UniqueKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 105 /* TypeOfKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 137 /* ReadonlyKeyword */: + case 143 /* SymbolKeyword */: + case 146 /* UniqueKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 107 /* TypeOfKeyword */: + case 136 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: - case 28 /* LessThanToken */: - case 50 /* BarToken */: - case 49 /* AmpersandToken */: - case 96 /* NewKeyword */: + case 29 /* LessThanToken */: + case 51 /* BarToken */: + case 50 /* AmpersandToken */: + case 98 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 137 /* ObjectKeyword */: - case 40 /* AsteriskToken */: - case 56 /* QuestionToken */: - case 52 /* ExclamationToken */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 140 /* ObjectKeyword */: + case 41 /* AsteriskToken */: + case 57 /* QuestionToken */: + case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 128 /* InferKeyword */: - case 93 /* ImportKeyword */: + case 131 /* InferKeyword */: + case 95 /* ImportKeyword */: + case 123 /* AssertsKeyword */: return true; - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return !inStartOfParameter; - case 39 /* MinusToken */: + case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -19401,27 +20244,27 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + case 53 /* ExclamationToken */: + type = createPostfixType(296 /* JSDocNonNullableType */, type); break; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type - if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { + if (!(contextFlags & 4194304 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(295 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(184 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(173 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19440,16 +20283,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(183 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); - parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var node = createNode(180 /* InferType */); + parseExpected(131 /* InferKeyword */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19457,11 +20300,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130 /* KeyOfKeyword */: - case 143 /* UniqueKeyword */: - case 134 /* ReadonlyKeyword */: + case 133 /* KeyOfKeyword */: + case 146 /* UniqueKeyword */: + case 137 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 128 /* InferKeyword */: + case 131 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -19482,13 +20325,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(178 /* IntersectionType */, parseTypeOperatorOrHigher, 50 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(177 /* UnionType */, parseIntersectionTypeOrHigher, 51 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { return true; } return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -19498,7 +20341,7 @@ var ts; // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 101 /* ThisKeyword */) { + if (isIdentifier() || token() === 103 /* ThisKeyword */) { nextToken(); return true; } @@ -19520,8 +20363,8 @@ 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() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 56 /* QuestionToken */ || token() === 60 /* EqualsToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 57 /* QuestionToken */ || token() === 62 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -19530,7 +20373,7 @@ var ts; } if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -19542,7 +20385,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(167 /* TypePredicate */, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19553,45 +20397,52 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167 /* TypePredicate */); + node.assertsModifier = parseExpectedToken(123 /* AssertsKeyword */); + node.parameterName = token() === 103 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132 /* IsKeyword */) ? parseType() : undefined; + return finishNode(node); + } function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 98 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89 /* ExtendsKeyword */)) { + var node = createNode(179 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(56 /* QuestionToken */); + parseExpected(57 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -19600,14 +20451,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 96 /* NewKeyword */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 73 /* Identifier */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 98 /* NewKeyword */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 75 /* Identifier */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -19618,18 +20469,18 @@ var ts; return true; } switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 28 /* LessThanToken */: - case 123 /* AwaitKeyword */: - case 118 /* YieldKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 29 /* LessThanToken */: + case 126 /* AwaitKeyword */: + case 120 /* 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. @@ -19648,9 +20499,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && - token() !== 58 /* AtToken */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && + token() !== 59 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -19673,7 +20524,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -19718,7 +20569,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 === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -19734,7 +20585,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118 /* YieldKeyword */) { + if (token() === 120 /* 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()) { @@ -19763,15 +20614,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(211 /* 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() === 40 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19782,20 +20633,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(201 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(201 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(155 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -19820,8 +20671,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(37 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -19831,10 +20682,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() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 122 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 125 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* 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. @@ -19844,12 +20695,12 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { return 0 /* False */; } } @@ -19863,8 +20714,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 37 /* EqualsGreaterThanToken */: - case 57 /* ColonToken */: + case 38 /* EqualsGreaterThanToken */: + case 58 /* ColonToken */: case 18 /* OpenBraceToken */: return 1 /* True */; default: @@ -19888,30 +20739,30 @@ var ts; // 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 !== 122 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 /* 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 !== 101 /* ThisKeyword */) { + if (!isIdentifier() && second !== 103 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 57 /* ColonToken */: + case 58 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 60 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -19920,7 +20771,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 28 /* LessThanToken */); + ts.Debug.assert(first === 29 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -19930,11 +20781,11 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87 /* ExtendsKeyword */) { + if (third === 89 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 60 /* EqualsToken */: - case 30 /* GreaterThanToken */: + case 62 /* EqualsToken */: + case 31 /* GreaterThanToken */: return false; default: return true; @@ -19955,11 +20806,19 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -19972,23 +20831,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() === 122 /* AsyncKeyword */) { + if (token() === 125 /* 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() === 37 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(201 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -19998,7 +20857,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -20011,7 +20870,7 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -20022,8 +20881,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -20048,20 +20907,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(56 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* 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(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(209 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57 /* ColonToken */); + node.colonToken = parseExpectedToken(58 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + : createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -20069,7 +20928,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 96 /* InKeyword */ || t === 151 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20098,16 +20957,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() === 41 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 /* InKeyword */ && inDisallowInContext()) { + if (token() === 96 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -20128,51 +20987,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94 /* InKeyword */) { + if (inDisallowInContext() && token() === 96 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(208 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(216 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(202 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(203 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(204 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123 /* AwaitKeyword */) { + if (token() === 126 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -20182,7 +21041,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(205 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20206,7 +21065,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 /* AsteriskAsteriskToken */ ? + return token() === 42 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -20223,10 +21082,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41 /* AsteriskAsteriskToken */) { + if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 198 /* 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 { @@ -20251,23 +21110,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 82 /* DeleteKeyword */: + case 84 /* DeleteKeyword */: return parseDeleteExpression(); - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return parseVoidExpression(); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 123 /* AwaitKeyword */: + case 126 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -20290,16 +21149,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 123 /* AwaitKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 126 /* AwaitKeyword */: return false; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -20322,21 +21181,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20377,14 +21236,14 @@ 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() === 93 /* ImportKeyword */) { + if (token() === 95 /* ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { @@ -20392,21 +21251,22 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); - node.keywordToken = 93 /* ImportKeyword */; + var node = createNode(218 /* MetaProperty */, fullStart); + node.keywordToken = 95 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; + sourceFile.flags |= 2097152 /* PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 /* 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. + // CallExpression or OptionalExpression. As such, we need to consume the rest + // of it here to be complete. return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { @@ -20458,11 +21318,11 @@ var ts; // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -20474,7 +21334,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(193 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20483,8 +21343,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 266 /* JsxOpeningElement */) { + var node = createNode(264 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20493,15 +21353,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 269 /* JsxOpeningFragment */) { + var node = createNode(268 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 265 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20512,11 +21372,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 28 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(208 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20546,7 +21406,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29 /* LessThanSlashToken */: + case 30 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; case 11 /* JsxText */: @@ -20554,7 +21414,7 @@ var ts; return parseJsxText(); case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -20575,16 +21435,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(272 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28 /* LessThanToken */); - if (token() === 30 /* GreaterThanToken */) { + parseExpected(29 /* LessThanToken */); + if (token() === 31 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(269 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20592,23 +21452,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30 /* GreaterThanToken */) { + if (token() === 31 /* 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(263 /* JsxOpeningElement */, fullStart); + node = createNode(266 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(42 /* SlashToken */); + parseExpected(43 /* SlashToken */); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(265 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20622,10 +21482,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() === 101 /* ThisKeyword */ ? + var expression = token() === 103 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20633,7 +21493,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(274 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -20659,9 +21519,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(271 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -20674,7 +21534,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(273 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -20682,78 +21542,110 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(267 /* JsxClosingElement */); + parseExpected(30 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(270 /* JsxClosingFragment */); + parseExpected(30 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); - parseExpected(28 /* LessThanToken */); + var node = createNode(198 /* TypeAssertionExpression */); + parseExpected(29 /* LessThanToken */); node.type = parseType(); - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 /* OpenBracketToken */ + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 /* QuestionDotToken */ + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + propertyAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23 /* CloseBracketToken */); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + indexedAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24 /* DotToken */); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(217 /* 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(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - if (token() === 23 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23 /* CloseBracketToken */); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, /*typeArguments*/ undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, /*typeArguments*/ undefined); continue; } return expression; @@ -20762,48 +21654,70 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32 /* OptionalChain */) { + tagExpression.flags |= 32 /* OptionalChain */; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); + var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); // handle 'foo<()' - if (token() === 28 /* LessThanToken */ || token() === 46 /* LessThanLessThanToken */) { + if (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the // stack. var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(195 /* CallExpression */, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + // We failed to parse anything, so report a missing identifier here. + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32 /* OptionalChain */; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20 /* OpenParenToken */); @@ -20812,12 +21726,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* LessThanToken */) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(30 /* GreaterThanToken */)) { + if (!parseExpected(31 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -20834,21 +21748,23 @@ var ts; 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. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] - case 57 /* ColonToken */: // foo: + case 58 /* 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 57 /* QuestionToken */: // foo? + case 34 /* EqualsEqualsToken */: // foo == + case 36 /* EqualsEqualsEqualsToken */: // foo === + case 35 /* ExclamationEqualsToken */: // foo != + case 37 /* ExclamationEqualsEqualsToken */: // foo !== + case 55 /* AmpersandAmpersandToken */: // foo && + case 56 /* BarBarToken */: // foo || + case 60 /* QuestionQuestionToken */: // foo ?? + case 52 /* CaretToken */: // foo ^ + case 50 /* AmpersandToken */: // foo & + case 51 /* 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 @@ -20860,6 +21776,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -20872,11 +21789,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -20884,7 +21801,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 122 /* AsyncKeyword */: + case 125 /* 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. @@ -20892,14 +21809,14 @@ var ts; break; } return parseFunctionExpression(); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassExpression(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionExpression(); - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -20910,28 +21827,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(199 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(212 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(214 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(191 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -20943,25 +21860,25 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 281 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(53 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -20969,24 +21886,24 @@ 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() !== 57 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(60 /* EqualsToken */); + node.kind = 280 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(62 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276 /* PropertyAssignment */; - parseExpected(57 /* ColonToken */); + node.kind = 279 /* PropertyAssignment */; + parseExpected(58 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(192 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21005,10 +21922,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(200 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -21016,7 +21933,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -21028,26 +21945,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96 /* NewKeyword */); + parseExpected(98 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); - node_2.keywordToken = 96 /* NewKeyword */; + var node_2 = createNode(218 /* MetaProperty */, fullStart); + node_2.keywordToken = 98 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, /*optionalChain*/ undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(196 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21057,7 +21974,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(222 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21090,25 +22007,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(223 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); - parseExpected(92 /* IfKeyword */); + var node = createNode(226 /* IfStatement */); + parseExpected(94 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); - parseExpected(83 /* DoKeyword */); + var node = createNode(227 /* DoStatement */); + parseExpected(85 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(108 /* WhileKeyword */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21120,8 +22037,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); - parseExpected(108 /* WhileKeyword */); + var node = createNode(228 /* WhileStatement */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21130,12 +22047,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90 /* ForKeyword */); - var awaitToken = parseOptionalToken(123 /* AwaitKeyword */); + parseExpected(92 /* ForKeyword */); + var awaitToken = parseOptionalToken(126 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 106 /* VarKeyword */ || token() === 112 /* LetKeyword */ || token() === 78 /* ConstKeyword */) { + if (token() === 108 /* VarKeyword */ || token() === 114 /* LetKeyword */ || token() === 80 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -21143,23 +22060,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(151 /* OfKeyword */) : parseOptional(151 /* OfKeyword */)) { + var forOfStatement = createNode(231 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + else if (parseOptional(96 /* InKeyword */)) { + var forInStatement = createNode(230 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(229 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21177,7 +22094,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 233 /* BreakStatement */ ? 76 /* BreakKeyword */ : 81 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21185,8 +22102,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); - parseExpected(98 /* ReturnKeyword */); + var node = createNode(234 /* ReturnStatement */); + parseExpected(100 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -21194,39 +22111,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); - parseExpected(109 /* WithKeyword */); + var node = createNode(235 /* WithStatement */); + parseExpected(111 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); + node.statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); - parseExpected(75 /* CaseKeyword */); + var node = createNode(275 /* CaseClause */); + parseExpected(77 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); - parseExpected(81 /* DefaultKeyword */); - parseExpected(57 /* ColonToken */); + var node = createNode(276 /* DefaultClause */); + parseExpected(83 /* DefaultKeyword */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 77 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); - parseExpected(100 /* SwitchKeyword */); + var node = createNode(236 /* SwitchStatement */); + parseExpected(102 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(250 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21241,29 +22158,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); - parseExpected(102 /* ThrowKeyword */); + var node = createNode(238 /* ThrowStatement */); + parseExpected(104 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); - parseExpected(104 /* TryKeyword */); + var node = createNode(239 /* TryStatement */); + parseExpected(106 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 78 /* 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() === 89 /* FinallyKeyword */) { - parseExpected(89 /* FinallyKeyword */); + if (!node.catchClause || token() === 91 /* FinallyKeyword */) { + parseExpected(91 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); - parseExpected(76 /* CatchKeyword */); + var result = createNode(278 /* CatchClause */); + parseExpected(78 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21 /* CloseParenToken */); @@ -21276,8 +22193,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); - parseExpected(80 /* DebuggerKeyword */); + var node = createNode(240 /* DebuggerStatement */); + parseExpected(82 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -21287,13 +22204,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + if (expression.kind === 75 /* Identifier */ && parseOptional(58 /* ColonToken */)) { + node.kind = 237 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 225 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21305,11 +22222,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 79 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 93 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -21318,12 +22235,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* 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 @@ -21346,41 +22263,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146 /* GlobalKeyword */: + case 149 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 73 /* Identifier */ || token() === 86 /* ExportKeyword */; - case 93 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 75 /* Identifier */ || token() === 88 /* ExportKeyword */; + case 95 /* ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); - if (token() === 60 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || token() === 81 /* DefaultKeyword */ || - token() === 120 /* AsKeyword */) { + if (token() === 62 /* EqualsToken */ || token() === 41 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 83 /* DefaultKeyword */ || + token() === 122 /* AsKeyword */) { return true; } continue; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: nextToken(); continue; default: @@ -21393,50 +22310,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 92 /* IfKeyword */: - case 83 /* DoKeyword */: - case 108 /* WhileKeyword */: - case 90 /* ForKeyword */: - case 79 /* ContinueKeyword */: - case 74 /* BreakKeyword */: - case 98 /* ReturnKeyword */: - case 109 /* WithKeyword */: - case 100 /* SwitchKeyword */: - case 102 /* ThrowKeyword */: - case 104 /* TryKeyword */: - case 80 /* DebuggerKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 94 /* IfKeyword */: + case 85 /* DoKeyword */: + case 110 /* WhileKeyword */: + case 92 /* ForKeyword */: + case 81 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 100 /* ReturnKeyword */: + case 111 /* WithKeyword */: + case 102 /* SwitchKeyword */: + case 104 /* ThrowKeyword */: + case 106 /* TryKeyword */: + case 82 /* 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 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78 /* ConstKeyword */: - case 86 /* ExportKeyword */: + case 80 /* ConstKeyword */: + case 88 /* ExportKeyword */: return isStartOfDeclaration(); - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 111 /* InterfaceKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 141 /* TypeKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 113 /* InterfaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 144 /* TypeKeyword */: + case 149 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 119 /* StaticKeyword */: + case 137 /* 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); @@ -21459,63 +22377,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); - case 112 /* LetKeyword */: + case 108 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); + case 114 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); } break; - case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); - case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); - case 92 /* IfKeyword */: + case 93 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(243 /* FunctionDeclaration */)); + case 79 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(244 /* ClassDeclaration */)); + case 94 /* IfKeyword */: return parseIfStatement(); - case 83 /* DoKeyword */: + case 85 /* DoKeyword */: return parseDoStatement(); - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return parseWhileStatement(); - case 90 /* ForKeyword */: + case 92 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); - case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); - case 98 /* ReturnKeyword */: + case 81 /* ContinueKeyword */: + return parseBreakOrContinueStatement(232 /* ContinueStatement */); + case 76 /* BreakKeyword */: + return parseBreakOrContinueStatement(233 /* BreakStatement */); + case 100 /* ReturnKeyword */: return parseReturnStatement(); - case 109 /* WithKeyword */: + case 111 /* WithKeyword */: return parseWithStatement(); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return parseSwitchStatement(); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return parseThrowStatement(); - case 104 /* TryKeyword */: + case 106 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return parseTryStatement(); - case 80 /* DebuggerKeyword */: + case 82 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 58 /* AtToken */: + case 59 /* AtToken */: return parseDeclaration(); - case 122 /* AsyncKeyword */: - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 85 /* EnumKeyword */: - case 86 /* ExportKeyword */: - case 93 /* ImportKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 119 /* AbstractKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 87 /* EnumKeyword */: + case 88 /* ExportKeyword */: + case 95 /* ImportKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 121 /* AbstractKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: + case 149 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -21524,52 +22443,71 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126 /* DeclareKeyword */; + return modifier.kind === 129 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304 /* Ambient */; + m.flags |= 8388608 /* Ambient */; } - return doInsideOfContext(4194304 /* Ambient */, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: return parseVariableStatement(node); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassDeclaration(node); - case 111 /* InterfaceKeyword */: + case 113 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 141 /* TypeKeyword */: + case 144 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 85 /* EnumKeyword */: + case 87 /* EnumKeyword */: return parseEnumDeclaration(node); - case 146 /* GlobalKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 149 /* GlobalKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); switch (token()) { - case 81 /* DefaultKeyword */: - case 60 /* EqualsToken */: + case 83 /* DefaultKeyword */: + case 62 /* EqualsToken */: return parseExportAssignment(node); - case 120 /* AsKeyword */: + case 122 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -21578,7 +22516,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(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21601,24 +22539,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(214 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -21626,14 +22564,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(188 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(189 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -21655,10 +22593,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(241 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 /* Identifier */ && - token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 /* Identifier */ && + token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -21668,14 +22606,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(242 /* VariableDeclarationList */); switch (token()) { - case 106 /* VarKeyword */: + case 108 /* VarKeyword */: break; - case 112 /* LetKeyword */: + case 114 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -21691,7 +22629,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() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -21706,25 +22644,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 224 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + node.kind = 243 /* FunctionDeclaration */; + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* 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(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125 /* ConstructorKeyword */) { - return parseExpected(125 /* ConstructorKeyword */); + if (token() === 128 /* ConstructorKeyword */) { + return parseExpected(128 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -21736,25 +22674,25 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; - fillSignature(57 /* ColonToken */, 0 /* None */, node); + node.kind = 161 /* Constructor */; + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 160 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; - if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 158 /* PropertyDeclaration */; + if (!node.questionToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -21769,17 +22707,17 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. node.initializer = ts.hasModifier(node, 32 /* Static */) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseInitializer); + : doOutsideOfContext(8192 /* YieldContext */ | 4096 /* DisallowInContext */, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* 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(56 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -21787,13 +22725,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57 /* ColonToken */, 0 /* None */, node); + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58 /* AtToken */) { + if (token() === 59 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -21810,7 +22748,7 @@ var ts; } nextToken(); } - if (token() === 40 /* AsteriskToken */) { + if (token() === 41 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -21826,18 +22764,18 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 138 /* SetKeyword */ || idToken === 127 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 141 /* SetKeyword */ || idToken === 130 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { case 20 /* OpenParenToken */: // Method declaration - case 28 /* LessThanToken */: // Generic Method declaration - case 52 /* ExclamationToken */: // Non-null assertion on property name - case 57 /* ColonToken */: // Type Annotation for declaration - case 60 /* EqualsToken */: // Initializer for declaration - case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 29 /* LessThanToken */: // Generic Method declaration + case 53 /* ExclamationToken */: // Non-null assertion on property name + case 58 /* ColonToken */: // Type Annotation for declaration + case 62 /* EqualsToken */: // Initializer for declaration + case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -21855,10 +22793,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58 /* AtToken */)) { + if (!parseOptional(59 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(156 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -21878,7 +22816,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 80 /* 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)) { @@ -21897,7 +22835,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -21908,20 +22846,20 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(221 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 128 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -21935,27 +22873,37 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 40 /* AsteriskToken */ || + token() === 41 /* AsteriskToken */ || token() === 22 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608 /* Ambient */; + } + return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75 /* 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 */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 213 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 244 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77 /* ClassKeyword */); + parseExpected(79 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -21981,7 +22929,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -21993,33 +22941,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + ts.Debug.assert(tok === 89 /* ExtendsKeyword */ || tok === 112 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(277 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 29 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; - parseExpected(111 /* InterfaceKeyword */); + node.kind = 245 /* InterfaceDeclaration */; + parseExpected(113 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22027,11 +22974,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; - parseExpected(141 /* TypeKeyword */); + node.kind = 246 /* TypeAliasDeclaration */; + parseExpected(144 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -22041,14 +22988,14 @@ 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(279 /* EnumMember */); + var node = createNodeWithJSDoc(282 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; - parseExpected(85 /* EnumKeyword */); + node.kind = 247 /* EnumDeclaration */; + parseExpected(87 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -22060,7 +23007,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(249 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22071,7 +23018,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 248 /* 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 */; @@ -22083,11 +23030,11 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; - if (token() === 146 /* GlobalKeyword */) { + node.kind = 248 /* ModuleDeclaration */; + if (token() === 149 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 512 /* GlobalAugmentation */; + node.flags |= 1024 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(); @@ -22103,15 +23050,15 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146 /* GlobalKeyword */) { + if (token() === 149 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132 /* NamespaceKeyword */)) { + else if (parseOptional(135 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(131 /* ModuleKeyword */); + parseExpected(134 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } @@ -22119,52 +23066,52 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 /* RequireKeyword */ && + return token() === 138 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 42 /* SlashToken */; + return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; - parseExpected(120 /* AsKeyword */); - parseExpected(132 /* NamespaceKeyword */); + node.kind = 251 /* NamespaceExportDeclaration */; + parseExpected(122 /* AsKeyword */); + parseExpected(135 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 /* CommaToken */ && token() !== 145 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 148 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 253 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 40 /* AsteriskToken */ || // import * + token() === 41 /* AsteriskToken */ || // import * token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145 /* FromKeyword */); + parseExpected(148 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 252 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -22176,7 +23123,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(254 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22186,7 +23133,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(256 /* NamedImports */); } return finishNode(importClause); } @@ -22196,8 +23143,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); - parseExpected(135 /* RequireKeyword */); + var node = createNode(263 /* ExternalModuleReference */); + parseExpected(138 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -22219,9 +23166,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); - parseExpected(40 /* AsteriskToken */); - parseExpected(120 /* AsKeyword */); + var namespaceImport = createNode(255 /* NamespaceImport */); + parseExpected(41 /* AsteriskToken */); + parseExpected(122 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -22234,14 +23181,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 256 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(261 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(257 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22255,9 +23202,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(120 /* AsKeyword */); + parseExpected(122 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -22266,24 +23213,24 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 257 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; - if (parseOptional(40 /* AsteriskToken */)) { - parseExpected(145 /* FromKeyword */); + node.kind = 259 /* ExportDeclaration */; + if (parseOptional(41 /* AsteriskToken */)) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(260 /* 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() === 145 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(145 /* FromKeyword */); + if (token() === 148 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -22291,12 +23238,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; - if (parseOptional(60 /* EqualsToken */)) { + node.kind = 258 /* ExportAssignment */; + if (parseOptional(62 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(81 /* DefaultKeyword */); + parseExpected(83 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -22311,15 +23258,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */ + || node.kind === 253 /* ImportDeclaration */ + || node.kind === 258 /* ExportAssignment */ + || node.kind === 259 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -22327,7 +23272,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -22378,9 +23323,9 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(292 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); + result.type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -22390,8 +23335,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = parseJSDocCommentWorker(start, length); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22402,11 +23347,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536 /* JavaScriptFile */) { + if (contextFlags & 131072 /* JavaScriptFile */) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -22471,7 +23416,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -22490,7 +23435,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 40 /* AsteriskToken */: + case 41 /* 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 @@ -22541,7 +23486,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297 /* JSDocComment */, start); + var result = createNode(301 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22577,14 +23522,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { indentText += scanner.getTokenText(); if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40 /* AsteriskToken */) { + else if (token() === 41 /* AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -22592,7 +23537,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -22676,7 +23621,7 @@ var ts; } indent = 0; break; - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 3 /* SavingBackticks */) { comments.push(scanner.getTokenText()); break; @@ -22701,7 +23646,7 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -22709,7 +23654,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59 /* BacktickToken */: + case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { state = 2 /* SavingComments */; } @@ -22718,7 +23663,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -22741,7 +23686,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300 /* JSDocTag */, start); + var result = createNode(304 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22769,15 +23714,15 @@ var ts; skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(59 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(60 /* EqualsToken */)) { + if (parseOptionalToken(62 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -22786,9 +23731,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -22804,8 +23749,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(312 /* JSDocPropertyTag */, start) : - createNode(306 /* JSDocParameterTag */, start); + createNode(316 /* JSDocPropertyTag */, start) : + createNode(310 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22822,20 +23767,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) { + if (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -22847,7 +23792,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307 /* JSDocReturnTag */, start); + var result = createNode(311 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -22856,13 +23801,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309 /* JSDocTypeTag */, start); + var result = createNode(313 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302 /* JSDocAuthorTag */, start); + var result = createNode(306 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -22884,20 +23829,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 5 /* WhitespaceTrivia */: case 24 /* DotToken */: - case 58 /* AtToken */: + case 59 /* AtToken */: comments.push(scanner.getTokenText()); break; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (!seenLessThan || seenGreaterThan) { return; } @@ -22916,14 +23861,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301 /* JSDocAugmentsTag */, start); + var result = createNode(305 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -22935,7 +23880,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(193 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -22943,19 +23888,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303 /* JSDocClassTag */, start); + var tag = createNode(307 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308 /* JSDocThisTag */, start); + var tag = createNode(312 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305 /* JSDocEnumTag */, start); + var tag = createNode(309 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22964,7 +23909,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311 /* JSDocTypedefTag */, start); + var typedefTag = createNode(315 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22978,9 +23923,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start); } - if (child.kind === 309 /* JSDocTypeTag */) { + if (child.kind === 313 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -22993,7 +23938,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23012,7 +23957,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(248 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23026,22 +23971,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304 /* JSDocCallbackTag */, start); + var callbackTag = createNode(308 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299 /* JSDocSignature */, start); + var jsdocSignature = createNode(303 /* 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(58 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 307 /* JSDocReturnTag */) { + if (tag && tag.kind === 311 /* JSDocReturnTag */) { return tag; } } @@ -23083,10 +24028,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) && + if (child && (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23099,13 +24044,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -23114,7 +24059,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -23150,13 +24095,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(154 /* 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(27 /* CommaToken */)); - var result = createNode(310 /* JSDocTemplateTag */, start); + var result = createNode(314 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23189,18 +24134,21 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73 /* Identifier */, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + var result = createNode(75 /* Identifier */, pos); + if (token() !== 75 /* Identifier */) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -23321,7 +24269,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return true; } return false; @@ -23887,10 +24835,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73 /* Identifier */) { + if (lhs.kind === 75 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101 /* ThisKeyword */) { + if (lhs.kind === 103 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -24040,12 +24988,21 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -24055,7 +25012,7 @@ var ts; }, ]; /* @internal */ - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -24157,7 +25114,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -24194,6 +25152,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -24202,6 +25161,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -24209,6 +25169,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -24227,6 +25188,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -24254,6 +25216,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -24263,6 +25226,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -24279,6 +25243,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -24298,7 +25263,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, // Strict Type Checks { @@ -24432,7 +25398,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { // this option can only be specified in tsconfig.json @@ -24447,7 +25414,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -24471,7 +25439,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -24568,6 +25537,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -24617,14 +25587,20 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + transpileOptionValue: true }, { name: "stripInternal", @@ -24640,6 +25616,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -24660,6 +25642,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -24675,7 +25658,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -24733,6 +25717,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -24762,7 +25753,11 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + /* @internal */ + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -24826,7 +25821,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; /* @internal */ @@ -25326,7 +26322,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 !== 276 /* PropertyAssignment */) { + if (element.kind !== 279 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25382,15 +26378,15 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97 /* NullKeyword */: + case 99 /* 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 + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25408,13 +26404,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 206 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25431,7 +26427,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25482,13 +26478,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), 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 config = __assign(__assign({ compilerOptions: __assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? 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 }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -25713,8 +26709,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -25880,7 +26875,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -26569,8 +27564,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -26829,7 +27825,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27013,6 +28009,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -27023,6 +28020,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -27232,7 +28232,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); @@ -27268,7 +28268,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; @@ -27289,7 +28289,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -27769,35 +28769,67 @@ var ts; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1 /* Instantiated */; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0 /* NonInstantiated */; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; - // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case 259 /* ExportDeclaration */: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0 /* NonInstantiated */; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1 /* Instantiated */) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. + case 249 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0 /* NonInstantiated */: // child is non-instantiated - continue searching @@ -27816,9 +28848,9 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: - return getModuleInstanceState(node); - case 73 /* Identifier */: + case 248 /* ModuleDeclaration */: + return getModuleInstanceState(node, visited); + case 75 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -27827,6 +28859,36 @@ var ts; } return 1 /* Instantiated */; } + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1 /* Instantiated */) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + } var ContainerFlags; (function (ContainerFlags) { // The current node is not a container, and no container manipulation should happen before @@ -27855,7 +28917,9 @@ var ts; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -27889,7 +28953,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -27957,7 +29021,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -27968,7 +29032,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { setValueDeclaration(symbol, node); } } @@ -27984,7 +29048,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 === 255 /* ExportAssignment */) { + if (node.kind === 258 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -27993,7 +29057,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28005,39 +29069,42 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: + case 169 /* FunctionType */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 155 /* 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 === 295 /* 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 === 298 /* 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; @@ -28137,7 +29204,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 === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 258 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28155,7 +29222,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0 /* None */, name); } } @@ -28172,7 +29239,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 261 /* ExportSpecifier */ || (node.kind === 252 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28196,11 +29263,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { + if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 67220415 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -28239,7 +29306,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 !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28267,12 +29334,12 @@ var ts; if (!isIIFE) { currentFlow = { flags: 2 /* Start */ }; if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { - currentFlow.container = node; + currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -28280,19 +29347,20 @@ var ts; flowNodeCreated = ts.identity; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~1408 /* ReachabilityAndEmitFlags */; + node.flags &= ~2816 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 128 /* HasImplicitReturn */; + node.flags |= 256 /* HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 256 /* HasExplicitReturn */; + node.flags |= 512 /* HasExplicitReturn */; + node.endFlowNode = currentFlow; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28309,7 +29377,7 @@ var ts; else if (containerFlags & 64 /* IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 /* ContainsThis */ : node.flags & ~64 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; } else { bindChildren(node); @@ -28336,8 +29404,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28369,79 +29437,93 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 /* FirstStatement */ && node.kind <= 240 /* LastStatement */ && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 225 /* ExpressionStatement */: + bindExpressionStatement(node); + break; + case 237 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + bindAccessExpressionFlow(node); + break; + case 195 /* CallExpression */: bindCallExpressionFlow(node); break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; + case 307 /* JSDocClassTag */: + bindJSDocClassTag(node); + break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 288 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28452,29 +29534,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: - return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 203 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || + return expr.kind === 75 /* Identifier */ || expr.kind === 103 /* ThisKeyword */ || expr.kind === 101 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && + ts.isElementAccessExpression(expr) && + ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { @@ -28486,7 +29568,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 193 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28500,17 +29582,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableReference(expr.left); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -28519,11 +29601,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -28532,20 +29614,14 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4 /* BranchLabel */, - antecedents: undefined - }; + return { flags: 4 /* BranchLabel */, antecedents: undefined }; } function createLoopLabel() { - return { - flags: 8 /* LoopLabel */, - antecedents: undefined - }; + return { flags: 8 /* LoopLabel */, antecedents: undefined }; } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; + flow.flags |= flow.flags & 1024 /* Referenced */ ? 2048 /* Shared */ : 1024 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -28560,31 +29636,36 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 103 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 88 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { - return unreachableFlow; + if (expression.kind === 105 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 90 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (!ts.isOptionalChainRoot(expression.parent)) { + return unreachableFlow; + } } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16 /* Assignment */, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -28599,47 +29680,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 229 /* ForStatement */: + case 209 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 206 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 55 /* BarBarToken */); + return node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* BarBarToken */ || + node.operatorToken.kind === 60 /* QuestionQuestionToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && - node.parent.operator === 52 /* ExclamationToken */) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); } @@ -28667,7 +29753,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 237 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -28699,15 +29785,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 231 /* ForOfStatement */) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 242 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -28729,7 +29815,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 234 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -28749,7 +29835,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -28841,7 +29927,7 @@ var ts; // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. - var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = { flags: 4096 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -28859,7 +29945,7 @@ var ts; } } if (!(currentFlow.flags & 1 /* Unreachable */)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096 /* AfterFinally */, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192 /* AfterFinally */, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -28877,9 +29963,10 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276 /* 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). + // case clauses have unreachable end points (e.g. they all return). Note, we no longer need + // this property in control flow analysis, it's there only for backwards compatibility. node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -28933,6 +30020,17 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + // A top level call expression with a dotted function name and at least one argument + // is potentially an assertion and is therefore included in the control flow. + if (node.expression.kind === 195 /* CallExpression */) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -28944,14 +30042,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 227 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -28962,10 +30060,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 191 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 212 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -28973,16 +30071,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 279 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 280 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 281 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -28990,7 +30088,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -29001,7 +30099,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52 /* ExclamationToken */) { + if (node.operator === 53 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -29011,20 +30109,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -29038,7 +30136,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 62 /* EqualsToken */ && node.left.kind === 194 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29049,7 +30147,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 193 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29088,27 +30186,102 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 309 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - // If the target of the call expression is a function expression or arrow function we have - // 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 === 196 /* ParenthesizedExpression */) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193 /* PropertyAccessExpression */: + bind(node.name); + break; + case 194 /* ElementAccessExpression */: + bind(node.argumentExpression); + break; + case 195 /* CallExpression */: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + // For an optional chain, we emulate the behavior of a logical expression: + // + // a?.b -> a && a.b + // a?.b.c -> a && a.b.c + // a?.b?.c -> a && a.b && a.b.c + // a?.[x = 1] -> a && a[x = 1] + // + // To do this we descend through the chain until we reach the root of a chain (the expression with a `?.`) + // and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest + // of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost + // chain node. We then treat the entire node as the right side of the expression. + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + // If the target of the call expression is a function expression or arrow function we have + // an immediately invoked function expression (IIFE). Initialize the flowNode property to + // the current control flow (which includes evaluation of the IIFE arguments). + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 /* FunctionExpression */ || expr.kind === 201 /* ArrowFunction */) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29117,54 +30290,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 272 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 298 /* JSDocFunctionType */: + case 169 /* FunctionType */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 170 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 278 /* CatchClause */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 250 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 222 /* 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 @@ -29197,45 +30370,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 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 192 /* ObjectLiteralExpression */: + case 245 /* InterfaceDeclaration */: + case 272 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 299 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 303 /* JSDocSignature */: + case 166 /* IndexSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 298 /* JSDocFunctionType */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 246 /* TypeAliasDeclaration */: + case 185 /* 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 @@ -29262,11 +30435,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 4194304 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 32 /* ExportContext */; + if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* ExportContext */; } else { - node.flags &= ~32 /* ExportContext */; + node.flags &= ~64 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -29336,7 +30509,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 === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 281 /* SpreadAssignment */ || prop.name.kind !== 75 /* Identifier */) { continue; } var identifier = prop.name; @@ -29348,7 +30521,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 === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 279 /* PropertyAssignment */ || prop.kind === 280 /* ShorthandPropertyAssignment */ || prop.kind === 160 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29380,10 +30553,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29414,9 +30587,37 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + container = file; + break; + case 4 /* ThisProperty */: + container = declName.parent.expression; + break; + case 3 /* PrototypeProperty */: + container = declName.parent.expression.name; + break; + case 5 /* Property */: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0 /* None */: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75 /* Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -29432,10 +30633,11 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 112 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 120 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */)) { + !(node.flags & 8388608 /* Ambient */) && + !(node.flags & 4194304 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29469,7 +30671,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 73 /* Identifier */) { + if (inStrictMode && node.expression.kind === 75 /* 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); @@ -29480,7 +30682,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73 /* Identifier */) { + if (name && name.kind === 75 /* 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 @@ -29521,8 +30723,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 288 /* SourceFile */ && + blockScopeContainer.kind !== 248 /* 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. @@ -29548,7 +30750,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -29583,7 +30785,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -29617,7 +30819,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 > 148 /* LastToken */) { + if (node.kind > 151 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -29657,8 +30859,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -29679,7 +30881,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 73 /* Identifier */: + case 75 /* 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. @@ -29688,31 +30890,32 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); break; } // falls through - case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + case 103 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -29740,76 +30943,76 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 182 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 282 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* 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 240 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); + case 243 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 162 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); + case 163 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: + case 170 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 185 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -29828,64 +31031,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); + case 246 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + case 247 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 288 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 222 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 306 /* JSDocParameterTag */: - if (node.parent.kind === 299 /* JSDocSignature */) { + case 310 /* JSDocParameterTag */: + if (node.parent.kind === 303 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 298 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 302 /* JSDocTypeLiteral */) { break; } // falls through - case 312 /* JSDocPropertyTag */: + case 316 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -29993,8 +31197,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); } @@ -30004,7 +31207,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 /* Property */ | 1048576 /* ExportValue */ | 32 /* Class */ : 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, lhs, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); } } function bindModuleExportsAssignment(node) { @@ -30029,13 +31232,13 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 === 60 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } @@ -30043,38 +31246,59 @@ var ts; // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } break; default: ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4 /* Property */, "__computed" /* Computed */); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101 /* ThisKeyword */) { + if (node.expression.kind === 103 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30087,8 +31311,7 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.left.expression, node.left, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -30107,32 +31330,38 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 288 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { // This can be an alias for the 'exports' or 'module.exports' names, e.g. // var util = module.exports; // util.property = function ... bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -30141,10 +31370,10 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; @@ -30160,6 +31389,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30170,17 +31402,47 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var includes = 0 /* None */; + var excludes = 0 /* None */; + // Method-like + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192 /* Method */; + excludes = 103359 /* MethodExcludes */; + } + // Maybe accessor-like + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this + // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) + includes |= 65536 /* SetAccessor */ | 4 /* Property */; + excludes |= 78783 /* SetAccessorExcludes */; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 /* GetAccessor */ | 4 /* Property */; + excludes |= 46015 /* GetAccessorExcludes */; + } + } + if (includes === 0 /* None */) { + includes = 4 /* Property */; + excludes = 0 /* PropertyExcludes */; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 /* SourceFile */ + : propertyAccess.parent.parent.kind === 288 /* SourceFile */; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30209,7 +31471,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 === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -30226,7 +31488,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -30238,7 +31500,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -30249,8 +31511,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); + if (node.kind === 244 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; @@ -30283,19 +31545,16 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 /* RegularEnum */ : 0 /* None */); - var enumExcludes = (isEnum ? 68008191 /* RegularEnumExcludes */ : 0 /* None */); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */ | enumFlags, 67220415 /* BlockScopedVariableExcludes */ | enumExcludes); + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -30307,18 +31566,18 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */ | enumFlags, 67220414 /* FunctionScopedVariableExcludes */ | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 306 /* JSDocParameterTag */ && container.kind !== 299 /* JSDocSignature */) { + if (node.kind === 310 /* JSDocParameterTag */ && container.kind !== 303 /* JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { + if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); @@ -30327,34 +31586,34 @@ var ts; bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -30365,8 +31624,8 @@ var ts; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -30386,26 +31645,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 180 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } // reachability checks @@ -30420,11 +31679,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 223 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 248 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30438,7 +31697,7 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 8388608 /* Ambient */) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -30468,12 +31727,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30485,7 +31744,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -30522,58 +31781,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 155 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 161 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -30584,6 +31843,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } if (node.typeArguments) { transformFlags |= 1 /* AssertTypeScript */; } @@ -30595,7 +31857,7 @@ var ts; transformFlags |= 2048 /* ContainsLexicalThis */; } } - if (expression.kind === 93 /* ImportKeyword */) { + if (expression.kind === 95 /* ImportKeyword */) { transformFlags |= 524288 /* ContainsDynamicImport */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -30618,17 +31880,20 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* QuestionQuestionToken */) { + transformFlags |= 4 /* AssertESNext */; + } + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 192 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 191 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ - || operatorTokenKind === 64 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 42 /* AsteriskAsteriskToken */ + || operatorTokenKind === 66 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 64 /* AssertES2016 */; } @@ -30671,8 +31936,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 === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 216 /* AsExpression */ + || expressionKind === 198 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -30712,11 +31977,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87 /* ExtendsKeyword */: + case 89 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; - case 110 /* ImplementsKeyword */: + case 112 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; @@ -30907,9 +32172,12 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -30919,9 +32187,12 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If an ElementAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31009,43 +32280,43 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { - case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 125 /* AsyncKeyword */: + case 205 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; break; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 217 /* NonNullExpression */: + case 137 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 267 /* JsxClosingElement */: + case 268 /* JsxFragment */: + case 269 /* JsxOpeningFragment */: + case 270 /* JsxClosingFragment */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 274 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31053,11 +32324,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: - case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 280 /* ShorthandPropertyAssignment */: + case 119 /* StaticKeyword */: + case 218 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31074,103 +32345,103 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; break; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 167 /* TypePredicate */: + case 168 /* TypeReference */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 171 /* TypeQuery */: + case 172 /* TypeLiteral */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 180 /* InferType */: + case 181 /* ParenthesizedType */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: + case 251 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 153 /* 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. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; excludeFlags = 536870912 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31183,26 +32454,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31220,67 +32491,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 191 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 155 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 161 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 139 /* StringKeyword */: - case 137 /* ObjectKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 142 /* StringKeyword */: + case 140 /* ObjectKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 278 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: - case 99 /* SuperKeyword */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: + case 199 /* ParenthesizedExpression */: + case 101 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31299,7 +32570,7 @@ var ts; /** @internal */ var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -31372,7 +32643,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -31455,7 +32726,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 === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 171 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -31506,6 +32777,180 @@ var ts; WideningKind[WideningKind["Normal"] = 0] = "Normal"; WideningKind[WideningKind["GeneratorYield"] = 1] = "GeneratorYield"; })(WideningKind || (WideningKind = {})); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + 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"] = 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 */, + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ + }); + var typeofNEFacts = ts.createMapFromTemplate({ + 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 TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; + TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; + TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; + CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; + CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; + })(CheckMode || (CheckMode = {})); + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + ContextFlags[ContextFlags["NoConstraints"] = 2] = "NoConstraints"; + })(ContextFlags || (ContextFlags = {})); + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; + })(AccessFlags || (AccessFlags = {})); + var CallbackCheck; + (function (CallbackCheck) { + CallbackCheck[CallbackCheck["None"] = 0] = "None"; + CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; + CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; + })(CallbackCheck || (CallbackCheck = {})); + var MappedTypeModifiers; + (function (MappedTypeModifiers) { + MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; + })(MappedTypeModifiers || (MappedTypeModifiers = {})); + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var MembersOrExportsResolutionKind; + (function (MembersOrExportsResolutionKind) { + MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; + MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; + })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); + var UnusedKind; + (function (UnusedKind) { + UnusedKind[UnusedKind["Local"] = 0] = "Local"; + UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; + })(UnusedKind || (UnusedKind = {})); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); + var DeclarationMeaning; + (function (DeclarationMeaning) { + DeclarationMeaning[DeclarationMeaning["GetAccessor"] = 1] = "GetAccessor"; + DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; + DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; + })(DeclarationMeaning || (DeclarationMeaning = {})); + var DeclarationSpaces; + (function (DeclarationSpaces) { + DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; + DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; + DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; + DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; + })(DeclarationSpaces || (DeclarationSpaces = {})); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -31553,11 +32998,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -31591,6 +33034,9 @@ var ts; var requireSymbol = createSymbol(4 /* Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; + // This object is reused for `checkOptionalExpression` return values to avoid frequent GC due to nursery object allocations. + // This object represents a pool-size of 1. + var pooledOptionalTypeResult = { isOptional: false, type: undefined }; // for public members that accept a Node or one of its subtypes, we must guard against // synthetic nodes created during transformations by calling `getParseTreeNode`. // for most of these, we perform the guard only on `checker` to avoid any possible @@ -31639,8 +33085,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -31757,7 +33206,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -31773,6 +33222,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -31791,6 +33243,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -31819,7 +33272,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -31831,7 +33284,7 @@ var ts; // Ensure file is type checked checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { addUnusedDiagnostics(); } @@ -31843,7 +33296,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -31883,6 +33336,7 @@ var ts; var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 262144 /* ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); var nullType = createIntrinsicType(65536 /* Null */, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 262144 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); @@ -31912,6 +33366,7 @@ var ts; var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 1048576 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -31935,7 +33390,7 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); + var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 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); @@ -32032,6 +33487,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -32044,113 +33502,18 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - // Suggestion diagnostics must have a file. Keyed by source file name. - var suggestionDiagnostics = ts.createMultiMap(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - 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"] = 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 */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ - }); - var typeofNEFacts = ts.createMapFromTemplate({ - 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 suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -32168,71 +33531,8 @@ var ts; var comparableRelation = ts.createMap(); var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; - TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; - TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); - var CheckMode; - (function (CheckMode) { - CheckMode[CheckMode["Normal"] = 0] = "Normal"; - CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; - CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; - CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; - CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; - CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; - })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - })(AccessFlags || (AccessFlags = {})); - var CallbackCheck; - (function (CallbackCheck) { - CallbackCheck[CallbackCheck["None"] = 0] = "None"; - CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; - CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; - })(CallbackCheck || (CallbackCheck = {})); - var MappedTypeModifiers; - (function (MappedTypeModifiers) { - MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; - })(MappedTypeModifiers || (MappedTypeModifiers = {})); - var ExpandingFlags; - (function (ExpandingFlags) { - ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; - ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; - ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; - ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; - })(ExpandingFlags || (ExpandingFlags = {})); - var MembersOrExportsResolutionKind; - (function (MembersOrExportsResolutionKind) { - MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; - MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; - })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); - var UnusedKind; - (function (UnusedKind) { - UnusedKind[UnusedKind["Local"] = 0] = "Local"; - UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; - })(UnusedKind || (UnusedKind = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -32244,7 +33544,7 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; @@ -32297,11 +33597,11 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32323,35 +33623,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= 67220415 /* BlockScopedVariableExcludes */; + result |= 111551 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= 67220414 /* FunctionScopedVariableExcludes */; + result |= 111550 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) result |= 0 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= 68008959 /* EnumMemberExcludes */; + result |= 900095 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= 67219887 /* FunctionExcludes */; + result |= 110991 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 68008383 /* ClassExcludes */; + result |= 899503 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 67897736 /* InterfaceExcludes */; + result |= 788872 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 68008191 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 68008831 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 110735 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) - result |= 67212223 /* MethodExcludes */; + result |= 103359 /* MethodExcludes */; if (flags & 32768 /* GetAccessor */) - result |= 67154879 /* GetAccessorExcludes */; + result |= 46015 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) - result |= 67187647 /* SetAccessorExcludes */; + result |= 78783 /* SetAccessorExcludes */; if (flags & 262144 /* TypeParameter */) - result |= 67635688 /* TypeParameterExcludes */; + result |= 526824 /* TypeParameterExcludes */; if (flags & 524288 /* TypeAlias */) - result |= 67897832 /* TypeAliasExcludes */; + result |= 788968 /* TypeAliasExcludes */; if (flags & 2097152 /* Alias */) result |= 2097152 /* AliasExcludes */; return result; @@ -32386,7 +33686,11 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* Assignment */) { - ts.Debug.assert(source !== target); + if (source === target) { + // This can happen when an export assigned namespace exports something also erroneously exported at the top level + // See `declarationFileNoCrashOnExtraExportModifier` for an example + return target; + } if (!(target.flags & 33554432 /* Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -32515,7 +33819,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -32525,7 +33829,7 @@ var ts; // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); if (mainModule_1.flags & 1920 /* Namespace */) { - // If we’re merging an augmentation to a pattern ambient module, we want to + // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you // all the exports both from the pattern and from the augmentation, but @@ -32574,7 +33878,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32604,8 +33908,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -32618,7 +33922,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304 /* Ambient */) { + declaration.flags & 8388608 /* Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -32632,17 +33936,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 190 /* 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, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 190 /* 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, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 241 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -32665,22 +33969,22 @@ 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 === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 /* ExportSpecifier */ || (usage.parent.kind === 258 /* 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 === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 258 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 224 /* VariableStatement */: + case 229 /* ForStatement */: + case 231 /* 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)) { @@ -32701,16 +34005,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 158 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 160 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -32731,14 +34035,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 201 /* ArrowFunction */: + case 158 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 222 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return true; default: return false; @@ -32784,12 +34088,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 !== 297 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 301 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 155 /* Parameter */ || + lastLocation.kind === 154 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -32806,13 +34110,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 === 152 /* Parameter */ || + lastLocation.kind === 155 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 179 /* 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; @@ -32827,14 +34131,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + case 248 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -32858,7 +34162,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 261 /* ExportSpecifier */)) { break; } } @@ -32872,12 +34176,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -32887,20 +34191,20 @@ var ts; if (!ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -32915,7 +34219,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 213 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -32923,11 +34227,11 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 89 /* ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -32943,34 +34247,34 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -32983,7 +34287,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -32992,7 +34296,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 === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 155 /* Parameter */) { location = location.parent; } // @@ -33007,24 +34311,25 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244 /* ClassDeclaration */)) { location = location.parent; } break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 155 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 155 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33044,7 +34349,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 288 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33110,21 +34415,21 @@ var ts; // we want to check for block-scoped if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 67220415 /* Value */) === 67220415 /* Value */))) { + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415 /* Value */) === 67220415 /* Value */) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -33140,10 +34445,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 201 /* ArrowFunction */ && location.kind !== 200 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -33156,12 +34461,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33173,7 +34478,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 === 151 /* TypeParameter */) { + if (decl.kind === 154 /* 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 @@ -33228,10 +34533,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33241,9 +34546,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -33262,8 +34567,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 /* Type */ & 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1920 /* Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -33272,12 +34577,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later @@ -33301,15 +34606,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */ & ~67897832 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 /* Type */ & ~1024 /* NamespaceModule */ & ~67220415 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~67897832 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -33319,11 +34624,15 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); + if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + // constructor functions aren't block scoped + return; + } // 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 === 244 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { @@ -33355,13 +34664,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33371,7 +34680,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33436,7 +34745,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -33448,7 +34762,7 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -33472,7 +34786,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -33502,9 +34816,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -33539,7 +34854,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default" /* Default */)) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -33559,34 +34879,56 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; } - var aliasLike = resolveEntityName(expression, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 261 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); + case 258 /* ExportAssignment */: + case 208 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280 /* ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 279 /* PropertyAssignment */: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193 /* PropertyAccessExpression */: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -33596,7 +34938,7 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); @@ -33630,7 +34972,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -33646,17 +34988,15 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 258 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); + // We defer checking of the reference of an `import =` until the import itself is referenced, + // This way a chain of imports can be elided if ultimately the final input is only used in a type + // position. + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // import foo = + checkExpressionCached(node.moduleReference); + } } } } @@ -33668,18 +35008,18 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 73 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 75 /* Identifier */ || entityName.parent.kind === 152 /* 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 === 249 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 252 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -33692,9 +35032,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); @@ -33702,9 +35042,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 152 /* QualifiedName */ || name.kind === 193 /* PropertyAccessExpression */) { + var left = name.kind === 152 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 152 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -33756,7 +35096,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -33795,6 +35135,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -33806,9 +35160,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -33839,7 +35190,7 @@ var ts; if (patternAmbientModules) { var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference); if (pattern) { - // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // If the module reference matched a pattern ambient module ('*.foo') but there's also a // module augmentation by the specific name requested ('a.foo'), we store the merged symbol // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports // from a.foo. @@ -33910,7 +35261,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -33919,9 +35270,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* ValueModule */; if (merged.exports === undefined) { - merged.flags = merged.flags | 512 /* ValueModule */; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -33929,15 +35284,16 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 288 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34011,7 +35367,7 @@ var ts; return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -34148,7 +35504,8 @@ var ts; */ function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + // Type parameters end up in the `members` lists but are not externally visible + if (container && !(symbol.flags & 262144 /* TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { @@ -34157,7 +35514,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -34165,7 +35533,7 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { @@ -34173,33 +35541,42 @@ var ts; // fast path, `symbol` is either already the alias or isn't aliased return symbol; } + // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return + // the container itself as the alias for the symbol + var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + /** + * Checks if two symbols, through aliasing and/or merging, refer to the same thing + */ + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 67220415 /* Value */); + return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34277,31 +35654,61 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + case 248 /* ModuleDeclaration */: + var sym = getSymbolOfNode(location); + // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten + // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred + // to one another anyway) + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + // Type parameters are bound into `members` lists so they can merge across declarations + // This is troublesome, since in all other respects, they behave like locals :cries: + // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol + // lookup logic in terms of `resolveName` would be nice + // 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! + var table_1; + // TODO: Should this filtered table be cached in some way? + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 67220415 /* Value */ ? 67220415 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -34332,12 +35739,12 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { // If symbol is directly available by its name in the symbol table @@ -34354,7 +35761,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, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34390,7 +35797,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, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34405,10 +35812,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: continue; default: return false; @@ -34419,11 +35826,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -34466,7 +35873,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -34525,14 +35932,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -34575,21 +35982,21 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 171 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 153 /* ComputedPropertyName */) { // Typeof value - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 152 /* QualifiedName */ || entityName.kind === 193 /* PropertyAccessExpression */ || + entityName.parent.kind === 252 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 67897832 /* Type */; + meaning = 788968 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -34631,15 +36038,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructorType */ : 169 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 165 /* ConstructSignature */ : 164 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -34662,14 +36069,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -34700,6 +36110,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -34710,7 +36123,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -34738,37 +36152,37 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(144 /* UnknownKeyword */); + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139 /* StringKeyword */); + return ts.createKeywordTypeNode(142 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136 /* NumberKeyword */); + return ts.createKeywordTypeNode(139 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147 /* BigIntKeyword */); + return ts.createKeywordTypeNode(150 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124 /* BooleanKeyword */); + return ts.createKeywordTypeNode(127 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); return enumLiteralName; } if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* Type */); } if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); @@ -34777,7 +36191,7 @@ var ts; if (type.flags & 256 /* NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048 /* BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -34791,38 +36205,38 @@ var ts; if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143 /* UniqueKeyword */, ts.createKeywordTypeNode(140 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(146 /* UniqueKeyword */, ts.createKeywordTypeNode(143 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107 /* VoidKeyword */); + return ts.createKeywordTypeNode(109 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(145 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97 /* NullKeyword */); + return ts.createKeywordTypeNode(99 /* NullKeyword */); } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133 /* NeverKeyword */); + return ts.createKeywordTypeNode(136 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140 /* SymbolKeyword */); + return ts.createKeywordTypeNode(143 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* ObjectKeyword */); + return ts.createKeywordTypeNode(140 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -34836,10 +36250,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { @@ -34847,6 +36267,7 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; @@ -34854,15 +36275,9 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832 /* Type */) + ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); - } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -34870,7 +36285,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 177 /* UnionType */ : 178 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -34934,51 +36349,31 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 /* Type */ : 67220415 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; 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 === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415 /* Value */); + return symbolToTypeNode(symbol, context, 111551 /* Value */); } 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) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 67897832 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* Type */); } else { return createElidedInformationPlaceholder(context); } } 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.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -34991,15 +36386,45 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 288 /* SourceFile */ || declaration.parent.kind === 249 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions 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 + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; + var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + // 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.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -35012,12 +36437,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170 /* ConstructorType */, context); return signatureNode; } } @@ -35030,7 +36455,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2 /* WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -35038,7 +36463,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { @@ -35052,12 +36477,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -35065,6 +36490,8 @@ var ts; else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && + // Use `import` types for refs to other scopes, only anonymize something defined in the same scope + ts.findAncestor(type.symbol.valueDeclaration, function (d) { return d === ts.getSourceFileOfNode(context.enclosingDeclaration); }) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return createAnonymousTypeNode(type); } @@ -35087,7 +36514,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 67897832 /* Type */, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -35100,7 +36527,7 @@ var ts; } var flags = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832 /* Type */, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -35152,11 +36579,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35203,7 +36630,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); @@ -35214,25 +36641,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } - var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); + var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -35243,20 +36674,30 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { // Copy comments to node for declaration emit - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + ts.setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -35297,7 +36738,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 139 /* StringKeyword */ : 136 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 142 /* StringKeyword */ : 139 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -35310,7 +36751,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -35321,7 +36762,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 === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35329,23 +36770,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 /* Identifier */ ? + var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? + ts.createToken(123 /* AssertsKeyword */) : + undefined; + var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 121 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 124 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(124 /* 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); @@ -35365,9 +36809,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35377,15 +36821,14 @@ var ts; 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) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 152 /* 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) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(57 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -35395,29 +36838,32 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 190 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; // get symbol of the first identifier of the entityName - var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var firstIdentifier = getFirstIdentifier(accessExpression); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; @@ -35450,6 +36896,13 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent + // No need to lookup an alias for the symbol in itself + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -35530,7 +36983,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 288 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35566,7 +37019,7 @@ var ts; // using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -35575,7 +37028,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 67220415 /* Value */; + var isTypeOf = meaning === 111551 /* Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -35622,16 +37075,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216 /* InInitialEntityName */; } - var parent = chain[index - 1]; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { @@ -35654,7 +37123,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); } function typeParameterToName(type, context) { if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { @@ -35663,7 +37132,10 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ true); + var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 75 /* Identifier */)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -35709,9 +37181,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -35720,6 +37189,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -35747,12 +37219,1072 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + // See getNameForSymbolFromNameType for a stringy equivalent + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384 /* StringOrNumberLiteral */) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192 /* UniqueESSymbol */) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + // Make type parameters created within this context not consume the name outside this context + // The symbol serializer ends up creating many sibling scopes that all need "separate" contexts when + // it comes to naming things - within a normal `typeToTypeNode` call, the node builder only ever descends + // through the type tree, so the only cases where we could have used distinct sibling scopes was when there + // were multiple generic overloads with similar generated type parameter names + // The effect: + // When we write out + // export const x: (x: T) => T + // export const y: (x: T) => T + // we write it out like that, rather than as + // export const x: (x: T) => T + // export const y: (x: T_1) => T_1 + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159 /* MethodSignature */, /*useAcessors*/ false); + // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of + // declaration mapping + // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration + // emit codepaths which want to apply more specific contexts (so we can still refer to the root real declaration + // we're trying to emit from later on) + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.mapMap(symbolTable, function (_symbol, name) { return [ts.unescapeLeadingUnderscores(name), true]; }), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false); + if (accessibleResult.accessibility === 0 /* Accessible */) { + // Lookup the root symbol of the chain of refs we'll use to access it and serialize it + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4 /* Property */)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export=" /* ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + symbolTable = ts.createSymbolTable(); + // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) + symbolTable.set("export=" /* ExportEquals */, exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75 /* Identifier */; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from + // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1 /* Export */); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(/*alias*/ undefined, id); })), + /*moduleSpecifier*/ undefined)])); + } + // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + // Pass 2: Combine all `export {}` declarations + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), + /*moduleSpecifier*/ undefined)]); + } + // Pass 2b: Also combine all `export {} from "..."` declarations as needed + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + // remove group members from statements and then merge group members and add back to statements + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + // Pass 3: Move all `export {}`'s to `export` modifiers where possible + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + // all clauses removed, filter the export declaration + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + // some items filtered, others not - update the export declaration + // (mutating because why not, we're building a whole new tree here anyway) + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + // Not a cleanup, but as a final step: If there is a mix of `export` and non-`export` declarations, but no `export =` or `export {}` add a `export {};` so + // declaration privacy is respected. + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1 /* Export */) & ~2 /* Ambient */; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + // deferredPrivates will be filled up by visiting the symbol table + // And will continue to iterate as elements are added while visited `deferredPrivates` + // (As that's how a map iterator is defined to work) + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + // cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but + // still skip reserializing it if we encounter the merged product later on + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; // Already printed + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + // Only actually serialize symbols within the correct enclosing declaration, otherwise do nothing with the out-of-context symbol + var skipMembershipCheck = !isPrivate; // We only call this on exported symbols when we know they're in the correct scope + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias + // or a merge of some number of those. + // An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping + // each symbol in only one of the representations + // Also, synthesizing a default export of some kind + // If it's an alias: emit `export default ref` + // If it's a property: emit `export default _default` with a `_default` prop + // If it's a class/interface/function: emit a class/interface/function with a `default` modifier + // These forms can merge, eg (`export default 12; export default interface A {}`) + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default" /* Default */; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( + context.encounteredError = true; + // TODO: Issue error via symbol tracker? + return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); + if (symbol.flags & 16 /* Function */) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288 /* TypeAlias */) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + // Need to skip over export= symbols below - json source files get a single `Property` flagged + // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. + if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) + && symbol.escapedName !== "export=" /* ExportEquals */ + && !(symbol.flags & 4194304 /* Prototype */) + && !(symbol.flags & 32 /* Class */)) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384 /* Enum */) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 4 /* Property */) { + // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, + // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property + // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if (symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */)) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64 /* Interface */) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152 /* Alias */) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608 /* ExportStar */) { + // synthesize export * from "moduleReference" + // Straightforward - only one thing to do - make an export declaration + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*exportClause*/ undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + } + } + function includePrivateSymbol(symbol) { + ts.Debug.assertDefined(deferredPrivates); + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` + // Note: This _mutates_ `node` without using `updateNode` - the assumption being that all nodes should be manufactured fresh by the node builder + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0 /* None */; + if (additionalModifierFlags & 1 /* Export */ && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private + newModifierFlags |= 1 /* Export */; + } + if (addingDeclare && !(newModifierFlags & 1 /* Export */) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope + newModifierFlags |= 2 /* Ambient */; + } + if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* Default */; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; // Reset computed flags cache + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608 /* InTypeAlias */; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 164 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 165 /* ConstructSignature */); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather + // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, + // so we don't even have placeholders to fill in. + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, /*suppressNewPrivateContext*/ false); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + ts.forEach(mergedMembers, includePrivateSymbol); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + return ts.createExportSpecifier(name === localName ? undefined : localName, name); + })))]); + addResult(ts.createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ + // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` + var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined + : isConstVariable(symbol) ? 2 /* Const */ + : 1 /* Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a seperate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0 /* None */); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0 /* Call */); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + // Each overload becomes a separate function declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, 243 /* FunctionDeclaration */, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + // Module symbol emit will take care of module-y members, provided it has exports + if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + // handle remote props first - we need to make an `import` declaration that points at the module containing each remote + // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) + // Example: + // import Foo_1 = require("./exporter"); + // export namespace ns { + // import Foo = Foo_1.Foo; + // export { Foo }; + // export const c: number; + // } + // This is needed because in JS, statements like `const x = require("./f")` support both type and value lookup, even if they're + // normally just value lookup (so it functions kinda like an alias even when it's not an alias) + // _Usually_, we'll simply print the top-level as an alias instead of a `var` in such situations, however is is theoretically + // possible to encounter a situation where a type has members from both the current file and other files - in those situations, + // emit akin to the above would be needed. + // Add a namespace + var fakespace = ts.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16 /* Namespace */); + fakespace.flags ^= 8 /* Synthesized */; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + // TODO: implement handling for the localVsRemoteMap.get("remote") - should be difficult to trigger (see comment above), as only interesting cross-file js merges should make this possible + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, /*propertyAsAlias*/ true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8 /* Synthesized */; // reset synthesized + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); // namespaces can never be default exported + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); + // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics + var staticMembers = symbol.flags & (16 /* Function */ | 512 /* ValueModule */) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var constructors = serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 161 /* Constructor */); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + // A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration + // `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + // synthesize an alias, eg `export { symbolName as Name }` + // need to mark the alias `symbol` points + // at as something we need to serialize as a private declaration as well + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" /* ExportEquals */ && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match + verbatimTargetName = "default" /* Default */; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first + switch (node.kind) { + case 252 /* ImportEqualsDeclaration */: + // Could be a local `import localName = ns.member` or + // an external `import localName = require("whatever")` + var isLocalImport = !(target.flags & 512 /* ValueModule */); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0 /* None */); + break; + case 251 /* NamespaceExportDeclaration */: + // export as namespace foo + // TODO: Not part of a file's local or export symbol tables + // Is bound into file.symbol.globalExports instead, which we don't currently traverse + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + break; + case 254 /* ImportClause */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(ts.createIdentifier(localName), /*namedBindings*/ undefined), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0 /* None */); + break; + case 255 /* NamespaceImport */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + break; + case 257 /* ImportSpecifier */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0 /* None */); + break; + case 261 /* ExportSpecifier */: + // does not use localName because the symbol name in this case refers to the name in the exports table, + // which we must exactly preserve + var specifier = node.parent.parent.moduleSpecifier; + // targetName is only used when the target is local, as otherwise the target is an alias that points at + // another file + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258 /* ExportAssignment */: + serializeMaybeAliasAssignment(symbol); + break; + case 208 /* BinaryExpression */: + // Could be best encoded as though an export specifier or as though an export assignment + // If name is default or export=, do an export assignment + // Otherwise do an export specifier + if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + case 193 /* PropertyAccessExpression */: + // A PAE alias is _always_ going to exist as an append to a top-level export, where our top level + // handling should always be sufficient to encode the export action itself + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304 /* Prototype */) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export=" /* ExportEquals */; + var isDefault = name === "default" /* Default */; + var isExportAssignment = isExportEquals || isDefault; + // synthesize export = ref + // ref should refer to either be a locally scoped symbol which we need to emit, or + // a reference to another namespace/module which we may need to emit an `import` statement for + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + // serialize what the alias points to, preserve the declaration's initializer + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + if (target) { + // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it + // eg, `namespace A { export class B {} }; exports = A.B;` + // Technically, this is all that's required in the case where the assignment is an entity name expression + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + // We disable the context's symbol traker for the duration of this name serialization + // as, by virtue of being here, the name is required to print something, and we don't want to + // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue + // a visibility error here (as they're not visible within any scope), but we want to hoist them + // into the containing scope anyway, so we want to skip the visibility checks. + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + } + else { + if (first_1 === expr) { + // serialize as `export {target as name}` + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + // serialize as `import _Ref = t.arg.et; export { _Ref as name }` + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + // serialize as an anonymous property declaration + var varName = getUnusedName(name, symbol); + // We have to use `getWidenedType` here since the object within a json file is unwidened within the file + // (Unwidened types can only exist in expression contexts and should never be serialized) + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); + } + else { + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2 /* Const */)); + addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + // Only object types which are not constructable, or indexable, whose members all come from the + // context source file, and whose property names are all valid identifiers and not late-bound, _and_ + // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + !getIndexInfoOfType(typeToSerialize, 0 /* String */) && + !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols + // need to be merged namespace members + return []; + } + if (p.flags & 4194304 /* Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 /* Static */ : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 /* Accessor */ && useAccessors) { + var result = []; + if (p.flags & 65536 /* SetAccessor */) { + result.push(ts.setTextRange(ts.createSetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "arg", + /*questionToken*/ undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], + /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768 /* GetAccessor */) { + result.push(ts.setTextRange(ts.createGetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + // This is an else/if as accessors and properties can't merge in TS, but might in JS + // If this happens, we assume the accessor takes priority, as it imposes more constraints + else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { + return ts.setTextRange(createProperty( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | staticFlag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), + // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 + // interface members can't have initializers, however class members _can_ + /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0 /* Call */); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + // Each overload becomes a separate method declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; // TODO: Clone + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216 /* Optional */) { + decl.questionToken = ts.createToken(57 /* QuestionToken */); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 /* UniqueESSymbol */ && + type.symbol === symbol) { + context.flags |= 1048576 /* AllowUniqueESSymbolType */; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124 /* AnyKeyword */); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99 /* NullKeyword */)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, "x", + /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144 /* TypeParameter */) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1 /* Construct */) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // No base type, every constructor is empty - elide the extraneous `constructor()` + } + if (baseType) { + // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations + var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; // Every signature was identical - elide constructor list as it is inherited + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + // Each overload becomes a separate constructor declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0 /* String */, 1 /* Number */]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2 /* Const */)); + addResult(statement, 0 /* None */); + return ts.createExpressionWithTypeArguments(/*typeArgs*/ undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + // We don't use `isValueSymbolAccessible` below. since that considers alternative containers (like modules) + // which we can't write out in a syntactically valid way as an expression + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (input === "default" /* Default */) { + input = "_default"; + } + else if (input === "export=" /* ExportEquals */) { + input = "_exports"; + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + var flags = context.flags; + context.flags |= 16777216 /* InInitialEntityName */; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = ts.isIdentifierText(nameCandidate, languageVersion) && !ts.isStringANonContextualKeyword(nameCandidate) ? nameCandidate : getUnusedName("_default", symbol); + } + // The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createToken(123 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); @@ -35797,8 +38329,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 !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181 /* ParenthesizedType */; }); + if (node.kind === 246 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -35806,11 +38338,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 249 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 288 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35848,9 +38380,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -35863,17 +38395,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 241 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -35890,27 +38425,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 241 /* 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 247 /* EnumDeclaration */: + case 252 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -35918,53 +38454,54 @@ 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 !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 252 /* ImportEqualsDeclaration */ && parent.kind !== 288 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* 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 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 161 /* Constructor */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 155 /* Parameter */: + case 249 /* ModuleBlock */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 168 /* TypeReference */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 181 /* 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 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 288 /* SourceFile */: + case 251 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return false; default: return false; @@ -35973,14 +38510,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 258 /* ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 261 /* ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -35998,8 +38538,10 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); - if (importSymbol) { + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -36062,8 +38604,10 @@ var ts; } return ts.Debug.assertNever(propertyName); } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. + /** + * Pop an entry from the type resolution stack and return its associated result value. The result value will + * be true if no circularities were detected, or false if a circularity was found. + */ function popTypeResolution() { resolutionTargets.pop(); resolutionPropertyNames.pop(); @@ -36072,12 +38616,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 241 /* VariableDeclaration */: + case 242 /* VariableDeclarationList */: + case 257 /* ImportSpecifier */: + case 256 /* NamedImports */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: return false; default: return true; @@ -36110,7 +38654,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36162,7 +38706,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(194 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36177,23 +38721,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 190 /* BindingElement */ && parent.kind === 188 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 279 /* PropertyAssignment */ || node.kind === 280 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36211,11 +38755,11 @@ var ts; 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)) { + if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 188 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36283,30 +38827,30 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 /* NullKeyword */ || expr.kind === 73 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 /* NullKeyword */ || expr.kind === 75 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 191 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 155 /* Parameter */ && + (node.parent.kind === 200 /* FunctionExpression */ || node.parent.kind === 201 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration 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 === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230 /* 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 === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231 /* 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, @@ -36325,8 +38869,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { + declaration.kind === 241 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -36339,11 +38883,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 155 /* 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 === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 163 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36410,12 +38954,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4 /* ThisProperty */) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -36433,6 +38979,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { @@ -36458,9 +39007,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -36553,9 +39102,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 === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 /* Constructor */ || + thisContainer.kind === 243 /* FunctionDeclaration */ || + (thisContainer.kind === 200 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -36630,7 +39179,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -36653,7 +39202,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -36692,7 +39241,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 155 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -36754,16 +39303,20 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 258 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -36804,6 +39357,9 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } @@ -36818,7 +39374,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -36845,59 +39401,65 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 163 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return errorType; - } - var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { // If there are no specified types, try to infer it from the body of the get accessor if it exists. if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } // Otherwise, fall back to 'any'. else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* 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)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -36905,19 +39467,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -36929,8 +39482,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 208 /* BinaryExpression */ || + (declaration.kind === 193 /* PropertyAccessExpression */ || declaration.kind === 194 /* ElementAccessExpression */) && + declaration.parent.kind === 208 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -36969,7 +39523,7 @@ var ts; // type symbol, call getDeclaredTypeOfSymbol. // This check is important because without it, a call to getTypeOfSymbol could end // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 67220415 /* Value */ + links.type = targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -36997,7 +39551,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -37078,39 +39632,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 185 /* MappedType */: + case 179 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 185 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 179 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */ || node.kind === 245 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37118,7 +39683,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, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37127,9 +39692,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || + node.kind === 213 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37148,19 +39714,19 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37253,24 +39819,18 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37308,14 +39868,21 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } - // A valid base type is `any`, any non-generic object type or intersection of non-generic - // object types. + // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { + if (type.flags & 262144 /* TypeParameter */) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } + // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? + // There's no reason a `T` should be allowed while a `Readonly` should not. return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } @@ -37323,7 +39890,7 @@ var ts; 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 === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37359,8 +39926,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { - if (declaration.flags & 64 /* ContainsThis */) { + if (declaration.kind === 245 /* InterfaceDeclaration */) { + if (declaration.flags & 128 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -37368,7 +39935,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832 /* Type */, /*ignoreErrors*/ true); + var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -37381,9 +39948,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37399,7 +39972,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -37415,9 +39988,10 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243 /* TypeAliasDeclaration */; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("Type alias symbol with no valid declaration found"); + } var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -37433,17 +40007,17 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 208 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37451,18 +40025,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304 /* Ambient */); + return !(member.flags & 8388608 /* Ambient */); } switch (expr.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 39 /* MinusToken */ && + case 206 /* PrefixUnaryExpression */: + return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37476,10 +40051,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -37503,7 +40078,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -37575,23 +40150,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: + case 186 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -37617,7 +40192,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -37633,14 +40208,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -37695,9 +40270,12 @@ var ts; * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 /* _ */ && @@ -37750,7 +40328,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -37791,7 +40369,8 @@ var ts; // In the event we attempt to resolve the late-bound name of this member recursively, // fall back to the early-bound name of this member. links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -37807,9 +40386,9 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); } lateSymbol.nameType = type; @@ -37850,6 +40429,21 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + || assignmentKind === 4 /* ThisProperty */ + || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; @@ -37860,7 +40454,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 /* LateBindingContainer */ + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) : symbol.members || emptySymbols; } @@ -37890,7 +40484,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4 /* Reference */) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -37953,9 +40547,9 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { var sig = new Signature(checker); @@ -37986,13 +40580,18 @@ var ts; result.mapper = undefined; return result; } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.isOptionalCall = true; + return result; + } function getExpandedParameters(sig) { if (sig.hasRestParameter) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -38012,7 +40611,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38056,8 +40655,9 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true); + // Allow matching non-generic signatures to have excess parameters and different return types. + // Prefer matching this types if possible. + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -38081,7 +40681,7 @@ var ts; for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true)) { + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -38090,7 +40690,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -38108,7 +40708,7 @@ var ts; // signatures from the type, whose ordering would be non-obvious) var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -38120,8 +40720,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -38134,8 +40734,8 @@ var ts; } // A signature `this` type might be a read or a write position... It's very possible that it should be invariant // and we should refuse to merge signatures if there are `this` types and they do not match. However, so as to be - // permissive when calling, for now, we'll union the `this` types just like the overlapping-union-signature check does - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2 /* Subtype */); + // permissive when calling, for now, we'll intersect the `this` types just like we do for param types in union signatures. + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -38246,7 +40846,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -38269,19 +40869,19 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } @@ -38289,7 +40889,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38345,14 +40945,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38495,8 +41099,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && - constraintDeclaration.operator === 130 /* KeyOfKeyword */; + return constraintDeclaration.kind === 183 /* TypeOperator */ && + constraintDeclaration.operator === 133 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -38509,7 +41113,7 @@ var ts; else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T', - // the modifiers type is T. Otherwise, the modifiers type is {}. + // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; @@ -38520,8 +41124,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - 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); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -38737,11 +41341,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; 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). @@ -38751,6 +41355,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908 /* DisjointDomains */) { @@ -38763,8 +41370,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -38850,8 +41457,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -39199,10 +41806,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 === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 297 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39236,13 +41843,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; - } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; } - function createThisTypePredicate(type) { - return { kind: 0 /* This */, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } /** * Gets the minimum number of type arguments needed to satisfy all non-optional type @@ -39308,7 +41912,7 @@ var ts; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415 /* Value */, undefined, undefined, /*isUse*/ false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this" /* This */) { @@ -39318,7 +41922,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { + if (type && type.kind === 186 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -39332,16 +41936,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 === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 162 /* GetAccessor */ || declaration.kind === 163 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 161 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -39399,13 +42003,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return node.name.kind === 153 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39448,9 +42052,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -39479,13 +42080,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73 /* Identifier */) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 /* ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -39495,8 +42093,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signature.isOptionalCall) { + type = propagateOptionalTypeMarker(type, /*wasOptional*/ true); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -39521,7 +42121,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 161 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39531,12 +42131,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39626,7 +42226,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 161 /* Constructor */ || kind === 165 /* ConstructSignature */ || kind === 170 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -39640,7 +42240,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 136 /* NumberKeyword */ : 139 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 139 /* NumberKeyword */ : 142 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -39667,21 +42267,20 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 180 /* 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 === 165 /* TypeReference */) { + if (grandParent.kind === 168 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -39706,7 +42305,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 === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -39730,7 +42329,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -39763,8 +42362,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -39779,7 +42378,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -39788,16 +42387,38 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4 /* Reference */, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + return type; + } + function getTypeArguments(type) { + if (!type.resolvedTypeArguments) { + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -39807,13 +42428,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -39821,10 +42442,13 @@ var ts; return errorType; } } + if (node.kind === 168 /* TypeReference */ && isAliasedType(node)) { + return createDeferredTypeReference(type, node, /*mapper*/ undefined); + } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -39845,27 +42469,27 @@ var ts; * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -39876,34 +42500,22 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); } - // JS enums are 'string' or 'number', not an enum type. - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5 /* EnumTagType */)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -39912,55 +42524,31 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 67897832 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value imported from commonjs. + * These should really be aliases, but this special-case code fakes alias resolution + * by producing a type from a value. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); - } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && // Make sure this is a commonjs export by checking that symbol -> type -> symbol doesn't roundtrip. + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } } function getSubstitutionType(typeVariable, substitute) { @@ -39979,7 +42567,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 174 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -39988,9 +42576,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 301 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 179 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40001,7 +42589,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 168 /* TypeReference */ || node.kind === 187 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40038,10 +42626,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40053,7 +42641,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40066,10 +42654,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832 /* Type */; + var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -40102,9 +42699,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return declaration; } } @@ -40124,10 +42721,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { // Don't track references for global symbols anyway, so value if `isReference` is arbitrary @@ -40196,7 +42793,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -40223,15 +42820,55 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 /* ArrayType */ || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176 /* RestType */) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 /* OptionalType */ && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); + } + // Return true when the given node is transitively contained in type constructs that eagerly + // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments + // of type aliases are eagerly resolved. + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181 /* ParenthesizedType */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 184 /* IndexedAccessType */: + case 179 /* ConditionalType */: + case 183 /* TypeOperator */: + return isAliasedType(parent); + case 246 /* TypeAliasDeclaration */: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 /* TupleType */ && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, /*mapper*/ undefined); + } + else { + var elementTypes = node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 137 /* ReadonlyKeyword */; } // We represent tuple types as type references to synthesized generic interface types created by // this function. The types are of the form: @@ -40268,7 +42905,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -40302,27 +42939,13 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* 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; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { // don't slice off rest element index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -40371,8 +42994,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -40401,8 +43024,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -40487,10 +43110,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { continue; } if (first) { @@ -40509,14 +43132,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } // This function assumes the constituent type list is sorted and deduplicated. function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { @@ -40583,8 +43202,8 @@ var ts; // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -40622,6 +43241,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } // If the given list of types contains more than one union of primitive types, replace the // first with a union containing an intersection of those primitive types, then remove the // other unions and return true. Otherwise, do nothing and return false. @@ -40740,6 +43368,12 @@ var ts; // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768 /* Undefined */)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536 /* Null */)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } else { // 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. @@ -40844,20 +43478,22 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130 /* KeyOfKeyword */: + case 133 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 140 /* SymbolKeyword */ + case 146 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 143 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -40893,7 +43529,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -40904,13 +43540,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 103 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -41041,13 +43677,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 184 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 153 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41172,7 +43805,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 !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41384,7 +44017,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 67220415 /* Value */ | 67897832 /* Type */ : 67897832 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41407,14 +44040,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 /* Value */ + var errorMessage = targetMeaning === 111551 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -41423,16 +44056,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + if (meaning === 111551 /* Value */) { + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41456,7 +44089,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -41645,12 +44282,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -41663,89 +44314,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 124 /* AnyKeyword */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return anyType; - case 144 /* UnknownKeyword */: + case 147 /* UnknownKeyword */: return unknownType; - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return stringType; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return numberType; - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return bigintType; - case 124 /* BooleanKeyword */: + case 127 /* BooleanKeyword */: return booleanType; - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return esSymbolType; - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return voidType; - case 142 /* UndefinedKeyword */: + case 145 /* UndefinedKeyword */: return undefinedType; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullType; - case 133 /* NeverKeyword */: + case 136 /* NeverKeyword */: return neverType; - case 137 /* ObjectKeyword */: - return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 140 /* ObjectKeyword */: + return node.flags & 131072 /* JavaScriptFile */ ? anyType : nonPrimitiveType; + case 182 /* ThisType */: + case 103 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: - return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 167 /* TypePredicate */: + return node.assertsModifier ? voidType : booleanType; + case 215 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + return getTypeFromArrayOrTupleTypeNode(node); + case 175 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 181 /* ParenthesizedType */: + case 296 /* JSDocNonNullableType */: + case 292 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 180 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 187 /* 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 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -41834,20 +44485,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1 /* Identifier */, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0 /* This */, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -41901,17 +44539,17 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -41927,7 +44565,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -41940,13 +44578,14 @@ var ts; // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -41954,8 +44593,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 152 /* QualifiedName */ || + node.parent.kind === 168 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -41964,7 +44604,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 /* Block */ || n.kind === 179 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -41973,12 +44613,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 182 /* ThisType */: return !!tp.isThisType; - case 73 /* Identifier */: + case 75 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42032,7 +44672,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -42128,15 +44768,18 @@ var ts; // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32 /* Mapped */) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4 /* Reference */) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -42200,35 +44843,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: - return node.operatorToken.kind === 55 /* BarBarToken */ && + case 208 /* BinaryExpression */: + return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 271 /* 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 271 /* JsxExpression */: { + case 274 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42248,7 +44891,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* 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); @@ -42260,7 +44903,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42363,23 +45006,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 274 /* JsxExpression */: + case 199 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -42551,7 +45194,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -42560,9 +45203,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -42636,7 +45279,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -42704,11 +45347,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 163 /* SetAccessor */: return [3 /*break*/, 2]; + case 162 /* GetAccessor */: return [3 /*break*/, 2]; + case 160 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 280 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 279 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -42743,7 +45386,7 @@ var ts; } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { return compareSignaturesRelated(source, target, 0 /* None */, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -42756,7 +45399,7 @@ var ts; /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -42780,8 +45423,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 /* MethodDeclaration */ && + kind !== 159 /* MethodSignature */ && kind !== 161 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -42814,11 +45457,11 @@ var ts; // with respect to T. var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (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) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -42829,15 +45472,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -42858,6 +45503,9 @@ var ts; // wouldn't be co-variant for T without this rule. result &= callbackCheck === 1 /* Bivariant */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -42870,7 +45518,7 @@ var ts; } return 0 /* False */; } - if (source.kind === 1 /* Identifier */) { + if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -42879,7 +45527,9 @@ var ts; return 0 /* False */; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -42925,12 +45575,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { - return relation === 1 /* Succeeded */; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { + return !!(entry & 1 /* Succeeded */); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -42941,7 +45591,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); } else { enumRelation.set(id, 2 /* Failed */); @@ -43020,7 +45670,7 @@ var ts; if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { - return related === 1 /* Succeeded */; + return !!(related & 1 /* Succeeded */); } } if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { @@ -43052,9 +45702,14 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -43084,7 +45739,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -43097,8 +45752,131 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0 /* False */; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; // Suppress the next relation error + lastSkippedInfo = undefined; // Reset skipped info cache + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + return; + } + // The first error will be the innermost, while the last will be the outermost - so by popping off the end, + // we can build from left to right + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + // Parenthesize a `new` if there is one + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + // If leading, just print back the arg (irrespective of if it's a valid identifier) + if (path.length === 0) { + path = "" + str; + } + // Otherwise write a dotted name if possible + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + // Failing that, check if the name is already a computed name + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + // And finally write out a computed name as a last resort + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + // Don't flatten signature compatability errors at the start of a chain - instead prefer + // to unify (the with no arguments bit is excessive for printback) and print them back + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + // Remove the innermost secondary error as it will duplicate the error already reported by `reportRelationError` on entry + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; // Teporarily override elision to ensure error is reported + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -43111,6 +45889,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 /* TypeParameter */ && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -43129,8 +45909,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43223,7 +46003,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -43233,11 +46013,11 @@ var ts; return 0 /* False */; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = 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, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -43252,23 +46032,23 @@ var ts; return 0 /* False */; } var result = 0 /* False */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); 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 & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { if (target.flags & 1048576 /* Union */) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined, isIntersectionConstituent)) { return 0 /* False */; } } @@ -43276,9 +46056,9 @@ var ts; else if (target.flags & 2097152 /* Intersection */) { isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, /*isIntersectionConstituent*/ false)) { return 0 /* False */; } } @@ -43297,15 +46077,15 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); } if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152 /* Intersection */) { + if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) { // 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 @@ -43315,21 +46095,30 @@ 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 & 1048576 /* Union */)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) { + if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { @@ -43349,6 +46138,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } @@ -43385,7 +46175,7 @@ var ts; // check excess properties against discriminant type only, not the entire union return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -43400,6 +46190,11 @@ var ts; // 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) + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + // Note that extraneous children (as in `extra`) don't pass this check, + // since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute. + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -43428,9 +46223,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -43566,14 +46361,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { return related; } @@ -43593,7 +46388,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -43620,10 +46415,10 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t); } else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 3 /* Bivariant */) { // In the bivariant case we first compare contravariantly without reporting @@ -43632,16 +46427,16 @@ var ts; // which is generally easier to reason about. related = isRelatedTo(t, s, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } if (!related) { @@ -43652,17 +46447,6 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8 /* Unmeasurable */) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16 /* Unreliable */) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -43673,24 +46457,24 @@ var ts; return 0 /* False */; } var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2 /* Failed */) { + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24 /* ReportsMask */; + if (saved & 8 /* ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16 /* ReportsUnreliable */) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; } } if (!maybeKeys) { @@ -43721,14 +46505,26 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 /* True */ || depth === 0) { // If result is definitely true, record all maybe keys as having succeeded for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */); + relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); } maybeCount = maybeStart; } @@ -43736,7 +46532,7 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); + relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -43776,7 +46572,7 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); // 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. @@ -43784,7 +46580,7 @@ var ts; source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43866,7 +46662,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -43877,7 +46673,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43886,25 +46682,25 @@ var ts; if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43913,13 +46709,23 @@ var ts; // 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. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43928,14 +46734,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43949,7 +46755,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43968,7 +46774,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); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43995,8 +46801,8 @@ var ts; // relates to X. Thus, we include intersection types on the source side here. 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, /*excludedProperties*/ undefined); + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; + result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); if (result) { @@ -44010,7 +46816,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; // Use variance error (there is no structural one) and return false } else if (result) { return result; @@ -44031,8 +46837,8 @@ var ts; } } return 0 /* False */; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { @@ -44041,7 +46847,7 @@ var ts; // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially // be assuming identity of the type parameter. originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -44069,7 +46875,7 @@ var ts; // comparison unexpectedly succeeds. This can happen when the structural comparison result // is a Ternary.Maybe for example caused by the recursion depth limiter. originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44145,11 +46951,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) @@ -44157,7 +46963,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -44165,8 +46971,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -44179,15 +46985,15 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, /*isIntersectionConstituent*/ false); if (result) { result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); if (result) { @@ -44222,7 +47028,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { @@ -44262,10 +47068,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -44303,10 +47109,10 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0 /* False */; } @@ -44326,7 +47132,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -44342,12 +47148,12 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) { @@ -44357,8 +47163,8 @@ var ts; 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(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined) @@ -44370,7 +47176,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -44395,8 +47201,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -44410,12 +47217,14 @@ var ts; // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members var properties = target.flags & 1048576 /* Union */ ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304 /* Prototype */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0 /* False */; } @@ -44478,14 +47287,15 @@ var ts; } } var result = -1 /* True */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 /* Instantiated */ && ts.getObjectFlags(target) & 64 /* Instantiated */ && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters // as they are known to always be the same. for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0 /* False */; } @@ -44499,7 +47309,7 @@ var ts; // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -44508,10 +47318,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -44524,11 +47334,23 @@ var ts; } return result; } + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } /** * See signatureAssignableTo, compareSignaturesIdentical */ - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -44594,7 +47416,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -44650,23 +47472,27 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + // undefined=unknown, true=discriminated, false=not discriminated + // The state of each type progresses from left to right. Discriminated types stop at 'true'. + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; // Finding multiple fields which discriminate to the same type is fine - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; } + else { + discriminable[i] = false; + } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(/*searchElement*/ true); + // make sure exactly 1 matches before returning it + return match === -1 || discriminable.indexOf(/*searchElement*/ true, match + 1) !== -1 ? defaultValue : target.types[match]; } /** * A type is 'weak' if it is an object type with at least one optional property @@ -44722,7 +47548,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -44754,7 +47580,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -44780,8 +47606,11 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -44790,7 +47619,7 @@ var ts; function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -44869,6 +47698,9 @@ var ts; // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 // levels, but unequal at some level beyond that. + // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially + // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives + // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`). 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 & 524288 /* Object */) { @@ -44885,8 +47717,30 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608 /* IndexedAccess */) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + /** + * Gets the leftmost object type in a chain of indexed accesses, eg, in A[P][Q], returns A + */ + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608 /* IndexedAccess */) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -44994,20 +47848,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - // If they're both type predicates their return types will both be `boolean`, so no need to compare those. - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : + source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type) : + 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -45046,7 +47902,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, @@ -45054,7 +47910,7 @@ var ts; return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -45138,7 +47994,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -45153,8 +48009,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -45219,6 +48075,41 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, function (t) { return t !== optionalType; }) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function createPooledOptionalTypeResult(isOptional, type) { + pooledOptionalTypeResult.isOptional = isOptional; + pooledOptionalTypeResult.type = type; + return pooledOptionalTypeResult; + } + function checkOptionalExpression(parent, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + var isOptional = false; + var type = checkExpression(expression); + if (ts.isOptionalChain(parent)) { + if (parent.questionDotToken) { + // If we have a questionDotToken then we are an OptionalExpression and should remove `null` and + // `undefined` from the type and add the optionalType to the result, if needed. + isOptional = isNullableType(type); + return createPooledOptionalTypeResult(isOptional, isOptional ? getNonNullableType(type) : type); + } + // If we do not have a questionDotToken, then we are an OptionalChain and we remove the optionalType and + // indicate whether we need to add optionalType back into the result. + var nonOptionalType = removeOptionalTypeMarker(type); + if (nonOptionalType !== type) { + isOptional = true; + type = nonOptionalType; + } + } + type = checkNonNullType(type, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + return createPooledOptionalTypeResult(isOptional, type); + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -45248,8 +48139,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45401,7 +48292,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -45438,7 +48329,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -45468,17 +48359,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 208 /* BinaryExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* 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 152 /* Parameter */: + case 155 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -45488,23 +48379,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -45518,7 +48409,7 @@ var ts; wideningKind === 1 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182 /* MappedType */: + case 185 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -45560,8 +48451,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 /* This */ || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -45630,6 +48520,12 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } @@ -45639,10 +48535,10 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & 32 /* Mapped */ || - type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -45708,10 +48604,10 @@ 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, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), 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.readonly, source.target.associatedNames); @@ -45797,8 +48693,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256 /* MaxValue */; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -45821,50 +48716,57 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - 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) { - for (var _i = 0, _a = source.types; _i < _a.length; _i++) { - var t = _a[_i]; - inferFromTypes(t, t); - } - return; - } - // Find each source constituent type that has an identically matching target constituent - // type, and for each such type infer from the type to itself. When inferring from a - // type to itself we effectively find all type parameter occurrences within that type - // and infer themselves as their type arguments. We have special handling for numeric - // and string literals because the number and string types are not represented as unions - // of all their possible values. - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } - } - // Next, to improve the quality of inferences, reduce the source and target types by - // removing the identically matched constituents. For example, when inferring from - // 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'. - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + // When source and target are the same union or intersection type, just relate each constituent + // type to itself. + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } + return; } - else if (target.flags & 1048576 /* Union */ && !(target.flags & 1024 /* EnumLiteral */) || target.flags & 2097152 /* Intersection */) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); + if (target.flags & 1048576 /* Union */) { + // First, infer between identically matching source and target constituents and remove the + // matching types. + var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + // Next, infer between closely matching source and target constituents and remove + // the matching types. Types closely match when they are instantiations of the same + // object type or instantiations of the same type alias. + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { return; } + target = getUnionType(targets); + if (sources.length === 0) { + // All source constituents have been matched and there is nothing further to infer from. + // However, simply making no inferences is undesirable because it could ultimately mean + // inferring a type parameter constraint. Instead, make a lower priority inference from + // the full source to whatever remains in the target. For example, when inferring from + // string to 'string | T', make a lower priority inference of string for T. + var savePriority = priority; + priority |= 1 /* NakedTypeVariable */; + inferFromTypes(source, target); + priority = savePriority; + return; + } + source = getUnionType(sources); + } + else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + // We reduce intersection types only when they contain naked type parameters. For example, when + // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and + // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the + // string[] on the source side and infer string for T. + // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" + // in such scenarios. + if (!(source.flags & 1048576 /* Union */)) { + // Infer between identically matching source and target constituents and remove the matching types. + var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); + } } else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { target = getActualTypeVariable(target); @@ -45909,7 +48811,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -45931,9 +48833,10 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; @@ -45969,8 +48872,8 @@ var ts; else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -46000,15 +48903,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1 /* Circularity */); + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -46048,31 +48972,34 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; + var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we - // track whether inferences were made from that particular type to some target. - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + // track whether inferences were made from that particular type to some target with + // equal priority (i.e. of equal quality) to what we would infer for a naked type + // parameter. + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - // If the target has a single naked type variable and inference completed (meaning we - // explored the types fully), create a union of the source types from which no inferences - // have been made so far and infer from that union to the naked type variable. - if (typeVariableCount === 1 && inferenceComplete) { + // If the target has a single naked type variable and no inference circularities were + // encountered above (meaning we explored the types fully), create a union of the source + // types from which no inferences have been made so far and infer from that union to the + // naked type variable. + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -46084,8 +49011,8 @@ var ts; // We infer from types that are not naked type variables first so that inferences we // make from nested naked type variables and given slightly higher priority by virtue // of being first in the candidates array. - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -46101,8 +49028,8 @@ var ts; if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1 /* NakedTypeVariable */; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -46176,7 +49103,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1 /* Circularity */; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -46188,6 +49115,11 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + // If source and target are references to the same generic type, infer from type arguments + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } 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 // from S to T and from X to Y. @@ -46217,10 +49149,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -46260,7 +49192,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 === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 160 /* MethodDeclaration */ || kind === 159 /* MethodSignature */ || kind === 161 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46286,46 +49218,12 @@ var ts; } } } - function isMatchableType(type) { - // We exclude non-anonymous object types because some frameworks (e.g. Ember) rely on the ability to - // infer between types that don't witness their type variables. Such types would otherwise be eliminated - // because they appear identical. - return !(type.flags & 524288 /* Object */) || !!(ts.getObjectFlags(type) & 16 /* Anonymous */); - } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */) && target.flags & 1048576 /* Union */) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - /** - * Return a new union or intersection type computed by removing a given set of types - * from a given union or intersection type. - */ - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -46464,7 +49362,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46476,7 +49374,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; @@ -46485,7 +49383,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 === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 /* TypeQuery */ ? true : n.kind === 75 /* Identifier */ || n.kind === 152 /* 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 @@ -46495,16 +49393,16 @@ var ts; // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46515,24 +49413,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73 /* Identifier */: - return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + case 75 /* Identifier */: + return target.kind === 75 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 /* VariableDeclaration */ || target.kind === 190 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 101 /* ThisKeyword */: - return target.kind === 101 /* ThisKeyword */; - case 99 /* SuperKeyword */: - return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 103 /* ThisKeyword */: + return target.kind === 103 /* ThisKeyword */; + case 101 /* SuperKeyword */: + return target.kind === 101 /* SuperKeyword */; + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -46540,8 +49438,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 /* PropertyAccessExpression */ ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -46565,7 +49463,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73 /* Identifier */) { + if (expr.kind === 75 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -46596,7 +49494,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -46624,14 +49522,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 193 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -46673,8 +49571,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -46779,15 +49677,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 208 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 231 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -46804,21 +49702,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -46826,7 +49724,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -46844,37 +49742,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 230 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 231 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 241 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 241 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 190 /* BindingElement */ && node.parent.kind === 208 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -46884,13 +49777,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 199 /* ParenthesizedExpression */ || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -46912,8 +49805,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { - if (clause.expression.kind === 10 /* StringLiteral */) { + if (clause.kind === 275 /* CaseClause */) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -46996,8 +49889,7 @@ var ts; return mapType(typeWithPrimitives, function (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; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47049,8 +49941,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47073,33 +49965,78 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 193 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 195 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 60 /* EqualsToken */ && + parent.parent.kind === 208 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 /* VariableDeclaration */ || declaration.kind === 155 /* Parameter */ || + declaration.kind === 158 /* PropertyDeclaration */ || declaration.kind === 157 /* PropertySignature */) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99 /* SuperKeyword */) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + // We require the dotted function name in an assertion expression to be comprised of identifiers + // that reference function, method, class or value module symbols; or variable, property or + // parameter symbols with declarations that have explicit type annotations. Such references are + // resolvable with no possibility of triggering circularities in control flow analysis. + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216 /* InWithStatement */)) { + switch (node.kind) { + case 75 /* Identifier */: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 103 /* ThisKeyword */: + return getExplicitThisType(node); + case 193 /* PropertyAccessExpression */: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199 /* ParenthesizedExpression */: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + // A call expression parented by an expression statement is a potential assertion. Other call + // expressions are potential type predicate function calls. In order to avoid triggering + // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call + // target expression of an assertion. + var funcType = node.parent.kind === 225 /* ExpressionStatement */ ? getTypeOfDottedName(node.expression, /*diagnostic*/ undefined) : + node.expression.kind !== 101 /* SuperKeyword */ ? checkOptionalExpression(node, node.expression).type : + undefined; + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -47107,6 +50044,68 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 /* PreFinally */ && flow.lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048 /* Shared */) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + } + noCacheCheck = false; + } + if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 4096 /* PreFinally */)) { + flow = flow.antecedent; + } + else if (flags & 512 /* Call */) { + var signature = getEffectsSignature(flow.node); + if (signature && getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 4 /* BranchLabel */) { + // A branching point is reachable if any branch is reachable. + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8 /* LoopLabel */) { + // A loop is reachable if the control flow path that leads to the top is reachable. + flow = flow.antecedents[0]; + } + else if (flags & 128 /* SwitchClause */) { + // The control flow path representing an unmatched value in a switch statement with + // no default clause is unreachable if the switch statement is exhaustive. + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192 /* AfterFinally */) { + // Cache is unreliable once we start locking nodes + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, /*skipCacheCheck*/ false); + flow.locked = false; + return result; + } + else { + return !(flags & 1 /* Unreachable */); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -47118,6 +50117,7 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; @@ -47126,7 +50126,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47148,16 +50148,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192 /* Cached */) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -47169,13 +50160,13 @@ var ts; } } var type = void 0; - if (flags & 4096 /* AfterFinally */) { + if (flags & 8192 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048 /* PreFinally */) { + else if (flags & 4096 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; @@ -47187,14 +50178,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192 /* Cached */; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512 /* Call */) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96 /* Condition */) { @@ -47221,11 +50210,11 @@ var ts; } else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && - reference.kind !== 101 /* ThisKeyword */) { + reference.kind !== 193 /* PropertyAccessExpression */ && + reference.kind !== 194 /* ElementAccessExpression */ && + reference.kind !== 103 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -47237,7 +50226,7 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // Record visited node and the associated type in the cache. sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; @@ -47247,11 +50236,34 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384 /* Cached */) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */ ? + getInitialType(node) : + getAssignedType(node), reference); + // We cache the assigned type when getFlowTypeOfReference was recursively invoked in the + // resolution of the assigned type and we're not within loop analysis. + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384 /* Cached */; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -47260,11 +50272,11 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } @@ -47273,27 +50285,60 @@ var ts; // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } // A matching dotted name might also be an expando property on a function *expression*, // 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 === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 200 /* FunctionExpression */ || init.kind === 201 /* 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 === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 208 /* BinaryExpression */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56 /* BarBarToken */) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, /*assumeTrue*/ true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : + predicate.kind === 3 /* AssertsIdentifier */ ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 195 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47301,7 +50346,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47336,7 +50381,7 @@ var ts; // *only* place a silent never type is ever generated. var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -47354,12 +50399,15 @@ 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 === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { type = declaredType; } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } return createFlowType(type, isIncomplete(flowType)); } function getTypeAtFlowBranchLabel(flow) { @@ -47368,7 +50416,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + if (antecedent.flags & 4096 /* PreFinally */ && antecedent.lock.locked) { // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. @@ -47428,25 +50476,32 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + // The first antecedent of a loop junction is always the non-looping control + // flow path that leads to the top. + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - // If we see a value appear in the cache it is a sign that control flow analysis - // was restarted and completed by checkExpressionCached. We can simply pick up - // the resulting type and bail out. - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + // All but the first antecedent are the looping control flow paths that lead + // back to the loop junction. We track these on the flow loop stack. + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + // If we see a value appear in the cache it is a sign that control flow analysis + // was restarted and completed by checkExpressionCached. We can simply pick up + // the resulting type and bail out. + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control @@ -47520,19 +50575,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -47551,9 +50606,9 @@ var ts; return declaredType; } break; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94 /* InKeyword */: + case 96 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -47568,11 +50623,11 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && (operator === 35 /* EqualsEqualsEqualsToken */) && assumeTrue) { + if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { return valueType; } @@ -47585,7 +50640,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? @@ -47597,7 +50652,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* EqualsEqualsToken */ ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -47610,7 +50665,7 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // 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 @@ -47620,7 +50675,7 @@ var ts; } return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (type.flags & 1 /* Any */ && literal.text === "function") { @@ -47847,22 +50902,24 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { return type; } - if (ts.isIdentifierTypePredicate(predicate)) { + if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { var predicateArgument = callExpression.arguments[predicate.parameterIndex]; - if (predicateArgument) { + if (predicateArgument && predicate.type) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } @@ -47873,7 +50930,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { + if (ts.isAccessExpression(invokedExpression) && predicate.type) { var possibleReference = ts.skipParentheses(invokedExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -47888,27 +50945,44 @@ var ts; // Narrow the given type based on the given expression having the assumed boolean value. The returned type // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { + // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` + if (ts.isOptionalChainRoot(expr.parent) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 195 /* CallExpression */: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: - if (expr.operator === 52 /* ExclamationToken */) { + case 206 /* PrefixUnaryExpression */: + if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; @@ -47916,7 +50990,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 === 73 /* Identifier */) { + if (location.kind === 75 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -47937,9 +51011,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 249 /* ModuleBlock */ || + node.kind === 288 /* SourceFile */ || + node.kind === 158 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -47958,10 +51032,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 === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155 /* Parameter */) { symbol.isAssigned = true; } } @@ -47976,7 +51050,7 @@ 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 === 152 /* Parameter */ && + declaration.kind === 155 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -47984,10 +51058,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 193 /* PropertyAccessExpression */ || + parent.kind === 195 /* CallExpression */ && parent.expression === node || + parent.kind === 194 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 190 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48002,8 +51076,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -48021,7 +51098,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* 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 */)) { @@ -48042,7 +51119,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 === 241 /* ClassDeclaration */ + if (declaration.kind === 244 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48054,14 +51131,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 213 /* 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 !== 285 /* SourceFile */) { + while (container.kind !== 288 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 158 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48110,7 +51187,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 === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 155 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48119,8 +51196,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 === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 /* FunctionExpression */ || + flowContainer.kind === 201 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48128,11 +51205,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 4194304 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261 /* ExportSpecifier */) || + node.parent.kind === 217 /* NonNullExpression */ || + declaration.kind === 241 /* VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -48166,7 +51243,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 278 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48189,7 +51266,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, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48207,8 +51284,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 === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 229 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48226,7 +51303,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 199 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48234,9 +51311,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 206 /* PrefixUnaryExpression */ || current.parent.kind === 207 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -48247,7 +51324,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 158 /* PropertyDeclaration */ || container.kind === 161 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48315,37 +51392,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 161 /* 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 === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* 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 244 /* EnumDeclaration */: + case 247 /* 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 158 /* Constructor */: + case 161 /* 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 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* 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 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48384,10 +51461,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48395,12 +51470,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 200 /* FunctionExpression */ || container.kind === 243 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48429,9 +51502,22 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 200 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48441,16 +51527,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 160 /* MethodDeclaration */ && + container.parent.kind === 192 /* 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 === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && + container.parent.kind === 279 /* PropertyAssignment */ && + container.parent.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48458,7 +51544,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 197 /* FunctionExpression */ && + else if (container.kind === 200 /* 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") && @@ -48483,7 +51569,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 298 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48497,15 +51583,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 /* 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 === 198 /* ArrowFunction */) { + while (container && container.kind === 201 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48518,14 +51604,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153 /* ComputedPropertyName */; }); + if (current && current.kind === 153 /* 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 === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -48533,7 +51619,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 161 /* 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) { @@ -48602,7 +51688,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 === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 160 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -48616,7 +51702,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 192 /* 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; @@ -48637,7 +51723,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 /* 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; @@ -48652,7 +51738,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 === 158 /* Constructor */; + return container.kind === 161 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -48660,21 +51746,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 === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */ || + container.kind === 158 /* PropertyDeclaration */ || + container.kind === 157 /* PropertySignature */ || + container.kind === 161 /* Constructor */; } } } @@ -48682,14 +51768,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 160 /* MethodDeclaration */ || + func.kind === 162 /* GetAccessor */ || + func.kind === 163 /* SetAccessor */) && func.parent.kind === 192 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 200 /* FunctionExpression */ && func.parent.kind === 279 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -48697,7 +51783,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -48724,7 +51810,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 279 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -48738,9 +51824,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 === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 193 /* PropertyAccessExpression */ || target.kind === 194 /* 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)) { @@ -48804,9 +51890,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 155 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -48896,6 +51982,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -48927,7 +52022,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 197 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -48936,7 +52031,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: if (node !== right) { return undefined; } @@ -48945,7 +52040,8 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -48954,7 +52050,7 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -48982,19 +52078,22 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -49016,12 +52115,13 @@ var ts; } if (kind === 2 /* ModuleExports */) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -49065,7 +52165,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49154,32 +52254,35 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 73 /* Identifier */: - case 142 /* UndefinedKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 75 /* Identifier */: + case 145 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 199 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 274 /* 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 === 276 /* 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 === 279 /* 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 === 268 /* 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 === 271 /* 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, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, /*noReductions*/ true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -49246,7 +52349,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49255,58 +52358,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 190 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 201 /* ArrowFunction */: + case 234 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: - if (parent.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (parent.expression.kind === 95 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: + case 196 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 191 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 220 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 210 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 199 /* 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, contextFlags); } - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49461,7 +52564,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 200 /* FunctionExpression */ || node.kind === 201 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49475,14 +52578,12 @@ 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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1 /* Signature */) : - getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* Signature */); if (!type) { return undefined; } @@ -49491,8 +52592,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -49522,8 +52623,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 190 /* BindingElement */ && !!node.initializer) || + (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -49535,7 +52636,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 212 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -49560,12 +52661,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 212 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212 /* 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] = []". @@ -49607,9 +52708,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return isNumericComputedName(name); - case 73 /* Identifier */: + case 75 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -49697,7 +52798,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 188 /* ObjectBindingPattern */ || contextualType.pattern.kind === 192 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -49712,13 +52813,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 === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 279 /* PropertyAssignment */ || + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -49741,8 +52842,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 === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -49767,7 +52868,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 281 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -49793,7 +52894,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 162 /* GetAccessor */ || memberDecl.kind === 163 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -49853,7 +52954,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -49901,7 +53008,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 === 73 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -49946,7 +53053,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 273 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -49969,7 +53076,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 /* 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); @@ -50043,7 +53150,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -50117,7 +53224,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -50141,7 +53248,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -50293,13 +53400,13 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted reactSym.isReferenced = 67108863 /* All */; - // If react symbol is alias, mark it as referenced - if (reactSym.flags & 2097152 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 2097152 /* Alias */) { markAliasSymbolAsReferenced(reactSym); } } @@ -50388,7 +53495,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 152 /* QualifiedName */ ? node.right : node.kind === 187 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* 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)); @@ -50486,12 +53593,11 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); + } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (strictNullChecks && type.flags & 2 /* Unknown */) { @@ -50523,14 +53629,13 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + var _a = checkOptionalExpression(node, left), isOptional = _a.isOptional, leftType = _a.type; var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -50544,6 +53649,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0 /* String */) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -50571,9 +53677,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 103 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -50582,14 +53688,14 @@ var ts; } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return propagateOptionalTypeMarker(getFlowTypeOfAccessExpression(node, prop, propType, right), isOptional); } function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { // 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. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 194 /* ElementAccessExpression */ && node.kind !== 193 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -50599,11 +53705,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 && node.expression.kind === 101 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -50624,7 +53730,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -50634,9 +53740,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && - !(valueDeclaration.flags & 4194304 /* Ambient */) && + else if (valueDeclaration.kind === 244 /* ClassDeclaration */ && + node.parent.kind !== 168 /* TypeReference */ && + !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -50647,22 +53753,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 279 /* PropertyAssignment */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 281 /* SpreadAssignment */: + case 153 /* ComputedPropertyName */: + case 220 /* TemplateSpan */: + case 274 /* JsxExpression */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 266 /* JsxOpeningElement */: + case 215 /* ExpressionWithTypeArguments */: + case 277 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -50702,7 +53808,7 @@ var ts; 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)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -50740,7 +53846,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415 /* Value */); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -50835,16 +53941,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 101 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 152 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 187 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 /* PropertyAccessExpression */ && node.expression.kind === 101 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -50861,13 +53967,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 242 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73 /* Identifier */) { + else if (initializer.kind === 75 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -50884,13 +53990,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73 /* Identifier */) { + if (e.kind === 75 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 230 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -50904,28 +54010,14 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + var _a = checkOptionalExpression(node, node.expression), isOptional = _a.isOptional, exprType = _a.type; var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* 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); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -50934,7 +54026,7 @@ var ts; 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); + return propagateOptionalTypeMarker(checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node), isOptional); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === errorType) { @@ -50980,13 +54072,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 156 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51005,7 +54097,7 @@ var ts; // interface B extends A { (x: 'foo'): string } // const b: B; // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -51013,8 +54105,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -51046,11 +54138,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? createOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 212 /* SpreadElement */ || arg.kind === 219 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51064,9 +54156,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 210 /* 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. @@ -51081,7 +54173,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 156 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51096,7 +54188,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 196 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51189,7 +54281,7 @@ var ts; // 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 !== 153 /* Decorator */) { + if (node.kind !== 156 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51219,7 +54311,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -51232,7 +54324,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51256,7 +54348,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 219 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51331,12 +54423,12 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 196 /* 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. @@ -51346,7 +54438,7 @@ var ts; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -51354,7 +54446,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -51364,7 +54456,7 @@ var ts; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -51374,7 +54466,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -51395,15 +54487,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 193 /* PropertyAccessExpression */ || callee.kind === 194 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(219 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51413,17 +54505,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 156 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51438,7 +54530,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, /*isSpread*/ i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -51453,30 +54545,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* 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 152 /* Parameter */: + case 155 /* 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 === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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 !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 158 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51490,17 +54582,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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 152 /* Parameter */: + case 155 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -51538,8 +54630,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -51608,8 +54700,8 @@ var ts; // Overloads exist var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -51624,22 +54716,22 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 156 /* 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 !== 99 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -51688,7 +54780,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 195 /* 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 @@ -51741,7 +54833,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -51759,7 +54851,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -51893,7 +54985,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { + var _loop_15 = function (i) { var symbols = ts.mapDefined(candidates, function (_a) { var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; return hasRestParameter ? @@ -51904,7 +54996,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); var hasRestParameter = restParameterSymbols.length !== 0; @@ -51982,7 +55074,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -51997,12 +55089,12 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var _b = checkOptionalExpression(node, node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined), isOptional = _b.isOptional, funcType = _b.type; if (funcType === silentNeverType) { return silentNeverSignature; } @@ -52068,7 +55160,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -52131,7 +55223,7 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time @@ -52139,7 +55231,7 @@ var ts; // operation is Any. It is an error to have a Void this type. var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -52224,8 +55316,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var constituent = types_16[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52316,23 +55408,23 @@ var ts; invocationError(node.tag, apparentType, 0 /* Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52369,16 +55461,16 @@ var ts; invocationErrorRecovery(apparentType, 0 /* Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, 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(121 /* AnyKeyword */)); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* 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(124 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -52409,7 +55501,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -52425,16 +55517,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 156 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52485,57 +55577,52 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); - } - return false; - } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 193 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -52550,15 +55637,15 @@ var ts; // returns a function type. We defer checking and return nonInferrableType. return nonInferrableType; } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 196 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 161 /* Constructor */ && + declaration.kind !== 165 /* ConstructSignature */ && + declaration.kind !== 170 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -52578,18 +55665,28 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 /* CallExpression */ && node.parent.kind === 225 /* ExpressionStatement */ && + returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -52606,7 +55703,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -52627,7 +55724,7 @@ var ts; // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -52666,7 +55763,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -52675,19 +55772,20 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 243 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 241 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 4194304 /* Ambient */); + return !!decl && !!(decl.flags & 8388608 /* Ambient */); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 131072 /* MakeTemplateObject */); } @@ -52702,20 +55800,20 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || + op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -52751,10 +55849,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96 /* NewKeyword */) { + if (node.keywordToken === 98 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93 /* ImportKeyword */) { + if (node.keywordToken === 95 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -52765,7 +55863,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 === 158 /* Constructor */) { + else if (container.kind === 161 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -52775,11 +55873,11 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 /* ESNext */ || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -52821,7 +55919,7 @@ var ts; // otherwise would return the type 'undefined'). var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -52853,7 +55951,7 @@ var ts; if (signature.hasRestParameter) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; @@ -52951,7 +56049,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 === 73 /* Identifier */) { + if (element.name.kind === 75 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -52965,8 +56063,8 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73 /* Identifier */) { - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + if (decl.name.kind !== 75 /* Identifier */) { + // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -53020,7 +56118,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 222 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -53092,7 +56190,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -53203,17 +56301,18 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200 /* TypeOfExpression */) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203 /* 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 & 131072 /* Never */); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -53226,13 +56325,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128 /* HasImplicitReturn */)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */ function checkAndAggregateReturnExpressionTypes(func, checkMode) { @@ -53272,11 +56365,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 160 /* MethodDeclaration */: + return func.parent.kind === 192 /* ObjectLiteralExpression */; default: return false; } @@ -53302,10 +56395,10 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 159 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 222 /* Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; if (type && type.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -53335,7 +56428,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -53355,7 +56448,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 200 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53409,7 +56502,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53422,7 +56515,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 222 /* Block */) { checkSourceElement(node.body); } else { @@ -53503,11 +56596,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && - expr.expression.kind === 101 /* ThisKeyword */) { + (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) && + expr.expression.kind === 103 /* 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 === 158 /* Constructor */)) { + if (!(func && func.kind === 161 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -53520,31 +56613,35 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 255 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 75 /* Identifier */ && node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32 /* OptionalChain */) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 193 /* PropertyAccessExpression */ && expr.kind !== 194 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -53566,14 +56663,14 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 16384 /* AwaitContext */)) { + if (!(node.flags & 32768 /* AwaitContext */)) { // use of 'await' in non-async function var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -53586,7 +56683,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) { + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -53596,14 +56697,14 @@ var ts; switch (node.operand.kind) { case 8 /* NumericLiteral */: switch (node.operator) { - case 39 /* MinusToken */: + case 40 /* MinusToken */: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38 /* PlusToken */: + case 39 /* PlusToken */: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9 /* BigIntLiteral */: - if (node.operator === 39 /* MinusToken */) { + if (node.operator === 40 /* MinusToken */) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -53611,32 +56712,32 @@ var ts; } } switch (node.operator) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38 /* PlusToken */) { + if (node.operator === 39 /* 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)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 45 /* PlusPlusToken */: + case 46 /* 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -53650,7 +56751,7 @@ var ts; 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -53671,8 +56772,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -53761,7 +56862,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */ || property.kind === 280 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -53774,9 +56875,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 281 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -53819,8 +56920,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 214 /* OmittedExpression */) { + if (element.kind !== 212 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -53838,7 +56939,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 208 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -53854,7 +56955,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 280 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -53870,24 +56971,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 208 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 192 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 191 /* 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 === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 281 /* 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)) { + var optionalError = target.parent.kind === 281 /* SpreadAssignment */ ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -53903,53 +57007,53 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 145 /* UndefinedKeyword */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 203 /* TypeOfExpression */: + case 217 /* NonNullExpression */: + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 52 /* ExclamationToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 53 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 204 /* VoidExpression */: // Explicit opt-out + case 198 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 216 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -53961,15 +57065,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60 /* QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); + if (operator === 62 /* EqualsToken */ && (left.kind === 192 /* ObjectLiteralExpression */ || left.kind === 191 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103 /* ThisKeyword */); } var leftType; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -53977,28 +57093,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40 /* AsteriskToken */: - case 41 /* AsteriskAsteriskToken */: - case 63 /* AsteriskEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 43 /* PercentToken */: - case 66 /* PercentEqualsToken */: - case 39 /* MinusToken */: - case 62 /* MinusEqualsToken */: - case 46 /* LessThanLessThanToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: + case 41 /* AsteriskToken */: + case 42 /* AsteriskAsteriskToken */: + case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 44 /* PercentToken */: + case 68 /* PercentEqualsToken */: + case 40 /* MinusToken */: + case 64 /* MinusEqualsToken */: + case 47 /* LessThanLessThanToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54025,17 +57141,17 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); } resultType_1 = bigintType; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54043,8 +57159,8 @@ var ts; } return resultType_1; } - case 38 /* PlusToken */: - case 61 /* PlusEqualsToken */: + case 39 /* PlusToken */: + case 63 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54077,24 +57193,24 @@ var ts; } if (!resultType) { // Types that have a reasonably good chance of being a valid operand type. - // If both types have an awaited type of one of these, we’ll assume the user + // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61 /* PlusEqualsToken */) { + if (operator === 63 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -54103,25 +57219,29 @@ var ts; }); } return booleanType; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 60 /* EqualsToken */: + case 60 /* QuestionQuestionToken */: + return getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + leftType; + case 62 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -54148,6 +57268,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54155,7 +57278,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -54165,7 +57288,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 75 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -54180,15 +57303,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - return 55 /* BarBarToken */; - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - return 36 /* ExclamationEqualsEqualsToken */; - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: - return 54 /* AmpersandAmpersandToken */; + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + return 56 /* BarBarToken */; + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + return 37 /* ExclamationEqualsEqualsToken */; + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: + return 55 /* AmpersandAmpersandToken */; default: return undefined; } @@ -54201,7 +57324,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non-compound operation to be assignable to the type of VarExpr. - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); @@ -54235,17 +57358,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; + } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54253,12 +57382,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: typeName = "false"; break; - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -54267,6 +57396,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54285,7 +57425,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -54334,12 +57474,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2 /* Next */, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -54361,7 +57496,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 /* 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; @@ -54400,12 +57535,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 198 /* TypeAssertionExpression */ || node.kind === 216 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54427,10 +57562,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54482,7 +57617,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54493,7 +57628,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54505,8 +57640,8 @@ var ts; var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8 /* SkipGenericFunctions */) { @@ -54636,11 +57771,11 @@ 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 === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + var _a = checkOptionalExpression(expr, expr.expression), isOptional = _a.isOptional, funcType = _a.type; var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -54686,17 +57821,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 261 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 8388608 /* Ambient */)); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304 /* Ambient */) { + if (constEnumDeclaration.flags & 8388608 /* Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -54709,14 +57845,25 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { - case 73 /* Identifier */: + var kind = node.kind; + if (cancellationToken) { + // 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 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 75 /* Identifier */: return checkIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return checkThisExpression(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkSuperExpression(node); - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -54727,82 +57874,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: return trueType; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: - if (node.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (node.expression.kind === 95 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 196 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 219 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -54839,7 +57986,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -54850,10 +57997,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 === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 161 /* Constructor */ || func.kind === 165 /* ConstructSignature */ || func.kind === 170 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -54877,7 +58024,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -54886,9 +58033,11 @@ var ts; error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, - /*headMessage*/ undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, + /*headMessage*/ undefined, leadingError); + } } } else if (parameterName) { @@ -54909,13 +58058,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 201 /* ArrowFunction */: + case 164 /* CallSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 169 /* FunctionType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -54929,11 +58078,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 75 /* 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 === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 189 /* ArrayBindingPattern */ || name.kind === 188 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -54942,13 +58091,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* 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 === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 169 /* FunctionType */ || node.kind === 243 /* FunctionDeclaration */ || node.kind === 170 /* ConstructorType */ || + node.kind === 164 /* CallSignature */ || node.kind === 161 /* Constructor */ || + node.kind === 165 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -54978,10 +58127,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55011,28 +58160,21 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 166 /* IndexSignature */ && node.kind !== 298 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } } function checkClassForDuplicateDeclarations(node) { - var Declaration; - (function (Declaration) { - Declaration[Declaration["Getter"] = 1] = "Getter"; - Declaration[Declaration["Setter"] = 2] = "Setter"; - Declaration[Declaration["Method"] = 4] = "Method"; - Declaration[Declaration["Property"] = 3] = "Property"; - })(Declaration || (Declaration = {})); var instanceNames = ts.createUnderscoreEscapedMap(); var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 161 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* Property */); + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { + addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } } @@ -55043,17 +58185,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: - addName(names, name, memberName, 1 /* Getter */); + case 162 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: - addName(names, name, memberName, 2 /* Setter */); + case 163 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* Property */); + case 158 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: - addName(names, name, memberName, 4 /* Method */); + case 160 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */); break; } } @@ -55062,8 +58204,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4 /* Method */) { - if (meaning !== 4 /* Method */) { + if (prev & 8 /* Method */) { + if (meaning !== 8 /* Method */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -55115,7 +58257,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 157 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55123,7 +58265,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 73 /* Identifier */: + case 75 /* Identifier */: memberName = ts.idText(name); break; default: @@ -55140,7 +58282,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* 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 @@ -55160,7 +58302,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -55168,7 +58310,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -55195,7 +58337,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 === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 160 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55220,7 +58362,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55248,9 +58390,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55275,9 +58417,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { - if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { - if (!(node.flags & 256 /* HasExplicitReturn */)) { + if (node.kind === 162 /* GetAccessor */) { + if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { + if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -55285,13 +58427,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* 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 === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55309,7 +58451,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55357,19 +58499,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { @@ -55405,16 +58544,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 176 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 175 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55435,7 +58574,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 /* 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)); } @@ -55486,7 +58625,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 /* 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); @@ -55497,16 +58636,16 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 4194304 /* Ambient */); + return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && - n.flags & 4194304 /* Ambient */) { + if (n.parent.kind !== 245 /* InterfaceDeclaration */ && + n.parent.kind !== 244 /* ClassDeclaration */ && + n.parent.kind !== 213 /* ClassExpression */ && + n.flags & 8388608 /* 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 flags |= 1 /* Export */; @@ -55596,7 +58735,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 === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* 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 @@ -55631,11 +58770,12 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent.kind === 245 /* InterfaceDeclaration */ || node.parent.kind === 172 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -55646,7 +58786,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if ((node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 243 /* FunctionDeclaration */ || node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */ || node.kind === 161 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -55687,6 +58830,15 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { + // A non-ambient class cannot be an implementation for a non-constructor function/class merge + // TODO: The below just replicates our older error from when classes and functions were + // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" + // might be warranted. :shrug: + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { @@ -55698,8 +58850,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -55708,13 +58860,6 @@ var ts; } } } - var DeclarationSpaces; - (function (DeclarationSpaces) { - DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; - DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; - DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; - DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; - })(DeclarationSpaces || (DeclarationSpaces = {})); function checkExportsOnMergedDeclarations(node) { if (!produceDiagnostics) { return; @@ -55775,40 +58920,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 258 /* 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 */; } 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 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 243 /* FunctionDeclaration */: + case 257 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -55842,7 +58989,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { @@ -55877,9 +59024,6 @@ var ts; */ function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3 /* AnyOrUnknown */)) { - addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -56038,10 +59182,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 75 /* 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 { @@ -56061,7 +59205,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -56080,24 +59224,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 155 /* 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 155 /* PropertyDeclaration */: + case 158 /* 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 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56118,7 +59262,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 75 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56143,29 +59287,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var typeNode = types_18[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* 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); @@ -56211,14 +59355,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* 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 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56227,23 +59371,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 160 /* 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 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 155 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56306,7 +59450,7 @@ var ts; 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 === 149 /* 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 === 152 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56339,9 +59483,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56354,7 +59498,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 === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56370,7 +59514,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -56383,7 +59527,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 159 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56409,7 +59553,7 @@ var ts; } function registerForUnusedIdentifiersCheck(node) { // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`. - if (produceDiagnostics && !(node.flags & 4194304 /* Ambient */)) { + if (produceDiagnostics && !(node.flags & 8388608 /* Ambient */)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -56425,42 +59569,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 288 /* SourceFile */: + case 248 /* ModuleDeclaration */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 180 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56480,11 +59624,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 160 /* MethodDeclaration */: + case 158 /* PropertyDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + if (member.kind === 163 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56493,7 +59637,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 158 /* Constructor */: + case 161 /* 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 */)) { @@ -56501,8 +59645,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 166 /* IndexSignature */: + case 221 /* SemicolonClassElement */: // Can't be private break; default: @@ -56529,7 +59673,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -56564,7 +59708,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304 /* Ambient */) + if (nodeWithLocals.flags & 8388608 /* Ambient */) return; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); @@ -56599,7 +59743,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -56614,7 +59758,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -56632,7 +59776,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 === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 242 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -56653,7 +59797,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -56665,24 +59809,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 254 /* ImportClause */ || node.kind === 257 /* ImportSpecifier */ || node.kind === 255 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 254 /* ImportClause */ ? decl : decl.kind === 255 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 222 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -56699,7 +59843,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -56712,21 +59856,21 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 158 /* PropertyDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 160 /* MethodDeclaration */ || + node.kind === 159 /* MethodSignature */ || + node.kind === 162 /* GetAccessor */ || + node.kind === 163 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // ambient context - no codegen impact return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -56736,7 +59880,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 73 /* Identifier */; + var isDeclaration_1 = node.kind !== 75 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -56751,7 +59895,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 73 /* Identifier */; + var isDeclaration_2 = node.kind !== 75 /* 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); } @@ -56777,7 +59921,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 /* 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)); } @@ -56792,7 +59936,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* 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)); } @@ -56827,7 +59971,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 === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 241 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -56839,17 +59983,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 224 /* 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 === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 222 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 249 /* ModuleBlock */ || + container.kind === 248 /* ModuleDeclaration */ || + container.kind === 288 /* 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 @@ -56879,18 +60023,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 190 /* BindingElement */) { + if (node.parent.kind === 188 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -56904,26 +60048,26 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 /* 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 === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 /* 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)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -56960,7 +60104,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -56986,10 +60130,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -56998,7 +60142,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 158 /* PropertyDeclaration */ || nextDeclaration.kind === 157 /* PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -57008,8 +60152,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 155 /* Parameter */ && right.kind === 241 /* VariableDeclaration */) || + (left.kind === 241 /* VariableDeclaration */ && right.kind === 155 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57046,13 +60190,56 @@ var ts; function checkIfStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 223 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + // While it technically should be invalid for any known-truthy value + // to be tested, we de-scope to functions unrefenced in the block as a + // heuristic to identify the most common bugs. There are too many + // false positives for values sourced from type definitions without + // strictNullChecks otherwise. + var callSignatures = getSignaturesOfType(type, 0 /* Call */); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -57075,12 +60262,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 242 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57114,14 +60301,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* 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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* 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. @@ -57129,7 +60316,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -57153,7 +60340,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* 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); @@ -57167,7 +60354,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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* 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)) { @@ -57175,7 +60362,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved @@ -57528,7 +60715,7 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use @@ -57540,7 +60727,7 @@ var ts; // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -57619,7 +60806,7 @@ var ts; // - `Generator` or `AsyncGenerator` var globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `IterableIterator` and `AsyncIterableIterator` are defined by the // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. @@ -57630,7 +60817,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(/*reportErrors*/ false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -57666,11 +60853,11 @@ var ts; // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` // or `IteratorReturnResult` types, then just grab its type argument. if (isReferenceToType(type, getGlobalIteratorYieldResultType(/*reportErrors*/ false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, /*returnType*/ undefined, /*nextType*/ undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(/*reportErrors*/ false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(/*yieldType*/ undefined, returnType_1, /*nextType*/ undefined); } // Choose any constituents that can produce the requested iteration type. @@ -57734,11 +60921,13 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + // The value of `next(value)` is *not* awaited by async generators + nextType = methodParameterType; } else if (methodName === "return") { + // The value of `return(value)` *is* awaited by async generators + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -57831,12 +61020,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160 /* SetAccessor */) { + if (func.kind === 163 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 161 /* 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); } @@ -57854,7 +61043,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -57862,7 +61051,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384 /* AwaitContext */) { + if (node.flags & 32768 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -57883,7 +61072,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 === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 276 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -57895,7 +61084,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 275 /* 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. @@ -57924,7 +61113,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58031,8 +61220,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 === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 208 /* BinaryExpression */ || + name.kind === 153 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58109,7 +61298,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 168 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58169,11 +61358,10 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - // relax check if later interface augmentation has no constraint - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + // relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with + // a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill) + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } // If the type parameter node has a default and it is not identical to the default // for the type parameter at this position, we report an error. @@ -58210,7 +61398,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassNameCollisionWithObject(node.name); } } @@ -58223,11 +61411,12 @@ var ts; checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } @@ -58265,12 +61454,9 @@ var ts; } 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 - // that the base type is a class or interface type (and not, for example, an anonymous object type). - // (Javascript constructor functions have this property trivially true since their return type is ignored.) + // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -58313,7 +61499,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -58332,7 +61518,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -58358,7 +61544,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 244 /* ClassDeclaration */ || d.kind === 245 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58377,7 +61563,7 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304 /* Prototype */) { @@ -58386,53 +61572,104 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overridden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 210 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + // In order to resolve whether the inherited method was overridden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { + // Searches other base types for a declaration that would satisfy the inherited abstract member. + // (The class may have more than one base type via declaration merging with an interface with the + // same name.) + for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { + var otherBaseType = _b[_a]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } + if (derivedClassDecl.kind === 213 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } - else { - // derived overrides base. - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { - // either base or derived property is private - not override, skip it + } + else { + // derived overrides base. + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + // either base or derived property is private - not override, skip it + continue; + } + var errorMessage = void 0; + var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + if (basePropertyFlags && derivedPropertyFlags) { + // property/accessor is overridden with property/accessor + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 /* InterfaceDeclaration */ + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { + // when the base property is abstract or from an interface, base/derived flags don't need to match + // same when the derived property is from an assignment continue; } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; + if (basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + else if (basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 /* PropertyDeclaration */ && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432 /* Transient */) + && !(baseDeclarationFlags & 128 /* Abstract */) + && !(derivedDeclarationFlags & 128 /* Abstract */) + && !derived.declarations.some(function (d) { return d.flags & 8388608 /* Ambient */; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } } + // correct case + continue; + } + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived)) { + // method is overridden with method -- correct case + continue; } - else if (base.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + else if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -58469,12 +61706,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2 /* Ambient */) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -58489,7 +61729,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -58513,7 +61753,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -58576,7 +61816,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -58608,7 +61848,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304 /* Ambient */) { + else if (member.parent.flags & 8388608 /* Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -58618,66 +61858,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38 /* PlusToken */: return value_2; - case 39 /* MinusToken */: return -value_2; - case 53 /* TildeToken */: return ~value_2; + case 39 /* PlusToken */: return value_2; + case 40 /* MinusToken */: return -value_2; + case 54 /* TildeToken */: return ~value_2; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - 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); + case 51 /* BarToken */: return left | right; + case 50 /* AmpersandToken */: return left & right; + case 48 /* GreaterThanGreaterThanToken */: return left >> right; + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* LessThanLessThanToken */: return left << right; + case 52 /* CaretToken */: return left ^ right; + case 41 /* AsteriskToken */: return left * right; + case 43 /* SlashToken */: return left / right; + case 39 /* PlusToken */: return left + right; + case 40 /* MinusToken */: return left - right; + case 44 /* PercentToken */: return left % right; + case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { return left + right; } break; case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 73 /* Identifier */: + case 75 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* 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 === 190 /* PropertyAccessExpression */) { + if (ex.kind === 193 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -58702,10 +61941,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10 /* StringLiteral */; + return node.kind === 75 /* Identifier */ || + node.kind === 193 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 194 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -58739,7 +61978,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 !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 247 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -58762,9 +62001,9 @@ 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 === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304 /* Ambient */)) { + if ((declaration.kind === 244 /* ClassDeclaration */ || + (declaration.kind === 243 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } } @@ -58787,7 +62026,7 @@ var ts; if (produceDiagnostics) { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304 /* Ambient */; + var inAmbientContext = node.flags & 8388608 /* Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -58826,7 +62065,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, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 244 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -58876,23 +62115,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* 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 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 241 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -58903,12 +62142,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -58929,17 +62168,36 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); + return node; + } + } + function getFirstNonModuleExportsIdentifier(node) { + switch (node.kind) { + case 75 /* Identifier */: + return node; + case 152 /* QualifiedName */: + do { + node = node.left; + } while (node.kind !== 75 /* Identifier */); + return node; + case 193 /* PropertyAccessExpression */: + do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } + node = node.expression; + } while (node.kind !== 75 /* Identifier */); return node; } } @@ -58953,9 +62211,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -58977,27 +62235,29 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - // For external modules symbol represent local symbol for an alias. + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864 /* Assignment */; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + // For external modules symbol represents local symbol for an alias. // This local symbol will merge any other local declarations (excluding other aliases) // and symbol.flags will contains combined representation for all merged declaration. // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). - var excludedMeanings = (symbol.flags & (67220415 /* Value */ | 1048576 /* ExportValue */) ? 67220415 /* Value */ : 0) | - (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | + symbol = getMergedSymbol(symbol.exportSymbol || symbol); + var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | + (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 261 /* 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 === 258 /* ExportSpecifier */ - && !(target.flags & 67220415 /* Value */) - && !(node.flags & 4194304 /* Ambient */)) { + && node.kind === 261 /* ExportSpecifier */ + && !(target.flags & 111551 /* Value */) + && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -59022,7 +62282,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59046,23 +62306,23 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 263 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415 /* Value */) { + if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832 /* Type */) { + if (target.flags & 788968 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608 /* Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -59082,10 +62342,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 /* ModuleBlock */ && + !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59102,7 +62362,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 288 /* SourceFile */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 248 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59116,13 +62376,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -59131,8 +62395,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 === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59145,8 +62409,18 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73 /* Identifier */) { - markExportAsReferenced(node); + if (node.expression.kind === 75 /* Identifier */) { + var id = node.expression; + var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + if (sym) { + markAliasReferenced(sym, id); + // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) + var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // However if it is a value, we need to check it's being used correctly + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); } @@ -59155,10 +62429,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -59184,9 +62458,9 @@ var ts; } } // Checks for export * conflicts - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -59215,14 +62489,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -59244,158 +62510,162 @@ 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 /* FirstStatement */ && kind <= 240 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 181 /* ParenthesizedType */: + case 175 /* OptionalType */: + case 176 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 182 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return checkImportType(node); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 306 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 298 /* JSDocTypeLiteral */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: + case 302 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 292 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 223 /* EmptyStatement */: + case 240 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -59490,23 +62760,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 264 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -59535,7 +62805,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } // Grammar checking @@ -59621,7 +62891,7 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608 /* InWithStatement */) { + if (location.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } @@ -59636,35 +62906,35 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // 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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -59706,17 +62976,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 /* Identifier */ && + return name.kind === 75 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 154 /* TypeParameter */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -59724,16 +62994,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 168 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 193 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 215 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -59761,13 +63031,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 152 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 252 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 258 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -59793,7 +63063,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 187 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -59803,7 +63073,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 193 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -59811,17 +63081,17 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 258 /* 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); + /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } 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, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 252 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -59839,11 +63109,11 @@ 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 === 212 /* ExpressionWithTypeArguments */) { - meaning = 67897832 /* Type */; + if (entityName.parent.kind === 215 /* ExpressionWithTypeArguments */) { + meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415 /* Value */; + meaning |= 111551 /* Value */; } } else { @@ -59855,10 +63125,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306 /* JSDocParameterTag */) { + if (entityName.parent.kind === 310 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 310 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 154 /* TypeParameter */ && entityName.parent.parent.kind === 314 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -59868,19 +63138,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 73 /* Identifier */) { + if (entityName.kind === 75 /* 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); + return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 193 /* PropertyAccessExpression */ || entityName.kind === 152 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 193 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -59890,22 +63160,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 168 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 167 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -59919,12 +63189,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 190 /* BindingElement */ && + grandParent.kind === 188 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -59934,11 +63204,11 @@ var ts; } } switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -59950,14 +63220,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 182 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkExpression(node).symbol; - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 161 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -59968,7 +63238,7 @@ var ts; // 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 === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 /* ImportDeclaration */ || node.parent.kind === 259 /* 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); @@ -59985,22 +63255,22 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81 /* DefaultKeyword */: - case 91 /* FunctionKeyword */: - case 37 /* EqualsGreaterThanToken */: - case 77 /* ClassKeyword */: + case 83 /* DefaultKeyword */: + case 93 /* FunctionKeyword */: + case 38 /* EqualsGreaterThanToken */: + case 79 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 280 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; } @@ -60008,10 +63278,10 @@ var ts; function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -60067,27 +63337,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 192 /* ObjectLiteralExpression */ || expr.kind === 191 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 231 /* 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 === 205 /* BinaryExpression */) { + if (expr.parent.kind === 208 /* 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 === 276 /* PropertyAssignment */) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60126,17 +63396,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } // Return the list of properties of the given type, augmented with properties from Function @@ -60188,7 +63457,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60209,13 +63478,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415 /* Value */); + return s && !!(s.flags & 111551 /* Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -60244,7 +63513,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 288 /* 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. @@ -60264,7 +63533,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -60272,7 +63541,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60281,7 +63550,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -60303,7 +63572,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 === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 222 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60344,26 +63613,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258 /* ExportAssignment */: + return node.expression && node.expression.kind === 75 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60377,7 +63645,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 67220415 /* Value */) && + return !!(target.flags & 111551 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -60391,7 +63659,7 @@ var ts; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && - target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -60445,7 +63713,7 @@ var ts; if (!symbol || !(symbol.flags & 16 /* Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 /* Value */ && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -60464,15 +63732,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 282 /* EnumMember */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 282 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -60499,9 +63767,9 @@ var ts; return ts.TypeReferenceSerializationKind.Unknown; } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 67220415 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 67897832 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -60557,7 +63825,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -60576,7 +63844,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -60584,7 +63852,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -60606,7 +63874,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -60627,7 +63895,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -60708,12 +63976,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 === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 163 /* SetAccessor */ ? 162 /* GetAccessor */ : 163 /* 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 === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -60726,10 +63994,19 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 215 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 277 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -60740,9 +64017,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* Type */ | 1920 /* Namespace */; + if ((node.kind === 75 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 193 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -60792,7 +64069,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -60820,12 +64097,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 /* 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, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 288 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -60958,16 +64235,16 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1 /* FirstEmitHelper */; helper <= 131072 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -61014,14 +64291,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 /* 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 === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* 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); @@ -61038,23 +64315,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 !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (modifier.kind !== 137 /* ReadonlyKeyword */) { + if (node.kind === 157 /* PropertySignature */ || node.kind === 159 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); + case 80 /* ConstKeyword */: + if (node.kind !== 247 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80 /* ConstKeyword */)); } break; - case 116 /* PublicKeyword */: - case 115 /* ProtectedKeyword */: - case 114 /* PrivateKeyword */: + case 118 /* PublicKeyword */: + case 117 /* ProtectedKeyword */: + case 116 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -61068,11 +64345,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* 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 === 114 /* PrivateKeyword */) { + if (modifier.kind === 116 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -61081,7 +64358,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -61091,10 +64368,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61103,18 +64380,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */ && node.kind !== 166 /* IndexSignature */ && node.kind !== 155 /* 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 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -61127,52 +64404,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 === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 83 /* DefaultKeyword */: + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* 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 126 /* DeclareKeyword */: + case 129 /* 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 === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 249 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 119 /* AbstractKeyword */: + case 121 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 244 /* ClassDeclaration */) { + if (node.kind !== 160 /* MethodDeclaration */ && + node.kind !== 158 /* PropertyDeclaration */ && + node.kind !== 162 /* GetAccessor */ && + node.kind !== 163 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 244 /* 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 */) { @@ -61184,14 +64461,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 122 /* AsyncKeyword */: + case 125 /* 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 */) { + else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61199,7 +64476,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61214,13 +64491,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 253 /* ImportDeclaration */ || node.kind === 252 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 /* 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 === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 155 /* 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 */) { @@ -61241,38 +64518,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 248 /* ModuleDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 155 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 125 /* AsyncKeyword */); + case 244 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AbstractKeyword */); + case 245 /* InterfaceDeclaration */: + case 224 /* VariableStatement */: + case 246 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); + case 247 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 80 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -61284,10 +64561,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61316,7 +64593,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -61350,7 +64627,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -61402,7 +64679,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 /* StringKeyword */ && parameter.type.kind !== 136 /* NumberKeyword */) { + if (parameter.type.kind !== 142 /* StringKeyword */ && parameter.type.kind !== 139 /* 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(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -61434,11 +64711,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211 /* OmittedExpression */) { + if (arg.kind === 214 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61468,7 +64751,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 === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -61481,7 +64764,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -61497,14 +64780,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -61515,21 +64798,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 153 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 208 /* 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 === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); - if (node.flags & 4194304 /* Ambient */) { + ts.Debug.assert(node.kind === 243 /* FunctionDeclaration */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 160 /* MethodDeclaration */); + if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -61544,17 +64827,10 @@ var ts; return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var Flags; - (function (Flags) { - Flags[Flags["Property"] = 1] = "Property"; - Flags[Flags["GetAccessor"] = 2] = "GetAccessor"; - Flags[Flags["SetAccessor"] = 4] = "SetAccessor"; - Flags[Flags["GetOrSetAccessor"] = 6] = "GetOrSetAccessor"; - })(Flags || (Flags = {})); var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 281 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -61565,20 +64841,21 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 /* 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); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 125 /* AsyncKeyword */ || prop.kind !== 160 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -61593,24 +64870,25 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 279 /* 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 157 /* MethodDeclaration */: - currentKind = 1 /* Property */; + currentKind = 4 /* PropertyAssignment */; + break; + case 160 /* MethodDeclaration */: + currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: - currentKind = 2 /* GetAccessor */; + case 162 /* GetAccessor */: + currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: - currentKind = 4 /* SetAccessor */; + case 163 /* SetAccessor */: + currentKind = 2 /* SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -61624,11 +64902,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + if ((currentKind & 12 /* PropertyAssignmentOrMethod */) && (existingKind & 12 /* PropertyAssignmentOrMethod */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6 /* GetOrSetAccessor */) && (existingKind & 6 /* GetOrSetAccessor */)) { - if (existingKind !== 6 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { + if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -61646,7 +64924,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 === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 273 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -61656,7 +64934,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 274 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -61670,14 +64948,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + if (forInOrOfStatement.kind === 231 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -61688,7 +64966,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 242 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -61703,20 +64981,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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); @@ -61726,42 +65004,38 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304 /* Ambient */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 8388608 /* Ambient */)) { + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { + if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 /* GetAccessor */ ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 162 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160 /* SetAccessor */) { + if (accessor.kind === 163 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; @@ -61771,23 +65045,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 === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143 /* UniqueKeyword */) { - if (node.type.kind !== 140 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140 /* SymbolKeyword */)); + if (node.operator === 146 /* UniqueKeyword */) { + if (node.type.kind !== 143 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* 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)) { @@ -61797,13 +65071,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 158 /* 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 154 /* PropertySignature */: + case 157 /* 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); } @@ -61812,9 +65086,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); + else if (node.operator === 137 /* ReadonlyKeyword */) { + if (node.type.kind !== 173 /* ArrayType */ && node.type.kind !== 174 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143 /* SymbolKeyword */)); } } } @@ -61827,10 +65101,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 160 /* MethodDeclaration */) { + if (node.parent.kind === 192 /* 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 === 122 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -61853,17 +65127,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* 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 === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 160 /* 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 === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* 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 === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* 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); } } @@ -61874,11 +65148,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 237 /* 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 === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 232 /* 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); @@ -61886,8 +65160,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 236 /* SwitchStatement */: + if (node.kind === 233 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -61902,13 +65176,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* 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 === 230 /* BreakStatement */ + var message = node.kind === 233 /* 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); @@ -61931,13 +65205,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -61950,7 +65224,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 /* TrueKeyword */ || initializer.kind === 88 /* FalseKeyword */ || + initializer.kind === 105 /* TrueKeyword */ || initializer.kind === 90 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -61967,8 +65241,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { - if (node.flags & 4194304 /* Ambient */) { + if (node.parent.parent.kind !== 230 /* ForInStatement */ && node.parent.parent.kind !== 231 /* ForOfStatement */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -61980,11 +65254,11 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -61997,7 +65271,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -62014,8 +65288,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73 /* Identifier */) { - if (name.originalKeywordKind === 112 /* LetKeyword */) { + if (name.kind === 75 /* Identifier */) { + if (name.originalKeywordKind === 114 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -62042,15 +65316,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62068,12 +65342,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96 /* NewKeyword */: + case 98 /* 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 93 /* ImportKeyword */: + case 95 /* 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"); } @@ -62131,7 +65405,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* 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; } @@ -62139,7 +65413,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* 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; } @@ -62147,11 +65421,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { + node.flags & 8388608 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } @@ -62168,13 +65442,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 246 /* TypeAliasDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 259 /* ExportDeclaration */ || + node.kind === 258 /* ExportAssignment */ || + node.kind === 251 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62183,7 +65457,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 === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 224 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62192,17 +65466,13 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304 /* Ambient */) { - // An accessors is already reported about the ambient context - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } + if (node.flags & 8388608 /* Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } // We are either parented by another statement, or some sort of block. @@ -62210,7 +65480,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 === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 222 /* Block */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62232,20 +65502,39 @@ 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, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 186 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 282 /* 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 === 39 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62300,11 +65589,19 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 243 /* FunctionDeclaration */ && declaration.kind !== 160 /* MethodDeclaration */) || + !!declaration.body; + } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62312,21 +65609,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 254 /* ImportClause */: // For default import + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: // For rename import `x as y` return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 257 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62336,7 +65632,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62407,6 +65702,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62454,7 +65750,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73 /* Identifier */); + var node = createSynthesizedNode(75 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -62535,23 +65831,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(99 /* SuperKeyword */); + return createSynthesizedNode(101 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101 /* ThisKeyword */); + return createSynthesizedNode(103 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97 /* NullKeyword */); + return createSynthesizedNode(99 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103 /* TrueKeyword */); + return createSynthesizedNode(105 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88 /* FalseKeyword */); + return createSynthesizedNode(90 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -62562,44 +65858,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(86 /* ExportKeyword */)); + result.push(createModifier(88 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(126 /* DeclareKeyword */)); + result.push(createModifier(129 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(81 /* DefaultKeyword */)); + result.push(createModifier(83 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(78 /* ConstKeyword */)); + result.push(createModifier(80 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(116 /* PublicKeyword */)); + result.push(createModifier(118 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(114 /* PrivateKeyword */)); + result.push(createModifier(116 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(115 /* ProtectedKeyword */)); + result.push(createModifier(117 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(119 /* AbstractKeyword */)); + result.push(createModifier(121 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(117 /* StaticKeyword */)); + result.push(createModifier(119 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(134 /* ReadonlyKeyword */)); + result.push(createModifier(137 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(122 /* AsyncKeyword */)); + result.push(createModifier(125 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(152 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -62618,7 +65914,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(153 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -62631,7 +65927,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(154 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -62647,7 +65943,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(155 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -62671,7 +65967,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(156 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -62684,7 +65980,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(157 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -62704,12 +66000,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(158 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -62719,8 +66015,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -62728,7 +66024,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(159 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -62745,7 +66041,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(160 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -62758,6 +66054,38 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), + /*typeArguments*/ undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + /* @internal */ + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + /* @internal */ + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -62773,7 +66101,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(161 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -62793,7 +66121,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(162 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62816,7 +66144,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(163 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62837,7 +66165,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -62845,7 +66173,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -62853,7 +66181,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(166 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -62893,21 +66221,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167 /* TypePredicate */); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(168 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -62921,7 +66259,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(169 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -62929,7 +66267,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(170 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -62937,7 +66275,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(171 /* TypeQuery */); node.exprName = exprName; return node; } @@ -62949,7 +66287,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(172 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -62961,7 +66299,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(173 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -62973,7 +66311,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(174 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -62985,7 +66323,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(175 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -62997,7 +66335,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(176 /* RestType */); node.type = type; return node; } @@ -63009,7 +66347,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(177 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63017,7 +66355,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(178 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63036,7 +66374,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(179 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63054,7 +66392,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(180 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63066,7 +66404,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(187 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63084,7 +66422,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(181 /* ParenthesizedType */); node.type = type; return node; } @@ -63096,12 +66434,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(182 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; + var node = createSynthesizedNode(183 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -63111,7 +66449,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(184 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63125,7 +66463,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(185 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63143,7 +66481,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(186 /* LiteralType */); node.literal = literal; return node; } @@ -63156,7 +66494,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(188 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63168,7 +66506,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(189 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63180,7 +66518,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(190 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63199,7 +66537,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(191 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63213,7 +66551,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(192 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63227,7 +66565,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63235,6 +66573,7 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessChain using updatePropertyAccess. Use updatePropertyAccessChain instead."); // Because we are updating existed propertyAccess we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -63243,22 +66582,62 @@ var ts; : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072 /* NoIndentation */); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(194 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessChain using updateElementAccess. Use updateElementAccessChain instead."); return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194 /* ElementAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(195 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63266,6 +66645,7 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update a CallChain using updateCall. Use updateCallChain instead."); return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -63273,8 +66653,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195 /* CallExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(196 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63290,7 +66690,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(197 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63313,7 +66713,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(198 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63327,7 +66727,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(199 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63339,7 +66739,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(200 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63363,12 +66763,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(201 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -63385,7 +66785,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(202 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63397,7 +66797,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(203 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63409,7 +66809,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(204 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63421,7 +66821,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(205 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63433,7 +66833,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(206 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63446,7 +66846,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(207 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63459,7 +66859,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(208 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63476,11 +66876,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(209 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(58 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -63496,7 +66896,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(210 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -63509,34 +66909,93 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15 /* TemplateHead */); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + } + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15 /* TemplateHead */: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16 /* TemplateMiddle */: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17 /* TemplateTail */: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23 /* CloseBracketToken */) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15 /* TemplateHead */, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16 /* TemplateMiddle */); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16 /* TemplateMiddle */, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17 /* TemplateTail */); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17 /* TemplateTail */, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14 /* NoSubstitutionTemplateLiteral */, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -63548,7 +67007,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(212 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -63560,7 +67019,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(213 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63581,11 +67040,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(214 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(215 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -63599,7 +67058,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(216 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -63613,7 +67072,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(217 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63625,7 +67084,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(218 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -63639,7 +67098,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(220 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -63653,12 +67112,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(221 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(222 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -63672,7 +67131,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(224 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -63687,11 +67146,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(223 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(225 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -63707,7 +67166,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(226 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -63723,7 +67182,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(227 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -63737,7 +67196,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(228 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63751,7 +67210,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(229 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -63769,7 +67228,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(230 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -63785,7 +67244,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(231 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -63803,7 +67262,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(232 /* ContinueStatement */); node.label = asName(label); return node; } @@ -63815,7 +67274,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(233 /* BreakStatement */); node.label = asName(label); return node; } @@ -63827,7 +67286,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(234 /* ReturnStatement */); node.expression = expression; return node; } @@ -63839,7 +67298,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(235 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63853,7 +67312,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(236 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -63867,7 +67326,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(237 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -63881,7 +67340,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(238 /* ThrowStatement */); node.expression = expression; return node; } @@ -63893,7 +67352,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(239 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -63909,11 +67368,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(240 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(241 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -63930,7 +67389,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(242 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -63943,7 +67402,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(243 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63969,7 +67428,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(244 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63991,7 +67450,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(245 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64013,7 +67472,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(246 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64033,7 +67492,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(247 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64052,8 +67511,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); + var node = createSynthesizedNode(248 /* ModuleDeclaration */); + node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -64071,7 +67530,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(249 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64083,7 +67542,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(250 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64095,7 +67554,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(251 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64107,7 +67566,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(252 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64125,7 +67584,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(253 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64143,7 +67602,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(254 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64157,7 +67616,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(255 /* NamespaceImport */); node.name = name; return node; } @@ -64169,7 +67628,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(256 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64181,7 +67640,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(257 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64195,11 +67654,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(258 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -64212,7 +67671,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(259 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64229,8 +67688,13 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + /* @internal */ + function createEmptyExports() { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(260 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64242,7 +67706,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(261 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64257,7 +67721,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(263 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64271,14 +67735,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(292 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(313 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64286,7 +67750,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(311 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64294,14 +67758,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(312 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(310 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64311,7 +67775,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297 /* JSDocComment */); + var node = createSynthesizedNode(301 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64325,7 +67789,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(264 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64341,7 +67805,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(265 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64357,7 +67821,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(266 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64373,7 +67837,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(267 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64385,7 +67849,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(268 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64407,11 +67871,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(269 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(270 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64423,7 +67887,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(271 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -64437,7 +67901,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(272 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -64449,7 +67913,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(273 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -64461,7 +67925,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(274 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -64475,7 +67939,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(275 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -64489,7 +67953,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(276 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -64501,7 +67965,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(277 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -64514,7 +67978,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(278 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -64529,7 +67993,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(279 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -64544,7 +68008,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(280 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -64558,7 +68022,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(281 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64571,7 +68035,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(282 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -64592,7 +68056,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(288 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -64676,7 +68140,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314 /* NotEmittedStatement */); + var node = createSynthesizedNode(318 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -64688,7 +68152,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(322 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64700,7 +68164,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(321 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64715,7 +68179,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(315 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(319 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -64731,7 +68195,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316 /* CommaListExpression */) { + if (node.kind === 320 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -64741,7 +68205,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316 /* CommaListExpression */); + var node = createSynthesizedNode(320 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -64752,9 +68216,25 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + /* @internal */ + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323 /* SyntheticReferenceExpression */); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + /* @internal */ + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(289 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -64785,7 +68265,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(290 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -64867,8 +68347,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal" /* Internal */: - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } // falls through case "text" /* Text */: (texts || (texts = [])).push(createUnparsedNode(section, node)); @@ -64917,10 +68400,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 283 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 284 /* UnparsedPrepend */; + case "internal" /* Internal */: return 286 /* UnparsedInternalText */; + case "text" /* Text */: return 285 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -64938,14 +68421,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(287 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(291 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -64991,8 +68474,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65035,43 +68518,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28 /* LessThanToken */, right); + return createBinary(left, 29 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60 /* EqualsToken */, right); + return createBinary(left, 62 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 36 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 37 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38 /* PlusToken */, right); + return createBinary(left, 39 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39 /* MinusToken */, right); + return createBinary(left, 40 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44 /* PlusPlusToken */); + return createPostfix(operand, 45 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54 /* AmpersandAmpersandToken */, right); + return createBinary(left, 55 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55 /* BarBarToken */, right); + return createBinary(left, 56 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60 /* QuestionQuestionToken */, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52 /* ExclamationToken */, operand); + return createPrefix(53 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -65091,7 +68578,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -65135,7 +68625,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 === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65200,7 +68690,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -65486,9 +68975,9 @@ var ts; ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -65589,29 +69078,34 @@ var ts; } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; // Helpers - function getHelperName(name) { + /** + * Gets an identifier for the name of an *unscoped* emit helper. + */ + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); @@ -65619,24 +69113,26 @@ var ts; ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; @@ -65658,7 +69154,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); @@ -65669,7 +69165,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -65681,20 +69177,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cacheIdentifiers; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -65709,7 +69205,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99 /* SuperKeyword */) { + else if (callee.kind === 101 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -65721,7 +69217,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 193 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65734,7 +69230,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65791,14 +69287,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66076,8 +69572,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -66105,9 +69601,9 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } @@ -66124,7 +69620,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 === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 199 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66158,10 +69654,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(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 /* ArrowFunction */ && binaryOperatorPrecedence > 3) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66173,7 +69669,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 211 /* YieldExpression */) { return false; } return true; @@ -66210,7 +69706,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 38 /* PlusToken */) { + if (binaryOperator === 39 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -66245,10 +69741,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 === 40 /* AsteriskToken */ - || binaryOperator === 50 /* BarToken */ - || binaryOperator === 49 /* AmpersandToken */ - || binaryOperator === 51 /* CaretToken */; + return binaryOperator === 41 /* AsteriskToken */ + || binaryOperator === 51 /* BarToken */ + || binaryOperator === 50 /* AmpersandToken */ + || binaryOperator === 52 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -66261,22 +69757,20 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(209 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -66311,8 +69805,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: needsParens = true; } } @@ -66328,9 +69822,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66353,7 +69847,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66391,7 +69885,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66402,29 +69896,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 200 /* FunctionExpression */ || kind === 201 /* 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 === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 192 /* ObjectLiteralExpression */ || leftmostExpressionKind === 200 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 179 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -66432,9 +69926,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 171 /* TypeQuery */: + case 183 /* TypeOperator */: + case 180 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -66460,28 +69954,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 315 /* PartiallyEmittedExpression */: + case 216 /* AsExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 217 /* NonNullExpression */: + case 319 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -66490,15 +69984,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 192 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 316 /* CommaListExpression */; + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 320 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -66511,13 +70005,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 217 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -66542,7 +70036,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 217 /* NonNullExpression */) { node = node.expression; } return node; @@ -66550,11 +70044,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 315 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -66572,7 +70066,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -66597,6 +70091,60 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + // use named imports + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + // Alias the imports if the names are used somewhere in the file. + // NOTE: We don't need to care about global import collisions as this is a module. + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + // use a namespace import + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -66611,8 +70159,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -66637,10 +70185,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 253 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 259 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -66759,7 +70307,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -66771,11 +70319,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -66807,12 +70355,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 155 /* Parameter */: + case 190 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 212 /* SpreadElement */: + case 281 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -66824,7 +70372,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 190 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -66836,7 +70384,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -66848,7 +70396,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -66871,13 +70419,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -66917,11 +70465,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67044,11 +70592,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -67082,278 +70628,287 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */) || kind === 182 /* ThisType */) { return node; } switch (kind) { // Names - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 155 /* 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 153 /* Decorator */: + case 156 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 157 /* 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 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 159 /* 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 157 /* MethodDeclaration */: + case 160 /* 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 158 /* Constructor */: + case 161 /* 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 159 /* GetAccessor */: + case 162 /* 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 160 /* SetAccessor */: + case 163 /* 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 161 /* CallSignature */: + case 164 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 166 /* 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 164 /* TypePredicate */: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 167 /* TypePredicate */: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 174 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 176 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 177 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 179 /* 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 177 /* InferType */: + case 180 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 187 /* 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 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 185 /* 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 183 /* LiteralType */: + case 186 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 190 /* 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 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 200 /* 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 198 /* ArrowFunction */: + case 201 /* 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 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 209 /* 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 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 213 /* 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 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 222 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 226 /* 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 224 /* DoStatement */: + case 227 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 229 /* 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 227 /* ForInStatement */: + case 230 /* 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 228 /* ForOfStatement */: + case 231 /* 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 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 243 /* 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 241 /* ClassDeclaration */: + case 244 /* 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 242 /* InterfaceDeclaration */: + case 245 /* 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 243 /* TypeAliasDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 247 /* 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 245 /* ModuleDeclaration */: + case 248 /* 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 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 252 /* 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 250 /* ImportDeclaration */: + case 253 /* 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 251 /* ImportClause */: + case 254 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 259 /* 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 257 /* NamedExports */: + case 260 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -67395,58 +70950,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 167 /* TypePredicate */ && kind <= 186 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 314 /* NotEmittedStatement */: + case 221 /* SemicolonClassElement */: + case 223 /* EmptyStatement */: + case 214 /* OmittedExpression */: + case 240 /* DebuggerStatement */: + case 318 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 155 /* 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 153 /* Decorator */: + case 156 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 157 /* 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 155 /* PropertyDeclaration */: + case 158 /* 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 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67455,12 +71010,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 161 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67468,7 +71023,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67476,50 +71031,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 196 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -67527,123 +71082,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 201 /* 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 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 213 /* 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 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 216 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 222 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 229 /* 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 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67652,7 +71207,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67660,140 +71215,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 247 /* 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 245 /* ModuleDeclaration */: + case 248 /* 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 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* 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 250 /* ImportDeclaration */: + case 253 /* 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 251 /* ImportClause */: + case 254 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 259 /* 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 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -67866,7 +71421,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 !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 215 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -67939,19 +71494,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ 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); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68154,12 +71710,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ 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 @@ -68171,6 +71726,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -68539,7 +72095,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -68581,25 +72137,31 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 252 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -68629,13 +72191,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -68643,7 +72205,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -68663,7 +72225,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -68685,12 +72247,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -68765,7 +72323,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -68795,42 +72353,28 @@ var ts; } ts.helperString = helperString; /** - * Gets all property declarations with initializers on either the static or instance side of a class. + * Gets all the static or all the instance property declarations of a class * * @param node The class node. * @param isStatic A value indicating whether to get properties from the static or instance side of the class. */ - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.getInitializedProperties = getInitializedProperties; + ts.getProperties = getProperties; /** - * Gets a value indicating whether a class element is a static property declaration with an initializer. - * - * @param member The class element node. - */ - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); - } - ts.isStaticInitializedProperty = isStaticInitializedProperty; - /** - * Gets a value indicating whether a class element is an instance property declaration with an initializer. - * - * @param member The class element node. - */ - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); - } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; - /** - * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. + * Is a class element either a static or an instance property declaration with an initializer? * * @param member The class element node. * @param isStatic A value indicating whether the member should be a static or instance member. */ - function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ - && member.initializer !== undefined; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; + } + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -69278,6 +72822,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -69302,7 +72847,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), + return ts.createCall(ts.getUnscopedHelperName("__rest"), /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) @@ -69355,8 +72900,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -69382,14 +72927,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* 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 === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -69440,16 +72985,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 249 /* ModuleBlock */: + case 222 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -69461,7 +73006,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 === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 244 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -69504,10 +73049,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -69528,13 +73073,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -69554,11 +73099,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 259 /* ExportDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 254 /* ImportClause */ || + (node.kind === 252 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 263 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -69582,19 +73127,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -69604,7 +73149,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 86 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 88 /* ExportKeyword */) { return undefined; } return node; @@ -69621,67 +73166,71 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 124 /* BooleanKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 133 /* NeverKeyword */: - case 107 /* VoidKeyword */: - case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 137 /* ReadonlyKeyword */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 172 /* TypeLiteral */: + case 167 /* TypePredicate */: + case 154 /* TypeParameter */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 127 /* BooleanKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 136 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 143 /* SymbolKeyword */: + case 170 /* ConstructorType */: + case 169 /* FunctionType */: + case 171 /* TypeQuery */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 181 /* ParenthesizedType */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 166 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 156 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 158 /* 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 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 245 /* 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 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69691,7 +73240,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69701,35 +73250,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -69739,35 +73288,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -69805,7 +73354,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -69834,7 +73383,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1 /* Export */))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); @@ -70071,7 +73620,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -70177,12 +73726,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70335,7 +73884,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 158 /* 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() @@ -70436,13 +73985,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(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -70458,10 +74007,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 158 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -70471,7 +74020,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -70482,12 +74031,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; } return false; @@ -70504,15 +74053,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -70549,7 +74098,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 162 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -70594,69 +74143,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: - case 124 /* BooleanKeyword */: + case 167 /* TypePredicate */: + case 127 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return ts.createIdentifier("String"); - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: - if (node.operator === 134 /* ReadonlyKeyword */) { + case 183 /* TypeOperator */: + if (node.operator === 137 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 171 /* TypeQuery */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 172 /* TypeLiteral */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 182 /* ThisType */: + case 187 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70667,15 +74216,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* 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); @@ -70755,12 +74304,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73 /* Identifier */) { + if (node.left.kind === 75 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -70776,7 +74325,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* 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); @@ -70784,7 +74333,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -70868,7 +74417,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 110 /* ImplementsKeyword */) { + if (node.token === 112 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -70918,7 +74467,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -71331,12 +74880,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 === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 288 /* 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 === 244 /* EnumDeclaration */) { + if (node.kind === 247 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -71461,7 +75010,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 249 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -71507,13 +75056,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 !== 246 /* ModuleBlock */) { + if (body.kind !== 249 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -71554,7 +75103,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 255 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -71767,7 +75316,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -71775,7 +75324,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(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -71785,17 +75334,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(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(75 /* Identifier */); + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(248 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 248 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 247 /* EnumDeclaration */; } /** * Hook for node emit. @@ -71854,11 +75403,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -71896,9 +75445,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 !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 288 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 248 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 247 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -71920,9 +75469,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } return substitute; @@ -71948,18 +75498,19 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), + return ts.createCall(ts.getUnscopedHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue @@ -71967,13 +75518,14 @@ var ts; } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression @@ -71981,6 +75533,7 @@ var ts; } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -72023,7 +75576,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -72034,11 +75589,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72050,20 +75605,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72073,7 +75628,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -72106,7 +75661,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var statements = [ ts.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -72122,9 +75677,9 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -72142,9 +75697,9 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { @@ -72156,7 +75711,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -72197,8 +75752,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -72211,7 +75766,7 @@ var ts; /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, /*isStatic*/ false); + var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false); // Only generate synthetic constructor when there are property initializers to move. if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); @@ -72243,7 +75798,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -72255,7 +75810,7 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -72272,7 +75827,7 @@ var ts; * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -72309,19 +75864,29 @@ var ts; */ function transformInitializedProperty(property, receiver) { // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72341,7 +75906,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -72425,6 +75990,7 @@ var ts; var hasSuperElementAccess; /** A set of node IDs for generated super accessors (variable statements). */ var substitutedSuperAccessors = []; + var topLevel; // Save the previous transformation hooks. var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; @@ -72436,38 +76002,57 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32 /* ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 243 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -72475,27 +76060,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 222 /* Block */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 235 /* WithStatement */: + case 237 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -72696,7 +76281,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 === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 201 /* 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 @@ -72719,7 +76304,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -72746,7 +76331,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -72787,17 +76372,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -72845,23 +76430,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -72873,19 +76458,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -72945,23 +76530,24 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; - return ts.createCall(ts.getHelperName("__awaiter"), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -72995,9 +76581,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; /** Keeps track of property names accessed on super (`super.x`) within async functions. */ var capturedSuperProperties; /** Whether the async function contains an element access on super (`super[x]`). */ @@ -73009,6 +76597,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -73020,68 +76610,85 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122 /* AsyncKeyword */) { + if (node.kind === 125 /* AsyncKeyword */) { return undefined; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 238 /* VariableDeclaration */: + case 224 /* VariableStatement */: + return visitVariableStatement(node); + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: - return visitConstructorDeclaration(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - return visitGetAccessorDeclaration(node); - case 160 /* SetAccessor */: - return visitSetAccessorDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + return doOutsideOfTopLevel(visitConstructorDeclaration, node); + case 160 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 162 /* GetAccessor */: + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 163 /* SetAccessor */: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 243 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -73114,7 +76721,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 231 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73126,7 +76733,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 === 278 /* SpreadAssignment */) { + if (e.kind === 281 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73135,7 +76742,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 279 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73169,7 +76776,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 192 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -73214,23 +76821,44 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a VariableDeclaration node with a binding pattern. * * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false); + } + function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. if (ts.isBindingPattern(node.name) && node.name.transformFlags & 8192 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */); + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -73445,10 +77073,10 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); @@ -73514,17 +77142,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -73572,23 +77200,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -73600,19 +77228,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73628,65 +77256,69 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), + return ts.createCall(ts.getUnscopedHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), /*typeArguments*/ undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__asyncGenerator"), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } })(ts || (ts = {})); @@ -73706,7 +77338,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -73725,6 +77357,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -73737,10 +77370,143 @@ var ts; return node; } switch (node.kind) { + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + var updated = visitOptionalExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208 /* BinaryExpression */: + if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a.b` -> { expression: `(_a = a).b`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a[b]` -> { expression: `(_a = a)[b]`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193 /* PropertyAccessExpression */: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194 /* ElementAccessExpression */: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193 /* PropertyAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194 /* ElementAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195 /* CallExpression */: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, + /*typeArguments*/ undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createNull()), ts.createToken(55 /* AmpersandAmpersandToken */), ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -73775,13 +77541,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73791,13 +77557,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -73872,7 +77638,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 274 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -73966,7 +77732,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 264 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74272,7 +78038,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74280,9 +78046,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74485,13 +78251,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 234 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 222 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -74504,72 +78270,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 73 /* Identifier */: + case 75 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -74580,28 +78346,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitSpreadElement(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -74692,14 +78458,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 === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 233 /* 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 === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -74710,7 +78476,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -74968,7 +78734,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -75106,11 +78872,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 234 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 226 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75118,7 +78884,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 222 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75273,10 +79039,10 @@ var ts; return false; } // `declarationName` is the name of the local declaration for the parameter. - var declarationName = parameter.name.kind === 73 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var declarationName = parameter.name.kind === 75 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 73 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; @@ -75300,7 +79066,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73 /* Identifier */) { + if (parameter.name.kind !== 75 /* Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); @@ -75316,7 +79082,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 201 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -75337,25 +79103,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 161 /* 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 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 */), 95 /* 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 */), 97 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -75384,20 +79150,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -75423,12 +79189,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), - /*location*/ member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. @@ -75585,7 +79361,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 === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 243 /* FunctionDeclaration */ || node.kind === 200 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -75629,7 +79405,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 201 /* 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 @@ -75697,9 +79473,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 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -75718,9 +79494,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 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -75755,7 +79531,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 60 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -75929,14 +79705,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76124,7 +79900,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 153 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76179,7 +79955,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -76245,11 +80021,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 229 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 231 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 227 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 228 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76274,11 +80050,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 242 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -76429,7 +80205,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -76491,7 +80267,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(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -76529,7 +80305,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -76540,7 +80316,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, 60 /* EqualsToken */, source); + return ts.createBinary(target, 62 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -76553,7 +80329,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -76567,7 +80343,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(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -76588,10 +80364,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -76677,20 +80453,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -76766,7 +80542,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a @@ -76797,7 +80573,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -76850,7 +80626,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 /* SuperKeyword */ || + if (expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -76974,10 +80750,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 4096 /* ContainsRestOrSpread */ || - node.expression.kind === 99 /* SuperKeyword */ || + node.expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -76995,7 +80771,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -77007,10 +80783,10 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -77034,7 +80810,7 @@ var ts; // [output] // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), /*typeArguments*/ undefined, []); } return ts.visitEachChild(node, visitor, context); @@ -77198,13 +80974,16 @@ var ts; // Find original source text, since we need to emit the raw strings of the tagged template. // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + 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 // and LineTerminatorSequences are normalized to for both TV and TRV. @@ -77295,13 +81074,11 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 98 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return ts.createFileLevelUniqueName("_newTarget"); } @@ -77333,7 +81110,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } /** @@ -77343,14 +81120,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableSubstitution(103 /* ThisKeyword */); + context.enableEmitNotification(161 /* Constructor */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(201 /* ArrowFunction */); + context.enableEmitNotification(200 /* FunctionExpression */); + context.enableEmitNotification(243 /* FunctionDeclaration */); } } /** @@ -77391,10 +81168,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 241 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -77407,9 +81184,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -77476,19 +81253,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -77498,7 +81275,7 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), + return ts.createCall(ts.getUnscopedHelperName("__extends"), /*typeArguments*/ undefined, [ name, ts.createFileLevelUniqueName("_super") @@ -77506,7 +81283,7 @@ var ts; } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw @@ -77514,12 +81291,14 @@ var ts; } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -77541,15 +81320,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(266 /* JsxOpeningElement */); + context.enableEmitNotification(267 /* JsxClosingElement */); + context.enableEmitNotification(265 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(279 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -77568,9 +81347,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -77627,7 +81406,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */) { + if (token !== undefined && token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -77902,13 +81681,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -77921,24 +81700,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -77959,21 +81738,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -77986,9 +81765,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78187,23 +81966,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 /* FirstCompoundAssignment */ - && kind <= 72 /* LastCompoundAssignment */; + return kind >= 63 /* FirstCompoundAssignment */ + && kind <= 74 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61 /* PlusEqualsToken */: return 38 /* PlusToken */; - case 62 /* MinusEqualsToken */: return 39 /* MinusToken */; - case 63 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; - case 64 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; - case 65 /* SlashEqualsToken */: return 42 /* SlashToken */; - case 66 /* PercentEqualsToken */: return 43 /* PercentToken */; - case 67 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; - case 68 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; - case 70 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; - case 71 /* BarEqualsToken */: return 50 /* BarToken */; - case 72 /* CaretEqualsToken */: return 51 /* CaretToken */; + case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; + case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; + case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; + case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; + case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; + case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; + case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; + case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; + case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; + case 73 /* BarEqualsToken */: return 51 /* BarToken */; + case 74 /* CaretEqualsToken */: return 52 /* CaretToken */; } } /** @@ -78216,7 +81995,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78228,7 +82007,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -78315,7 +82094,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 === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -78454,13 +82233,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -78469,7 +82248,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -78604,35 +82383,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79062,7 +82841,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 276 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79075,7 +82854,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79248,11 +83027,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -79387,7 +83165,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -80213,7 +83991,7 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), + return ts.createCall(ts.getUnscopedHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } // The __generator helper is used by down-level transformations to emulate the runtime @@ -80277,6 +84055,7 @@ var ts; // For examples of how these are used, see the comments in ./transformers/generators.ts ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -80303,12 +84082,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(288 /* 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. @@ -80406,14 +84185,14 @@ var ts; // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), // Add the module body function argument: // // function (require, exports, module1, module2) ... @@ -80423,10 +84202,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ]))) ]), @@ -80461,11 +84240,11 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) @@ -80493,10 +84272,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), @@ -80636,23 +84415,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 317 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -80679,24 +84458,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -80811,7 +84590,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -80825,7 +84604,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; if (languageVersion >= 2 /* ES2015 */) { @@ -80859,11 +84638,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; } @@ -81174,7 +84953,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81229,10 +85008,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -81414,8 +85193,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -81431,7 +85210,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -81493,12 +85272,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -81519,7 +85298,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -81587,15 +85366,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 === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* 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 === 204 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 207 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -81635,7 +85414,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]); } // emit helper for dynamic import @@ -81647,12 +85426,14 @@ var ts; // emit helper for `import * as Name from "foo"` ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -81669,16 +85450,18 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(218 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. + var contextObjectMap = []; // The context object associated with a source file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -81717,7 +85500,7 @@ var ts; // existing identifiers. exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -81895,7 +85678,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 259 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -81920,7 +85703,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 259 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -81989,28 +85772,28 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; + var group_2 = dependencyGroups_1[_i]; // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82060,15 +85843,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82244,7 +86027,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 === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 288 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -82308,7 +86091,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 === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -82370,10 +86153,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82553,43 +86336,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node); - case 317 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -82836,7 +86619,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 288 /* SourceFile */; } else { return false; @@ -82852,8 +86635,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -82869,12 +86652,13 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -82882,6 +86666,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -82917,7 +86702,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -82951,13 +86736,15 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); + case 218 /* MetaProperty */: + return substituteMetaProperty(node); } return node; } @@ -83042,22 +86829,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 === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* 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 === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 207 /* 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 === 204 /* PostfixUnaryExpression */) { - expression = node.operator === 44 /* PlusPlusToken */ + if (node.kind === 207 /* PostfixUnaryExpression */) { + expression = node.operator === 45 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -83066,6 +86853,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } /** * Gets the exports of a name. * @@ -83078,7 +86871,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83117,24 +86910,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); - context.enableSubstitution(73 /* Identifier */); - var currentSourceFile; + context.enableEmitNotification(288 /* SourceFile */); + context.enableSubstitution(75 /* Identifier */); + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864 /* NeverApplyImportHelper */); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -83146,10 +86935,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83170,9 +86959,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -83189,19 +86978,18 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -83257,7 +87045,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83286,7 +87074,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83312,7 +87100,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -83333,7 +87121,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 === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* 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 : @@ -83342,8 +87130,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 === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 158 /* PropertyDeclaration */ || node.kind === 193 /* PropertyAccessExpression */ || node.kind === 157 /* PropertySignature */ || + (node.kind === 155 /* 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 ? @@ -83352,7 +87140,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 === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 244 /* ClassDeclaration */ || node.kind === 155 /* 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 : @@ -83377,7 +87165,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* 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 */)) { @@ -83416,26 +87204,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* 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 161 /* CallSignature */: + case 164 /* 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 163 /* IndexSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83443,7 +87231,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83457,7 +87245,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 243 /* 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 : @@ -83482,30 +87270,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 161 /* 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 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 165 /* ConstructSignature */: + case 170 /* 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 161 /* CallSignature */: + case 164 /* 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 163 /* IndexSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83513,7 +87301,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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* 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 : @@ -83526,13 +87314,20 @@ 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 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 243 /* FunctionDeclaration */: + case 169 /* 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 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -83541,39 +87336,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 185 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* 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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* 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 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 169 /* FunctionType */: + case 243 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -83588,9 +87383,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 244 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 /* 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; } @@ -83625,11 +87420,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; // No declaration diagnostics for js for now - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -83639,7 +87431,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 155 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -83700,9 +87492,9 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -83785,20 +87577,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -83811,18 +87612,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { 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(126 /* 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 statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : 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 === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -83859,12 +87660,19 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -83906,6 +87714,15 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { + var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, host.getSourceFiles(), + /*preferences*/ undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration + // via a non-relative name, emit a type reference directive to that non-relative name, rather than + // a relative path to the declaration file + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { @@ -83942,11 +87759,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 189 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -83954,20 +87771,20 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 214 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { oldDiag = getSymbolAccessibilityDiagnostic; 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(56 /* 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(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -83992,19 +87809,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 155 /* 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(121 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* 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(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -84012,12 +87829,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 155 /* Parameter */ + || node.kind === 158 /* PropertyDeclaration */ + || node.kind === 157 /* 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)); @@ -84028,26 +87845,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(124 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return false; } return false; @@ -84074,6 +87891,33 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, /*modifierMask*/ undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -84101,7 +87945,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 /* ModuleDeclaration */ && parent.kind !== 187 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84121,7 +87965,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 263 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84148,7 +87992,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 === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 255 /* 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; @@ -84197,11 +88041,11 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -84211,13 +88055,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -84240,6 +88077,11 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + // Setup diagnostic-related flags before first potential `cleanup` call, otherwise + // We'd see a TDZ violation at runtime + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 /* TypeLiteral */ || input.kind === 185 /* MappedType */) && input.parent.kind !== 246 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -84248,76 +88090,77 @@ var ts; return cleanup(ts.createProperty(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* 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 212 /* ExpressionWithTypeArguments */: { + case 215 /* 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 165 /* TypeReference */: { + case 168 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 161 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(161 /* 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 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(159 /* 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 159 /* GetAccessor */: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 162 /* GetAccessor */: { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); } - case 160 /* SetAccessor */: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 163 /* SetAccessor */: { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); } - case 155 /* PropertyDeclaration */: + case 158 /* 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 154 /* PropertySignature */: + case 157 /* 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 156 /* MethodSignature */: { + case 159 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 164 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 166 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -84325,13 +88168,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 151 /* TypeParameter */: { + case 154 /* 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 176 /* ConditionalType */: { + case 179 /* 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); @@ -84343,13 +88186,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 169 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 170 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 187 /* 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)); @@ -84359,13 +88202,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -84378,7 +88221,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 160 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -84388,7 +88231,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 259 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -84397,13 +88240,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 258 /* 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 === 73 /* Identifier */) { + if (input.expression.kind === 75 /* Identifier */) { return input; } else { @@ -84413,7 +88256,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(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -84438,10 +88281,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -84462,14 +88305,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 246 /* 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), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 245 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 243 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -84484,7 +88327,7 @@ var ts; fakespace_1.symbol = props[0].parent; var declarations = ts.mapDefined(props, function (p) { if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { - return undefined; + return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker); @@ -84517,17 +88360,17 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 248 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 249 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304 /* Ambient */) { + if (input.flags & 8388608 /* Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -84536,7 +88379,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -84563,7 +88406,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 244 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -84574,7 +88417,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73 /* Identifier */) { + if (param.name.kind === 75 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -84604,7 +88447,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 !== 97 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); @@ -84614,16 +88457,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(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87 /* ExtendsKeyword */) { + if (clause.token === 89 /* 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 === 97 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -84634,10 +88477,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 247 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -84656,7 +88499,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 248 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -84677,7 +88520,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 214 /* OmittedExpression */) { return; } if (e.name) { @@ -84727,55 +88570,36 @@ var ts; function ensureModifierFlags(node) { 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 === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 288 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask, additions); } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); } - var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3 /* MultiLineCommentTrivia */) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; + return accessorType; } 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 === 87 /* ExtendsKeyword */ && t.expression.kind === 97 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 /* ExtendsKeyword */ && t.expression.kind === 99 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { return true; } return false; @@ -84800,7 +88624,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 162 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -84809,52 +88633,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 224 /* VariableStatement */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 165 /* ConstructSignature */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 241 /* VariableDeclaration */: + case 154 /* TypeParameter */: + case 215 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 179 /* ConditionalType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 187 /* ImportType */: return true; } return false; @@ -84983,7 +88807,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(319 /* Count */); + var enabledSyntaxKindFeatures = new Array(324 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -85190,7 +89014,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement( @@ -85268,15 +89092,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -85286,22 +89110,21 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - /*@internal*/ - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -85324,7 +89147,7 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; @@ -85332,14 +89155,14 @@ var ts; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 289 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -85349,9 +89172,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -85392,11 +89213,13 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : @@ -85407,43 +89230,73 @@ var ts; outputFileName : undefined; } + function createAddOutput() { + var outputs; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } /*@internal*/ function getAllProjectOutputs(configFile, ignoreCase) { - var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) - continue; - if (configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; /*@internal*/ function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { @@ -85457,8 +89310,13 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + continue; + if (ts.getEmitDeclarations(configFile.options)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); @@ -85466,7 +89324,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -85480,7 +89338,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -85576,17 +89434,16 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !declarationFilePath) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; // Setup and perform the transformation to retrieve declarations from the input files - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -85618,7 +89475,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -85626,12 +89483,8 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { - // Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule. - // But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow. - // Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the - // tslint directive can be all be removed. - var sourceFile = declarationTransform.transformed[0]; // tslint:disable-line + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288 /* SourceFile */) { + var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } @@ -85641,7 +89494,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -85653,8 +89506,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -85695,7 +89548,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 288 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -85802,10 +89655,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(288 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -85817,7 +89671,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(225 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -85856,7 +89710,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -85910,6 +89764,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers)); @@ -85962,6 +89817,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -85990,9 +89847,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 288 /* SourceFile */: return printFile(node); + case 289 /* Bundle */: return printBundle(node); + case 290 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86161,8 +90018,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -86174,7 +90030,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86190,6 +90046,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { @@ -86199,21 +90057,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(4 /* Unspecified */, node); + var substitute = pipelineEmit(4 /* Unspecified */, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(2 /* IdentifierName */, node); + return pipelineEmit(2 /* IdentifierName */, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1 /* Expression */, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(1 /* Expression */, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -86228,12 +90097,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 288 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -86247,10 +90116,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -86270,279 +90142,279 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 290 /* UnparsedSource */: + case 284 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 283 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 287 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 156 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 293 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 294 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + case 299 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 222 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 223 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 267 /* JsxClosingElement */: + case 270 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 304 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 299 /* JSDocSignature */: + case 303 /* JSDocSignature */: return emitJSDocSignature(node); - case 298 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 303 /* JSDocClassTag */: - case 300 /* JSDocTag */: + case 307 /* JSDocClassTag */: + case 304 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 297 /* JSDocComment */: + case 301 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -86560,83 +90432,83 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Reserved words - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 103 /* TrueKeyword */: - case 101 /* ThisKeyword */: - case 93 /* ImportKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 105 /* TrueKeyword */: + case 103 /* ThisKeyword */: + case 95 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return emitCommaList(node); } } @@ -86649,8 +90521,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -86664,8 +90539,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -86676,7 +90551,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 289 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -86685,12 +90560,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -86776,7 +90651,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -86809,7 +90684,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -86845,7 +90720,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 298 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -86907,7 +90782,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 162 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -86948,11 +90823,17 @@ var ts; // Types // function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -87084,18 +90965,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); - pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* QuestionToken */) { writePunctuation("?"); } } @@ -87175,66 +91055,57 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, - /*stopAfterLineBreak*/ false, - /*stopAtComments*/ true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { - var dotToken = ts.createToken(24 /* DotToken */); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(96 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(98 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -87274,22 +91145,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(84 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(107 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(126 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -87314,9 +91185,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* 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 */))); + return operand.kind === 206 /* PrefixUnaryExpression */ + && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) + || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -87329,7 +91200,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); @@ -87357,7 +91228,7 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(118 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(120 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -87434,7 +91305,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87442,8 +91313,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + emitTokenWithComment(86 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -87453,14 +91324,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(85 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -87469,14 +91340,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -87488,25 +91359,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -87514,7 +91385,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { emit(node); } else { @@ -87523,12 +91394,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(76 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -87556,12 +91427,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(100 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87569,7 +91440,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87579,17 +91450,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -87598,13 +91469,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(82 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -87629,7 +91500,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -87801,7 +91672,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512 /* GlobalAugmentation */) { + if (~node.flags & 1024 /* GlobalAugmentation */) { writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); writeSpace(); } @@ -87809,7 +91680,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 248 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -87830,17 +91701,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -87849,12 +91720,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -87869,9 +91740,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -87882,42 +91753,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(81 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(83 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -87937,7 +91808,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -88015,7 +91886,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88026,13 +91897,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(75 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(77 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -88044,12 +91915,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -88060,7 +91931,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -88130,7 +92001,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88164,7 +92035,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88183,7 +92054,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -88317,8 +92188,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_20 = types; _d < types_20.length; _d++) { + var directive = types_20[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -88498,7 +92369,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -88536,8 +92407,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmbeddedStatement */, node); } else { emit(node); @@ -88944,6 +92814,9 @@ var ts; return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -88961,7 +92834,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89026,81 +92899,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 237 /* LabeledStatement */: + case 235 /* WithStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89109,12 +92982,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -89172,7 +93045,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { return false; } } @@ -89294,25 +93167,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 258 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -89355,11 +93228,12 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 318 /* 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 */; @@ -89383,7 +93257,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -89413,6 +93287,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -89626,6 +93501,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -89640,7 +93516,7 @@ var ts; 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 !== 314 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -89653,12 +93529,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -90021,6 +93898,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -90376,7 +94256,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -90565,8 +94445,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -90579,6 +94459,8 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + /* @internal */ + ts.inferredTypesContainingFile = "__inferred type names__.ts"; /** * Determines if program structure is upto date or needs to be recreated */ @@ -90653,7 +94535,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -90683,15 +94565,17 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -90727,7 +94611,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).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; @@ -90744,7 +94628,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 @@ -90773,8 +94657,13 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks + // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -90782,20 +94671,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } } } @@ -90808,7 +94713,7 @@ var ts; 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(); - var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -90844,8 +94749,8 @@ var ts; // not part of the new program. if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || // old file wasnt redirect but new file is @@ -90861,12 +94766,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -90903,7 +94809,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -90930,9 +94838,14 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + // source file is allowed to be emitted and its not source of project reference redirect + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -91136,6 +95049,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; @@ -91226,7 +95145,7 @@ var ts; // moduleAugmentations has changed oldProgram.structureIsReused = 1 /* SafeModules */; } - if ((oldSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) { // dynamicImport has changed oldProgram.structureIsReused = 1 /* SafeModules */; } @@ -91263,28 +95182,26 @@ var ts; 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 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) { - oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + 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) { + oldProgram.structureIsReused = 1 /* SafeModules */; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } 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, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutions_1 = 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) { + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -91298,11 +95215,19 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping 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 (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined); + } + } // Set the file as found during node modules search if it was found that way in old progra, if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); @@ -91320,9 +95245,10 @@ var ts; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -91331,7 +95257,7 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -91387,15 +95313,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -91403,7 +95329,7 @@ var ts; // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); } @@ -91427,7 +95353,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -91502,15 +95429,16 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || - sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || + sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -91569,22 +95497,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 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 241 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -91592,41 +95520,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 110 /* ImplementsKeyword */) { + if (heritageClause.token === 112 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -91639,51 +95567,52 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* 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 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 224 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 158 /* 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 !== 117 /* StaticKeyword */) { + if (modifier.kind !== 119 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152 /* Parameter */: + case 155 /* 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 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 197 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -91700,24 +95629,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 126 /* DeclareKeyword */: - case 119 /* AbstractKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 129 /* DeclareKeyword */: + case 121 /* 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 117 /* StaticKeyword */: - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 119 /* StaticKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: } } } @@ -91792,8 +95721,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 /* Identifier */ - ? b.kind === 73 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 75 /* Identifier */ + ? b.kind === 75 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -91823,7 +95752,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -91874,7 +95803,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -91955,24 +95884,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -91995,15 +95918,26 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); + var file_2 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected - if (file_1 && options.forceConsistentCasingInFileNames) { + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -92012,34 +95946,35 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } // See if we need to reprocess the imports due to prior skipped imports - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -92057,14 +95992,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92095,7 +96023,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92118,8 +96046,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92134,8 +96072,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts or any of the non ts files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + // Ignore dts + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -92174,6 +96112,35 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + // Dont know which source file it means so return true? + var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); @@ -92208,9 +96175,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -92226,10 +96201,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -92241,7 +96222,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -92251,8 +96232,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -92260,14 +96240,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -92285,20 +96265,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -92338,14 +96318,22 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152 /* JSDoc */)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -92364,12 +96352,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -92426,9 +96417,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -92463,17 +96451,18 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -92589,8 +96578,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -92655,8 +96644,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -92683,7 +96705,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -92758,7 +96780,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -92817,6 +96839,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; /* @internal */ @@ -92862,9 +96890,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } /* @internal */ /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. @@ -92914,9 +96939,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93162,11 +97187,19 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, + /*emitOnlyDtsFiles*/ true, cancellationToken, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); + var firstDts_1 = emitOutput_1.outputFiles && + programOfThisState.getCompilerOptions().declarationMap ? + emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : + emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + if (firstDts_1) { + ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + latestSignature = computeHash(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -93269,6 +97302,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; /** * For script files that contains only ambient external modules, although they are not actually external module files, * they can only be consumed via importing elements from them. Regular script files cannot consume them. Therefore, @@ -93372,6 +97406,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -93385,8 +97424,7 @@ var ts; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them - // With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -93409,7 +97447,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -93455,7 +97494,7 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -93464,7 +97503,7 @@ var ts; function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -93483,7 +97522,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } /** * Releases program and other related not needed properties @@ -93509,7 +97548,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -93541,7 +97581,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } // Remove the changed file from the change set @@ -93587,13 +97626,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -93612,7 +97656,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -93637,7 +97681,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -93655,14 +97699,39 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } /** * Iterate on referencing modules that export entities from affected file */ function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { + return; + } + if (!isChangedSignagure(state, affectedFile.path)) return; + // Since isolated modules dont change js files, files affected by change in signature is itself + // But we need to cleanup semantic diagnostics and queue dts emit for affected files + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); @@ -93731,7 +97800,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -93741,6 +97810,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -93752,8 +97824,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + /** + * Returns the result with affected file + */ + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -93783,7 +97862,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -93878,7 +97957,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -93976,22 +98055,24 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94004,10 +98085,10 @@ var ts; affected = program; } } - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94063,7 +98144,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94095,7 +98176,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94107,8 +98188,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94144,7 +98231,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true }; return { @@ -94270,15 +98357,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -94443,8 +98542,8 @@ var ts; !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]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && @@ -94524,7 +98623,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -94735,6 +98834,10 @@ var ts; // Mark the file as needing re-evaluation of module resolution instead of using it blindly. resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + // When its a file with inferred types resolution, invalidate type reference directive resolution + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -94920,8 +99023,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -94937,20 +99041,26 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // Returns an import for each symlink and for the realpath. + /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) { var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); if (ambient) return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -94966,7 +99076,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0 /* Relative */) { return relativePath; @@ -95002,38 +99112,12 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. - // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** * Looks for existing imports that use symlinks to this module. @@ -95041,10 +99125,12 @@ var ts; */ function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -95061,7 +99147,31 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + // Sort by paths closest to importing file Name directory + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -95092,16 +99202,18 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -95110,24 +99222,27 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } // Simplify the full file path to something that can be resolved by Node. // If the module could be imported by a directory name, use that directory's name - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) @@ -95322,6 +99437,15 @@ var ts; ? newLine + newLine : newLine; } + /** + * Get locale specific time based on whether we are in test mode + */ + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -95329,7 +99453,7 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -95338,7 +99462,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -95531,7 +99655,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -95545,7 +99669,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -95579,7 +99705,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -95628,7 +99754,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -95721,7 +99847,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -95749,10 +99875,22 @@ 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, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -95978,13 +100116,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -96168,12 +100312,22 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -96329,11 +100483,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -96342,8 +100499,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -96363,12 +100519,35 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + // Clear all to ResolvedConfigFilePaths cache to start fresh + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + // Config file cache + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + // Remove watches for the program no longer in the solution + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -96376,6 +100555,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -96392,7 +100572,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -96447,7 +100627,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -96619,7 +100799,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -96787,6 +100967,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -96843,8 +101025,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97015,10 +101200,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97077,7 +101264,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -97242,16 +101429,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -97394,8 +101587,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -97427,6 +101620,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -97437,7 +101631,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -97445,7 +101639,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -97463,23 +101657,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -97512,13 +101716,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -97540,7 +101747,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -97928,6 +102134,15 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ + var PackageJsonDependencyGroup; + (function (PackageJsonDependencyGroup) { + PackageJsonDependencyGroup[PackageJsonDependencyGroup["Dependencies"] = 1] = "Dependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["DevDependencies"] = 2] = "DevDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["PeerDependencies"] = 4] = "PeerDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["OptionalDependencies"] = 8] = "OptionalDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["All"] = 15] = "All"; + })(PackageJsonDependencyGroup = ts.PackageJsonDependencyGroup || (ts.PackageJsonDependencyGroup = {})); + /* @internal */ ts.emptyOptions = {}; var HighlightSpanKind; (function (HighlightSpanKind) { @@ -97942,6 +102157,12 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = ts.SemicolonPreference || (ts.SemicolonPreference = {})); function getDefaultFormatCodeSettings(newLineCharacter) { return { indentSize: 4, @@ -97963,6 +102184,7 @@ var ts; insertSpaceBeforeFunctionParenthesis: false, placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, + semicolons: SemicolonPreference.Ignore, }; } ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; @@ -98192,37 +102414,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 278 /* CatchClause */: + case 271 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 154 /* TypeParameter */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 172 /* TypeLiteral */: return 2 /* Type */; - case 311 /* JSDocTypedefTag */: + case 315 /* 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 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 282 /* EnumMember */: + case 244 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -98232,26 +102454,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 247 /* EnumDeclaration */: + case 256 /* NamedImports */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 258 /* ExportAssignment */ || node.parent.kind === 263 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -98283,11 +102505,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 152 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 252 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -98299,27 +102521,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 152 /* QualifiedName */) { + while (root.parent && root.parent.kind === 152 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 168 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 193 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 193 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 215 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 277 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 244 /* ClassDeclaration */ && root.parent.parent.token === 112 /* ImplementsKeyword */) || + (decl.kind === 245 /* InterfaceDeclaration */ && root.parent.parent.token === 89 /* ExtendsKeyword */); } return false; } @@ -98328,17 +102550,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return true; - case 184 /* ImportType */: + case 187 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -98365,7 +102587,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 237 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -98381,11 +102603,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 73 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 73 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -98397,40 +102619,40 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 248 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 73 /* Identifier */ && + return node.kind === 75 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 282 /* EnumMember */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 248 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 186 /* LiteralType */: + return node.parent.parent.kind === 184 /* IndexedAccessType */; default: return false; } @@ -98454,17 +102676,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return node; } } @@ -98472,48 +102694,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 245 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 246 /* TypeAliasDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 247 /* EnumDeclaration */: return "enum" /* enumElement */; + case 241 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 162 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 163 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 279 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 166 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 165 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 164 /* CallSignature */: return "call" /* callSignatureElement */; + case 161 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 154 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 282 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 155 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -98540,7 +102767,7 @@ var ts; return "" /* unknown */; } } - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -98556,12 +102783,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 155 /* Parameter */; default: return false; } @@ -98626,42 +102853,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 172 /* TypeLiteral */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 250 /* CaseBlock */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 196 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 195 /* CallExpression */: + case 199 /* ParenthesizedExpression */: + case 181 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 201 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -98671,65 +102898,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 191 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 194 /* ElementAccessExpression */: + case 153 /* ComputedPropertyName */: + case 174 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 110 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 203 /* TypeOfExpression */: + case 202 /* DeleteExpression */: + case 204 /* VoidExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -98861,7 +103088,7 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - return ts.firstDefined(n.getChildren(), function (child) { + return ts.firstDefined(n.getChildren(sourceFile), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -98908,7 +103135,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 288 /* 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. @@ -98974,21 +103201,21 @@ var ts; return true; } //
Hello |
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 267 /* JsxClosingElement */) { return true; } return false; @@ -99010,7 +103237,7 @@ var ts; 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)) { + if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -99037,6 +103264,12 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; + function removeOptionality(type, isOptionalExpression, isOptionalChain) { + return isOptionalExpression ? type.getNonNullableType() : + isOptionalChain ? type.getNonOptionalType() : + type; + } + ts.removeOptionality = removeOptionality; function isPossiblyTypeArgumentPosition(token, sourceFile, checker) { var info = getPossibleTypeArgumentsInfo(token, sourceFile); return info !== undefined && (ts.isPartOfTypeNode(info.called) || @@ -99046,6 +103279,9 @@ var ts; ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; function getPossibleGenericSignatures(called, typeArgumentCount, checker) { var type = checker.getTypeAtLocation(called); + if (ts.isOptionalChain(called.parent)) { + type = removeOptionality(type, !!called.parent.questionDotToken, /*isOptionalChain*/ true); + } var signatures = ts.isNewExpression(called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); return signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= typeArgumentCount; }); } @@ -99062,9 +103298,12 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); + if (token && token.kind === 28 /* QuestionDotToken */) { + token = findPrecedingToken(token.getFullStart(), sourceFile); + } if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { @@ -99072,13 +103311,13 @@ var ts; } remainingLessThanTokens--; break; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: remainingLessThanTokens++; break; case 19 /* CloseBraceToken */: @@ -99106,20 +103345,22 @@ var ts; case 27 /* CommaToken */: nTypeArguments++; break; - case 37 /* EqualsGreaterThanToken */: - case 73 /* Identifier */: + case 38 /* EqualsGreaterThanToken */: + // falls through + case 75 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 105 /* TypeOfKeyword */: - case 87 /* ExtendsKeyword */: - case 130 /* KeyOfKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + // falls through + case 107 /* TypeOfKeyword */: + case 89 /* ExtendsKeyword */: + case 133 /* KeyOfKeyword */: case 24 /* DotToken */: - case 50 /* BarToken */: - case 56 /* QuestionToken */: - case 57 /* ColonToken */: + case 51 /* BarToken */: + case 57 /* QuestionToken */: + case 58 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -99168,16 +103409,16 @@ var ts; result.push("abstract" /* abstractModifier */); if (flags & 1 /* Export */) result.push("export" /* exportedModifier */); - if (node.flags & 4194304 /* Ambient */) + if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 168 /* TypeReference */ || node.kind === 195 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 244 /* ClassDeclaration */ || node.kind === 245 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -99197,7 +103438,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 72 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 74 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -99207,9 +103448,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: return true; } return false; @@ -99222,18 +103463,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 191 /* ArrayLiteralExpression */ || + node.kind === 192 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 208 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 60 /* EqualsToken */) { + node.parent.operatorToken.kind === 62 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 231 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -99241,7 +103482,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 279 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -99285,23 +103526,23 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 121 /* AnyKeyword */, - 147 /* BigIntKeyword */, - 124 /* BooleanKeyword */, - 88 /* FalseKeyword */, - 130 /* KeyOfKeyword */, - 133 /* NeverKeyword */, - 97 /* NullKeyword */, - 136 /* NumberKeyword */, - 137 /* ObjectKeyword */, - 134 /* ReadonlyKeyword */, - 139 /* StringKeyword */, - 140 /* SymbolKeyword */, - 103 /* TrueKeyword */, - 107 /* VoidKeyword */, - 142 /* UndefinedKeyword */, - 143 /* UniqueKeyword */, - 144 /* UnknownKeyword */, + 124 /* AnyKeyword */, + 150 /* BigIntKeyword */, + 127 /* BooleanKeyword */, + 90 /* FalseKeyword */, + 133 /* KeyOfKeyword */, + 136 /* NeverKeyword */, + 99 /* NullKeyword */, + 139 /* NumberKeyword */, + 140 /* ObjectKeyword */, + 137 /* ReadonlyKeyword */, + 142 /* StringKeyword */, + 143 /* SymbolKeyword */, + 105 /* TrueKeyword */, + 109 /* VoidKeyword */, + 145 /* UndefinedKeyword */, + 146 /* UniqueKeyword */, + 147 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -99337,7 +103578,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 153 /* 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); @@ -99413,7 +103654,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 73 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 75 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -99502,7 +103743,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 155 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -99543,6 +103784,8 @@ var ts; getColumn: function () { return 0; }, getLine: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingWhitespace: function () { return false; }, + hasTrailingComment: function () { return false; }, rawWrite: ts.notImplemented, getIndent: function () { return indent; }, increaseIndent: function () { indent++; }, @@ -99964,15 +104207,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 208 /* 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 272 /* CaseClause */: + case 275 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -100000,10 +104243,10 @@ var ts; ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: return true; default: return false; @@ -100014,8 +104257,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: return true; default: return false; @@ -100036,7 +104279,6 @@ var ts; 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, @@ -100054,28 +104296,90 @@ var ts; return typeIsAccessible ? res : undefined; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; - function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; - } - ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; + function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { + return kind === 164 /* CallSignature */ + || kind === 165 /* ConstructSignature */ + || kind === 166 /* IndexSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */; + } + ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; + function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { + return kind === 243 /* FunctionDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; + } + ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; + function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { + return kind === 248 /* ModuleDeclaration */; + } + ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; + function syntaxRequiresTrailingSemicolonOrASI(kind) { + return kind === 224 /* VariableStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 227 /* DoStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 233 /* BreakStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 158 /* PropertyDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 258 /* ExportAssignment */; + } + ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; + ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); + function isASICandidate(node, sourceFile) { + var lastToken = node.getLastToken(sourceFile); + if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + return false; + } + if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { + if (lastToken && lastToken.kind === 27 /* CommaToken */) { + return false; + } + } + else if (syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isModuleBlock(lastChild)) { + return false; + } + } + else if (syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isFunctionBlock(lastChild)) { + return false; + } + } + else if (!syntaxRequiresTrailingSemicolonOrASI(node.kind)) { + return false; + } + // See comment in parser’s `parseDoStatement` + if (node.kind === 227 /* DoStatement */) { + return true; + } + var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); + var nextToken = ts.findNextToken(node, topNode, sourceFile); + if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + return true; + } + var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(nextToken.getStart(sourceFile)).line; + return startLine !== endLine; + } + ts.isASICandidate = isASICandidate; function probablyUsesSemicolons(sourceFile) { var withSemicolon = 0; var withoutSemicolon = 0; var nStatementsToObserve = 5; ts.forEachChild(sourceFile, function visit(node) { - if (syntaxUsuallyHasTrailingSemicolon(node.kind)) { + if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { withSemicolon++; @@ -100098,9 +104402,154 @@ var ts; return withSemicolon / withoutSemicolon > 1 / nStatementsToObserve; } ts.probablyUsesSemicolons = probablyUsesSemicolons; + function tryGetDirectories(host, directoryName) { + return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || []; + } + ts.tryGetDirectories = tryGetDirectories; + function tryReadDirectory(host, path, extensions, exclude, include) { + return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include) || ts.emptyArray; + } + ts.tryReadDirectory = tryReadDirectory; + function tryFileExists(host, path) { + return tryIOAndConsumeErrors(host, host.fileExists, path); + } + ts.tryFileExists = tryFileExists; + function tryDirectoryExists(host, path) { + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; + } + ts.tryDirectoryExists = tryDirectoryExists; + function tryAndIgnoreErrors(cb) { + try { + return cb(); + } + catch (_a) { + return undefined; + } + } + ts.tryAndIgnoreErrors = tryAndIgnoreErrors; + 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); }); + } + ts.tryIOAndConsumeErrors = tryIOAndConsumeErrors; + function findPackageJsons(startDirectory, host, stopDirectory) { + var paths = []; + ts.forEachAncestorDirectory(startDirectory, function (ancestor) { + if (ancestor === stopDirectory) { + return true; + } + var currentConfigPath = ts.combinePaths(ancestor, "package.json"); + if (tryFileExists(host, currentConfigPath)) { + paths.push(currentConfigPath); + } + }); + return paths; + } + ts.findPackageJsons = findPackageJsons; + function findPackageJson(directory, host) { + var packageJson; + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (ancestor === "node_modules") + return true; + packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); + if (packageJson) { + return true; // break out + } + }); + return packageJson; + } + ts.findPackageJson = findPackageJson; + function getPackageJsonsVisibleToFile(fileName, host) { + if (!host.fileExists) { + return []; + } + var packageJsons = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(fileName), function (ancestor) { + var packageJsonFileName = ts.combinePaths(ancestor, "package.json"); + if (host.fileExists(packageJsonFileName)) { + var info = createPackageJsonInfo(packageJsonFileName, host); + if (info) { + packageJsons.push(info); + } + } + }); + return packageJsons; + } + ts.getPackageJsonsVisibleToFile = getPackageJsonsVisibleToFile; + function createPackageJsonInfo(fileName, host) { + if (!host.readFile) { + return undefined; + } + var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]; + var stringContent = host.readFile(fileName); + var content = stringContent && tryParseJson(stringContent); + if (!content) { + return undefined; + } + var info = {}; + for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) { + var key = dependencyKeys_1[_i]; + var dependencies = content[key]; + if (!dependencies) { + continue; + } + var dependencyMap = ts.createMap(); + for (var packageName in dependencies) { + dependencyMap.set(packageName, dependencies[packageName]); + } + info[key] = dependencyMap; + } + var dependencyGroups = [ + [1 /* Dependencies */, info.dependencies], + [2 /* DevDependencies */, info.devDependencies], + [8 /* OptionalDependencies */, info.optionalDependencies], + [4 /* PeerDependencies */, info.peerDependencies], + ]; + return __assign(__assign({}, info), { fileName: fileName, + get: get, + has: function (dependencyName, inGroups) { + return !!get(dependencyName, inGroups); + } }); + function get(dependencyName, inGroups) { + if (inGroups === void 0) { inGroups = 15 /* All */; } + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; + if (deps && (inGroups & group_1)) { + var dep = deps.get(dependencyName); + if (dep !== undefined) { + return dep; + } + } + } + } + } + ts.createPackageJsonInfo = createPackageJsonInfo; + function tryParseJson(text) { + try { + return JSON.parse(text); + } + catch (_a) { + return undefined; + } + } + function consumesNodeCoreModules(sourceFile) { + return ts.some(sourceFile.imports, function (_a) { + var text = _a.text; + return ts.JsTyping.nodeCoreModules.has(text); + }); + } + ts.consumesNodeCoreModules = consumesNodeCoreModules; + function isInsideNodeModules(fileOrDirectory) { + return ts.contains(ts.getPathComponents(fileOrDirectory), "node_modules"); + } + ts.isInsideNodeModules = isInsideNodeModules; })(ts || (ts = {})); var ts; (function (ts) { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { @@ -100178,36 +104627,36 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; - case 28 /* LessThanToken */: - if (lastNonTriviaToken === 73 /* Identifier */) { + case 29 /* LessThanToken */: + if (lastNonTriviaToken === 75 /* 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 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 121 /* AnyKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: + case 124 /* AnyKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* 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 = 73 /* Identifier */; + token = 75 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -100246,14 +104695,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 73 /* Identifier */; + token = 75 /* 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 = 73 /* Identifier */; + token = 75 /* Identifier */; } } } @@ -100267,19 +104716,19 @@ 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([ - 73 /* Identifier */, + 75 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 101 /* ThisKeyword */, - 44 /* PlusPlusToken */, - 45 /* MinusMinusToken */, + 103 /* ThisKeyword */, + 45 /* PlusPlusToken */, + 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 103 /* TrueKeyword */, - 88 /* FalseKeyword */, + 105 /* TrueKeyword */, + 90 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -100391,10 +104840,10 @@ var ts; return true; } switch (keyword2) { - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 125 /* ConstructorKeyword */: - case 117 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 128 /* ConstructorKeyword */: + case 119 /* 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. @@ -100427,43 +104876,44 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - 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 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* 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 71 /* BarEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 60 /* EqualsToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 50 /* AmpersandToken */: + case 52 /* CaretToken */: + case 51 /* BarToken */: + case 55 /* AmpersandAmpersandToken */: + case 56 /* BarBarToken */: + case 73 /* BarEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: + case 60 /* QuestionQuestionToken */: return true; default: return false; @@ -100471,12 +104921,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: return true; default: return false; @@ -100489,7 +104939,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 72 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 74 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -100508,7 +104958,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 73 /* Identifier */: + case 75 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -100533,10 +104983,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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -100729,6 +105179,11 @@ var ts; return; } } + else if (kind === 2 /* SingleLineCommentTrivia */) { + if (tryClassifyTripleSlashComment(start, width)) { + return; + } + } // Simple comment. Just add as is. pushCommentRange(start, width); } @@ -100749,18 +105204,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 306 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 307 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -100789,6 +105244,70 @@ var ts; } } } + function tryClassifyTripleSlashComment(start, width) { + var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; + var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + var text = sourceFile.text.substr(start, width); + var match = tripleSlashXMLCommentRegEx.exec(text); + if (!match) { + return false; + } + // Limiting classification to exactly the elements and attributes + // defined in `ts.commentPragmas` would be excessive, but we can avoid + // some obvious false positives (e.g. in XML-like doc comments) by + // checking the element name. + // eslint-disable-next-line no-in-operator + if (!match[3] || !(match[3] in ts.commentPragmas)) { + return false; + } + var pos = start; + pushCommentRange(pos, match[1].length); // /// + pos += match[1].length; + pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pos += match[2].length; + pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pos += match[3].length; + var attrText = match[4]; + var attrPos = pos; + while (true) { + var attrMatch = attributeRegex.exec(attrText); + if (!attrMatch) { + break; + } + var newAttrPos = pos + attrMatch.index; + if (newAttrPos > attrPos) { + pushCommentRange(attrPos, newAttrPos - attrPos); + attrPos = newAttrPos; + } + pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[1].length; + if (attrMatch[2].length) { + pushCommentRange(attrPos, attrMatch[2].length); // whitespace + attrPos += attrMatch[2].length; + } + pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = + attrPos += attrMatch[3].length; + if (attrMatch[4].length) { + pushCommentRange(attrPos, attrMatch[4].length); // whitespace + attrPos += attrMatch[4].length; + } + pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[5].length; + } + pos += match[4].length; + if (pos > attrPos) { + pushCommentRange(attrPos, pos - attrPos); + } + if (match[5]) { + pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pos += match[5].length; + } + var end = start + width; + if (pos < end) { + pushCommentRange(pos, end - pos); + } + return true; + } function processJSDocTemplateTag(tag) { for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; @@ -100847,22 +105366,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -100879,7 +105398,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* GreaterThanToken */) { + if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* 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)) { @@ -100889,19 +105408,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 60 /* EqualsToken */) { + if (tokenKind === 62 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 241 /* VariableDeclaration */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 155 /* Parameter */ || + parent.kind === 271 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 208 /* BinaryExpression */ || + parent.kind === 206 /* PrefixUnaryExpression */ || + parent.kind === 207 /* PostfixUnaryExpression */ || + parent.kind === 209 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -100915,7 +105434,7 @@ var ts; } else if (tokenKind === 10 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 271 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -100928,35 +105447,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 73 /* Identifier */) { + else if (tokenKind === 75 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 155 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -101079,11 +105598,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -101091,9 +105610,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 187 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 177 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -101103,7 +105622,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -101120,7 +105639,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -101133,8 +105652,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* 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 @@ -101143,9 +105662,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 263 /* 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*/"); @@ -101189,11 +105708,8 @@ var ts; 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; + 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 }; @@ -101250,7 +105766,7 @@ var ts; return ts.containsPath(rootDirectory, scriptDirectory, basePath, ignoreCase) ? scriptDirectory.substr(rootDirectory.length) : undefined; }); // TODO: GH#18217 // 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); }).concat([scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); + return ts.deduplicate(__spreadArrays(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), [scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); @@ -101283,10 +105799,10 @@ 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)) + if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { /** * Multiple file entries might map to the same truncated name once we remove extensions @@ -101309,7 +105825,7 @@ var ts; }); } // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); + var directories = ts.tryGetDirectories(host, baseDirectory); if (directories) { for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var directory = directories_1[_b]; @@ -101320,7 +105836,7 @@ var ts; } } // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); + var packageJsonPath = ts.findPackageJson(baseDirectory, host); if (packageJsonPath) { var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; @@ -101398,7 +105914,7 @@ var ts; if (!foundGlobal) { ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); - if (tryDirectoryExists(host, nodeModules)) { + if (ts.tryDirectoryExists(host, nodeModules)) { getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); @@ -101448,16 +105964,16 @@ 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 = ts.mapDefined(tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); }); - var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var directories = ts.mapDefined(ts.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); + return __spreadArrays(matches, directories); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); @@ -101505,22 +106021,22 @@ var ts; if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + var typeRoots = ts.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); } // Also get all @types typings installed in visible node_modules directories - for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + for (var _a = 0, _b = ts.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) { - if (!tryDirectoryExists(host, directory)) + if (!ts.tryDirectoryExists(host, directory)) return; - for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.tryGetDirectories(host, directory); _i < _a.length; _i++) { var typeDirectoryName = _a[_i]; var packageName = ts.unmangleScopedPackageName(typeDirectoryName); if (options.types && !ts.contains(options.types, packageName)) @@ -101541,34 +106057,11 @@ var ts; } } } - function findPackageJsons(directory, host) { - var paths = []; - ts.forEachAncestorDirectory(directory, function (ancestor) { - var currentConfigPath = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (!currentConfigPath) { - return true; // break out - } - paths.push(currentConfigPath); - }); - return paths; - } - function findPackageJson(directory, host) { - var packageJson; - ts.forEachAncestorDirectory(directory, function (ancestor) { - if (ancestor === "node_modules") - return true; - packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (packageJson) { - return true; // break out - } - }); - return packageJson; - } function enumerateNodeModulesVisibleToScript(host, scriptPath) { if (!host.readFile || !host.fileExists) return ts.emptyArray; var result = []; - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.findPackageJsons(scriptPath, host); _i < _a.length; _i++) { var packageJson = _a[_i]; var contents = ts.readJson(packageJson, host); // Cast to assert that readFile is defined // Provide completions for all non @types dependencies @@ -101617,33 +106110,6 @@ var ts; */ var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*" 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, 30 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -101816,14 +106341,25 @@ var ts; function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { var insertText; var replacementSpan; - if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; + var insertQuestionDot = origin && originIsNullableMember(origin); + var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; + if (origin && originIsThisType(origin)) { + insertText = needsConvertPropertyAccess + ? "this" + (insertQuestionDot ? "?." : "") + "[" + ts.quote(name, preferences) + "]" + : "this" + (insertQuestionDot ? "?." : ".") + 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 ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); + else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { + insertText = useBraces ? needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]" : name; + if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { + insertText = "?." + insertText; + } + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + if (!dot) { + return undefined; + } // 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); @@ -101836,6 +106372,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -101930,9 +106473,9 @@ var ts; } return entries; } - function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { + function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host) { var compilerOptions = program.getCompilerOptions(); - var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { return { type: "none" }; } @@ -101972,7 +106515,7 @@ var ts; 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); + var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); switch (symbolCompletion.type) { case "request": { var request = symbolCompletion.request; @@ -102028,8 +106571,8 @@ var ts; var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } - function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { - var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host) { + var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); return completion.type === "symbol" ? completion.symbol : undefined; } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; @@ -102062,34 +106605,34 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return checker.getContextualType(parent); - case 75 /* CaseKeyword */: + case 77 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 264 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.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); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -102099,9 +106642,9 @@ 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 === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 288 /* SourceFile */; }); } - function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 @@ -102150,11 +106693,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 312 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 316 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -102190,6 +106733,7 @@ var ts; var node = currentToken; var propertyAccessToConvert; var isRightOfDot = false; + var isRightOfQuestionDot = false; var isRightOfOpenTag = false; var isStartingCloseTag = false; var isJsxInitializer = false; @@ -102201,10 +106745,11 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */) { - isRightOfDot = true; + if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -102216,14 +106761,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 187 /* ImportType */: + case 218 /* MetaProperty */: node = parent; break; default: @@ -102236,56 +106781,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 === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 193 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + case 31 /* GreaterThanToken */: + if (currentToken.parent.kind === 264 /* JsxElement */ || currentToken.parent.kind === 266 /* JsxOpeningElement */) { location = currentToken; } break; - case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + case 43 /* SlashToken */: + if (currentToken.parent.kind === 265 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: - if (contextToken.kind === 42 /* SlashToken */) { + case 267 /* JsxClosingElement */: + if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: - if (contextToken.kind === 28 /* LessThanToken */) { + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: + case 266 /* JsxOpeningElement */: + if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: switch (previousToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: isJsxInitializer = true; break; - case 73 /* Identifier */: + case 75 /* 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, 60 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 62 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -102300,7 +106845,8 @@ var ts; var symbols = []; var symbolToOriginInfoMap = []; var symbolToSortTextMap = []; - if (isRightOfDot) { + var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { @@ -102350,11 +106896,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 311 /* JSDocTypedefTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 315 /* JSDocTypedefTag */: return true; default: return false; @@ -102398,24 +106944,40 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 288 /* SourceFile */ && d.kind !== 248 /* ModuleDeclaration */ && d.kind !== 247 /* EnumDeclaration */; })) { + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + insertQuestionDot = isRightOfDot && !isRightOfQuestionDot; + type = type.getNonNullableType(); + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 96 /* NewKeyword */ || node.keywordToken === 93 /* ImportKeyword */)) { - var completion = (node.keywordToken === 96 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 98 /* NewKeyword */ || node.keywordToken === 95 /* ImportKeyword */)) { + var completion = (node.keywordToken === 98 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + var type = typeChecker.getTypeAtLocation(node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + insertQuestionDot = isRightOfDot && !isRightOfQuestionDot; + type = type.getNonNullableType(); + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait, insertQuestionDot) { isNewIdentifierLocation = !!type.getStringIndexType(); + if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { + isNewIdentifierLocation = true; + } + var propertyAccess = node.kind === 187 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -102427,13 +106989,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { - addPropertySymbol(symbol); + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { + addPropertySymbol(symbol, /*insertAwait*/ false, insertQuestionDot); + } + } + } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true, insertQuestionDot); + } } } } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait, insertQuestionDot) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -102447,15 +107020,32 @@ var ts; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) + ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } + : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addSymbolOriginInfo(symbol); symbols.push(symbol); } + function addSymbolOriginInfo(symbol) { + if (preferences.includeCompletionsWithInsertText) { + if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + } + else if (insertQuestionDot) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + } + } + } + function getNullableSymbolOriginInfoKind(kind) { + return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -102488,6 +107078,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -102531,7 +107122,7 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); var isTypeOnly = isTypeOnlyCompletion(); - var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; @@ -102541,19 +107132,38 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 288 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ }; + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; } } } if (shouldOfferImportCompletions()) { - getSymbolsFromOtherSourceFileExports(symbols, previousToken && ts.isIdentifier(previousToken) ? previousToken.text : "", program.getCompilerOptions().target); + var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); + if (!detailsEntryId && importSuggestionsCache) { + importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); + } + autoImportSuggestions.forEach(function (_a) { + var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; + if (detailsEntryId) { + if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { + return; + } + } + else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { + return; + } + var symbolId = ts.getSymbolId(symbol); + symbols.push(symbol); + symbolToOriginInfoMap[symbolId] = origin; + symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; + }); } filterGlobalCompletion(symbols); } @@ -102575,10 +107185,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 210 /* TemplateExpression */: + case 274 /* JsxExpression */: + case 222 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -102608,7 +107218,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 67220415 /* Value */); + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); }); } function isTypeAssertion() { @@ -102623,28 +107233,28 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 107 /* TypeOfKeyword */ && + (contextToken.parent.kind === 171 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + case 58 /* ColonToken */: + return parentKind === 158 /* PropertyDeclaration */ || + parentKind === 157 /* PropertySignature */ || + parentKind === 155 /* Parameter */ || + parentKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; - case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; - case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; - case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + case 62 /* EqualsToken */: + return parentKind === 246 /* TypeAliasDeclaration */; + case 122 /* AsKeyword */: + return parentKind === 216 /* AsExpression */; + case 29 /* LessThanToken */: + return parentKind === 168 /* TypeReference */ || + parentKind === 198 /* TypeAssertionExpression */; + case 89 /* ExtendsKeyword */: + return parentKind === 154 /* TypeParameter */; } } return false; @@ -102653,15 +107263,76 @@ var ts; function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { if (seenModules === void 0) { seenModules = ts.createMap(); } var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 67897832 /* Type */) || + return !!(sym.flags & 788968 /* 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(); + /** + * Gathers symbols that can be imported from other files, deduplicating along the way. Symbols can be “duplicates” + * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but + * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, + * if and only if the the first can be imported (it may be excluded due to package.json filtering in + * `codefix.forEachExternalModuleToImportFrom`). + * + * Example. Imagine a chain of node_modules re-exporting one original symbol: + * + * ```js + * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js + * +-----------------------+ +--------------------------+ +--------------------------+ + * | | | | | | + * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | + * | | | | | | + * +-----------------------+ +--------------------------+ +--------------------------+ + * ``` + * + * Also imagine three buckets, which we’ll reference soon: + * + * ```md + * | | | | | | + * | **Bucket A** | | **Bucket B** | | **Bucket C** | + * | Symbols to | | Aliases to symbols | | Symbols to return | + * | definitely | | in Buckets A or C | | if nothing better | + * | return | | (don’t return these) | | comes along | + * |__________________| |______________________| |___________________| + * ``` + * + * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it + * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not + * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we + * may not be sure whether or not it should go in the list. So, we’ll take the following steps: + * + * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is + * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B + * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. + * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. + * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' + * should never be returned in the final list, so put it in Bucket B. + * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so + * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. + * Put this symbol in Bucket A. + * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t + * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move + * everything from Bucket C to Bucket A. + */ + function getSymbolsFromOtherSourceFileExports(target, host) { + var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); + if (cached) { + log("getSymbolsFromOtherSourceFileExports: Using cached list"); + return cached; + } + var startTime = ts.timestamp(); + log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); var seenResolvedModules = ts.createMap(); - ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + /** Bucket B */ + var aliasesToAlreadyIncludedSymbols = ts.createMap(); + /** Bucket C */ + var aliasesToReturnIfOriginalsAreMissing = ts.createMap(); + /** Bucket A */ + var results = []; + /** Ids present in `results` for faster lookup */ + var resultSymbolIds = ts.createMap(); + ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, function (moduleSymbol) { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; @@ -102671,41 +107342,75 @@ var ts; if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { return; } + // Don't add another completion for `export =` of a symbol that's already global. + // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. if (resolvedModuleSymbol !== moduleSymbol && - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { - symbols.push(resolvedModuleSymbol); - symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { + pushSymbol(resolvedModuleSymbol, moduleSymbol, /*skipFilter*/ true); } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; - // Don't add a completion for a re-export, only for the original. - // 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 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) { - // 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); - })) { + // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. + if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { continue; } - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + var symbolId = ts.getSymbolId(symbol).toString(); + // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. + var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; + // 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). + if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { + // Walk the export chain back one module (step 1 or 2 in diagrammed example). + // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. + var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); + if (!nearestExportSymbol) + continue; + var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); + var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); + if (!symbolHasBeenSeen) { + aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol }); + aliasesToAlreadyIncludedSymbols.set(symbolId, true); + } + else { + // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here + // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. + ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); + } } - var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; - if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) { - symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin; + else { + // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.delete(symbolId); + pushSymbol(symbol, moduleSymbol); } } }); + // By this point, any potential duplicates that were actually duplicates have been + // removed, so the rest need to be added. (Step 4 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { + var alias = _a.alias, moduleSymbol = _a.moduleSymbol; + return pushSymbol(alias, moduleSymbol); + }); + log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); + return results; + function pushSymbol(symbol, moduleSymbol, skipFilter) { + if (skipFilter === void 0) { skipFilter = false; } + var isDefaultExport = symbol.escapedName === "default" /* Default */; + if (isDefaultExport) { + symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + } + ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); + var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; + results.push({ + symbol: symbol, + symbolName: getSymbolName(symbol, origin, target), + origin: origin, + skipFilter: skipFilter, + }); + } + } + function getNearestExportSymbol(fromSymbol) { + return findAlias(typeChecker, fromSymbol, function (alias) { + return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); + }); } /** * True if you could remove some characters in `a` to get `b`. @@ -102752,12 +107457,12 @@ var ts; if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 266 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 267 /* JsxClosingElement */ || contextToken.parent.kind === 265 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 264 /* JsxElement */; } } return false; @@ -102768,40 +107473,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 195 /* CallExpression */ // func( a, | + || containingNodeKind === 161 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 196 /* NewExpression */ // new C(a, | + || containingNodeKind === 191 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 208 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 169 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 195 /* CallExpression */ // func( | + || containingNodeKind === 161 /* Constructor */ // constructor( | + || containingNodeKind === 196 /* NewExpression */ // new C(a| + || containingNodeKind === 199 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 181 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 131 /* ModuleKeyword */: // module | - case 132 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 191 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 166 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 153 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 134 /* ModuleKeyword */: // module | + case 135 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 248 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | - case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 244 /* ClassDeclaration */; // class A{ | + case 62 /* EqualsToken */: + return containingNodeKind === 241 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 208 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 210 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 220 /* TemplateSpan */; // `aa ${10} dd ${| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -102828,7 +107533,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 192 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; @@ -102837,7 +107542,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 188 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -102848,12 +107553,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 === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 231 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 155 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 160 /* MethodDeclaration */ || rootDeclaration.parent.kind === 163 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -102870,6 +107575,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -102895,7 +107601,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 256 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -102918,15 +107624,15 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 41 /* 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)) return 1 /* Success */; - var classElement = contextToken.parent; + var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : 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 === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 75 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -102961,9 +107667,9 @@ var ts; return parent; } break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 73 /* Identifier */: + case 75 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -103013,23 +107719,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 30 /* GreaterThanToken */: // End of a type argument list - case 29 /* LessThanSlashToken */: - case 42 /* SlashToken */: - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { - if (contextToken.kind === 30 /* GreaterThanToken */) { + case 31 /* GreaterThanToken */: // End of a type argument list + case 30 /* LessThanSlashToken */: + case 43 /* SlashToken */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 272 /* JsxAttributes */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 265 /* JsxSelfClosingElement */ || parent.kind === 266 /* JsxOpeningElement */)) { + if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) break; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103041,7 +107747,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 271 /* JsxAttribute */) || (parent.kind === 273 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103051,8 +107757,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 274 /* JsxExpression */ && + parent.parent && parent.parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103060,7 +107766,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 273 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103080,64 +107786,64 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 241 /* VariableDeclaration */ || + containingNodeKind === 242 /* VariableDeclarationList */ || + containingNodeKind === 224 /* VariableStatement */ || + containingNodeKind === 247 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| - case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [.| + case 58 /* ColonToken */: + return containingNodeKind === 190 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 278 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | - case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 247 /* EnumDeclaration */; // enum a { | + case 29 /* LessThanToken */: + return containingNodeKind === 244 /* ClassDeclaration */ || // class A< | + containingNodeKind === 213 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 245 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 246 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 119 /* StaticKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + return containingNodeKind === 155 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 189 /* ArrayBindingPattern */); // var [...z| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 155 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 122 /* AsKeyword */: + return containingNodeKind === 257 /* ImportSpecifier */ || + containingNodeKind === 261 /* ExportSpecifier */ || + containingNodeKind === 255 /* NamespaceImport */; + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 111 /* InterfaceKeyword */: - case 91 /* FunctionKeyword */: - case 106 /* VarKeyword */: - case 93 /* ImportKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 118 /* YieldKeyword */: - case 141 /* TypeKeyword */: // type htm| + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 113 /* InterfaceKeyword */: + case 93 /* FunctionKeyword */: + case 108 /* VarKeyword */: + case 95 /* ImportKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 120 /* YieldKeyword */: + case 144 /* TypeKeyword */: // type htm| return true; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -103158,22 +107864,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 119 /* AbstractKeyword */: - case 77 /* ClassKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 91 /* FunctionKeyword */: - case 111 /* InterfaceKeyword */: - case 112 /* LetKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 117 /* StaticKeyword */: - case 106 /* VarKeyword */: - case 118 /* YieldKeyword */: + case 121 /* AbstractKeyword */: + case 79 /* ClassKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 93 /* FunctionKeyword */: + case 113 /* InterfaceKeyword */: + case 114 /* LetKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 119 /* StaticKeyword */: + case 108 /* VarKeyword */: + case 120 /* YieldKeyword */: return true; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -103183,7 +107889,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 161 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -103202,16 +107908,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); 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 !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 279 /* PropertyAssignment */ && + m.kind !== 280 /* ShorthandPropertyAssignment */ && + m.kind !== 190 /* BindingElement */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */ && + m.kind !== 281 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103219,9 +107927,12 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 73 /* Identifier */) { + if (m.propertyName.kind === 75 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -103234,7 +107945,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -103246,10 +107990,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 !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 158 /* PropertyDeclaration */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103283,17 +108027,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 271 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -103304,7 +108054,7 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.startsWithQuote(name) + || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; @@ -103333,7 +108083,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 76 /* FirstKeyword */; i <= 151 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -103359,9 +108109,9 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 126 /* DeclareKeyword */ - || kind === 131 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 142 /* UndefinedKeyword */; + || kind === 129 /* DeclareKeyword */ + || kind === 134 /* ModuleKeyword */ + || ts.isTypeKeyword(kind) && kind !== 145 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -103371,7 +108121,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 78 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 80 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -103381,55 +108131,55 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 121 /* AnyKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 146 /* GlobalKeyword */: - case 110 /* ImplementsKeyword */: - case 128 /* InferKeyword */: - case 111 /* InterfaceKeyword */: - case 129 /* IsKeyword */: - case 130 /* KeyOfKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 133 /* NeverKeyword */: - case 136 /* NumberKeyword */: - case 137 /* ObjectKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: - case 139 /* StringKeyword */: - case 140 /* SymbolKeyword */: - case 141 /* TypeKeyword */: - case 143 /* UniqueKeyword */: - case 144 /* UnknownKeyword */: + case 121 /* AbstractKeyword */: + case 124 /* AnyKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 149 /* GlobalKeyword */: + case 112 /* ImplementsKeyword */: + case 131 /* InferKeyword */: + case 113 /* InterfaceKeyword */: + case 132 /* IsKeyword */: + case 133 /* KeyOfKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 136 /* NeverKeyword */: + case 139 /* NumberKeyword */: + case 140 /* ObjectKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: + case 142 /* StringKeyword */: + case 143 /* SymbolKeyword */: + case 144 /* TypeKeyword */: + case 146 /* UniqueKeyword */: + case 147 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 134 /* ReadonlyKeyword */; + return kind === 137 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 125 /* ConstructorKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 122 /* AsyncKeyword */: + case 121 /* AbstractKeyword */: + case 128 /* ConstructorKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 125 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 122 /* AsyncKeyword */ - || kind === 123 /* AwaitKeyword */ + return kind === 125 /* AsyncKeyword */ + || kind === 126 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -103467,7 +108217,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 313 /* SyntaxList */: + case 317 /* 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); @@ -103475,7 +108225,7 @@ var ts; return cls; } break; - case 73 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } + case 75 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } if (isFromObjectTypeDeclaration(location)) { return ts.findAncestor(location, ts.isObjectTypeDeclaration); } @@ -103501,7 +108251,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -103521,11 +108271,11 @@ var ts; return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -103534,6 +108284,14 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } + function findAlias(typeChecker, symbol, predicate) { + var currentAlias = symbol; + while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { + if (predicate(currentAlias)) { + return currentAlias; + } + } + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -103586,40 +108344,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 92 /* IfKeyword */: - case 84 /* ElseKeyword */: + case 94 /* IfKeyword */: + case 86 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 98 /* ReturnKeyword */: + case 100 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 104 /* TryKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: - var tryStatement = node.kind === 76 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 106 /* TryKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: + var tryStatement = node.kind === 78 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 75 /* CaseKeyword */: - case 81 /* DefaultKeyword */: + case 77 /* CaseKeyword */: + case 83 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 74 /* BreakKeyword */: - case 79 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 81 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 90 /* ForKeyword */: - case 108 /* WhileKeyword */: - case 83 /* DoKeyword */: + case 92 /* ForKeyword */: + case 110 /* WhileKeyword */: + case 85 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 125 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [125 /* ConstructorKeyword */]); - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [127 /* GetKeyword */, 138 /* SetKeyword */]); - case 123 /* AwaitKeyword */: + case 128 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [128 /* ConstructorKeyword */]); + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [130 /* GetKeyword */, 141 /* SetKeyword */]); + case 126 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 118 /* YieldKeyword */: + case 120 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -103662,7 +108420,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 288 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -103694,16 +108452,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 236 /* SwitchStatement */: + if (statement.kind === 232 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -103719,35 +108477,37 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 222 /* Block */: + case 275 /* CaseClause */: + case 276 /* 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]); + return __spreadArrays(declaration.members, [declaration]); } else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 172 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 28 /* AccessibilityModifier */) { + if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { - return nodes.concat(constructor.parameters); + return __spreadArrays(nodes, constructor.parameters); } } else if (modifierFlag & 128 /* Abstract */) { - return nodes.concat([container]); + return __spreadArrays(nodes, [container]); } return nodes; default: @@ -103767,12 +108527,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 92 /* ForKeyword */, 110 /* WhileKeyword */, 85 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 227 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 110 /* WhileKeyword */)) { break; } } @@ -103780,7 +108540,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */, 79 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */, 81 /* ContinueKeyword */); } }); return keywords; @@ -103789,13 +108549,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -103803,13 +108563,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 100 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 102 /* 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(), 75 /* CaseKeyword */, 81 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 77 /* CaseKeyword */, 83 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */); } }); }); @@ -103817,13 +108577,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 104 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 106 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 76 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 78 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 89 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 91 /* FinallyKeyword */); } return keywords; } @@ -103834,13 +108594,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* 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, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -103852,11 +108612,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* 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, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -103868,13 +108628,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 122 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 125 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 123 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 126 /* AwaitKeyword */); } }); }); @@ -103889,7 +108649,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 118 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 120 /* YieldKeyword */); } }); }); @@ -103908,7 +108668,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 === 84 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 86 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -103943,10 +108703,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], 92 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 94 /* 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], 84 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 86 /* ElseKeyword */)) { break; } } @@ -104162,12 +108922,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 241 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { directImports.push(name); break; } @@ -104176,22 +108936,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 73 /* Identifier */: // for 'const x = require("y"); + case 75 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 255 /* 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 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -104201,7 +108961,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 187 /* ImportType */: directImports.push(direct); break; default: @@ -104218,7 +108978,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 288 /* SourceFile */ || sourceFileLike.kind === 248 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -104273,17 +109033,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 252 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 73 /* Identifier */) { + if (decl.kind === 75 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 187 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -104298,17 +109058,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 259 /* 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 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -104358,7 +109118,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 261 /* 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); @@ -104387,7 +109147,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 === 285 /* SourceFile */) { + if (searchSourceFile.kind === 288 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -104435,7 +109195,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 === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 288 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -104450,15 +109210,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -104472,7 +109232,7 @@ var ts; /** * Given a local reference, we might notice that it's an import/export and recursively search for references of that. * If at an import, look locally for the symbol it imports. - * If an an export, look for all imports of it. + * If at an export, look for all imports of it. * This doesn't handle export specifiers; that is done in `getReferencesAtExportSpecifier`. * @param comingFromExport If we are doing a search for all exports, don't bother looking backwards for the imported symbol, since that's the reason we're here. */ @@ -104482,7 +109242,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 193 /* 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) @@ -104604,10 +109364,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 === 238 /* VariableDeclaration */) { - var p = parent; - return p.name !== node ? undefined : - p.parent.kind === 275 /* CatchClause */ ? undefined : p.parent.parent.kind === 220 /* VariableStatement */ ? p.parent.parent : undefined; + var declaration = ts.isVariableDeclaration(parent) ? parent : ts.isBindingElement(parent) ? ts.walkUpBindingElementsAndPatterns(parent) : undefined; + if (declaration) { + return parent.name !== node ? undefined : + ts.isCatchClause(declaration.parent) ? undefined : ts.isVariableStatement(declaration.parent.parent) ? declaration.parent.parent : undefined; } else { return parent; @@ -104616,13 +109376,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -104655,21 +109415,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 288 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 249 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 248 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 263 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -104718,7 +109478,7 @@ var ts; if (ts.isInJSFile(node)) { var binaryExpression = ts.isBinaryExpression(node.parent) ? node.parent : - ts.isPropertyAccessExpression(node.parent) && + ts.isAccessExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && node.parent.parent.left === node.parent ? node.parent.parent : @@ -104762,7 +109522,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 81 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 83 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -104771,7 +109531,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -104779,27 +109539,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -104843,18 +109603,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* 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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 99 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 101 /* 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); @@ -104934,16 +109694,16 @@ var ts; return { displayParts: displayParts, kind: symbolKind }; } function toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixText) { - return __assign({}, entryToDocumentSpan(entry), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); + return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); } FindAllReferences.toRenameLocation = toRenameLocation; function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); if (entry.kind === 0 /* Span */) { - return __assign({}, documentSpan, { isWriteAccess: false, isDefinition: false }); + return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign({}, documentSpan, { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 83 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -104987,10 +109747,10 @@ var ts; var documentSpan = entryToDocumentSpan(entry); if (entry.kind !== 0 /* Span */) { var node = entry.node; - return __assign({}, documentSpan, implementationKindDisplayParts(node, checker)); + return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign({}, documentSpan, { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -104998,13 +109758,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 213 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -105033,7 +109793,7 @@ var ts; function getTextSpan(node, sourceFile, endNode) { var start = node.getStart(sourceFile); var end = (endNode || node).getEnd(); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { ts.Debug.assert(endNode === undefined); start += 1; end -= 1; @@ -105048,7 +109808,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 === 81 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 83 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -105056,49 +109816,49 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 4194304 /* Ambient */)) + if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 208 /* BinaryExpression */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 83 /* DefaultKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 261 /* ExportSpecifier */: + case 254 /* ImportClause */: // default import + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 245 /* InterfaceDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 271 /* JsxAttribute */: + case 248 /* ModuleDeclaration */: + case 251 /* NamespaceExportDeclaration */: + case 255 /* NamespaceImport */: + case 155 /* Parameter */: + case 280 /* ShorthandPropertyAssignment */: + case 246 /* TypeAliasDeclaration */: + case 154 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 159 /* MethodSignature */: + case 157 /* PropertySignature */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -105258,10 +110018,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 288 /* 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 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -105278,21 +110038,32 @@ var ts; 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, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 88 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } + /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ + function isReadonlyTypeOperator(node) { + return node.kind === 137 /* ReadonlyKeyword */ + && ts.isTypeOperatorNode(node.parent) + && node.parent.operator === 137 /* ReadonlyKeyword */; + } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + // A modifier readonly (like on a property declaration) is not special; + // a readonly type keyword (like `readonly string[]`) is. + if (node.kind === 137 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + return undefined; + } + // Likewise, when we *are* looking for a special keyword, make sure we + // *don’t* include readonly member modifiers. + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 137 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -105308,7 +110079,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -105325,7 +110096,7 @@ var ts; // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 81 /* DefaultKeyword */) { + else if (node && node.kind === 83 /* 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); } @@ -105353,9 +110124,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: return 1 /* Constructor */; - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -105591,7 +110362,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 === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 200 /* FunctionExpression */ || valueDeclaration.kind === 213 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -105601,7 +110372,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, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 244 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -105630,7 +110401,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 288 /* 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; @@ -105651,7 +110422,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -105738,8 +110509,9 @@ 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 73 /* Identifier */: + case 75 /* Identifier */: return node.text.length === searchSymbolName.length; + case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && @@ -105747,17 +110519,19 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 81 /* DefaultKeyword */: + case 83 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; } } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, ts.tokenToString(keywordKind), sourceFile), function (referenceLocation) { - return referenceLocation.kind === keywordKind ? FindAllReferences.nodeEntry(referenceLocation) : undefined; + if (referenceLocation.kind === keywordKind && (!filter || filter(referenceLocation))) { + return FindAllReferences.nodeEntry(referenceLocation); + } }); }); return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; @@ -105811,7 +110585,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 73 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 75 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -105867,8 +110641,8 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 81 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 81 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 83 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 83 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.assertDefined(exportSpecifier.symbol); var exportInfo = ts.Debug.assertDefined(FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker)); @@ -105931,7 +110705,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -105947,7 +110721,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 81 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 83 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -105974,7 +110748,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 101 /* ThisKeyword */) { + if (node.kind === 103 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -105993,18 +110767,18 @@ var ts; if (constructorSymbol) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 128 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 161 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 160 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 103 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -106025,10 +110799,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 161 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 101 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -106052,10 +110826,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 73 /* Identifier */) { + if (refNode.kind !== 75 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 280 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -106075,7 +110849,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 222 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -106103,13 +110877,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 191 /* ArrayLiteralExpression */: return true; default: return false; @@ -106162,13 +110936,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -106177,7 +110951,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 99 /* SuperKeyword */) { + if (node.kind !== 101 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -106189,41 +110963,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 75 /* Identifier */ && node.parent.kind === 155 /* Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 288 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -106231,19 +111005,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* 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 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 288 /* SourceFile */: + return container.kind === 288 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -106320,7 +111094,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -106362,7 +111136,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 190 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -106412,11 +111186,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 8388608 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -106466,12 +111239,12 @@ var ts; /* @internal */ var ts; (function (ts) { - function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, _preferences, sourceMapper) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences, sourceMapper) { var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); 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) { + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, function (changeTracker) { updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); @@ -106719,9 +111492,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 101 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -106729,7 +111502,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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -106882,35 +111655,39 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 73 /* Identifier */) { + if (node.kind !== 75 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 257 /* ImportSpecifier */: + return declaration.parent.kind === 256 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(symbol.declarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { + // There are cases when you extend a function by adding properties to it afterwards, + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); 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 === 125 /* ConstructorKeyword */)) { - var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 128 /* ConstructorKeyword */)) { + var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } } function getCallSignatureDefinition() { return ts.isCallOrNewExpressionTarget(node) || ts.isNameOfFunctionDeclaration(node) - ? getSignatureDefinition(symbol.declarations, /*selectConstructors*/ false) + ? getSignatureDefinition(filteredDeclarations, /*selectConstructors*/ false) : undefined; } function getSignatureDefinition(signatureDeclarations, selectConstructors) { @@ -106918,8 +111695,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -106972,9 +111753,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return true; default: return false; @@ -107092,11 +111873,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return [declaration]; - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -107117,16 +111898,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return withNode(tag.class); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -107303,7 +112084,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 === 73 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 75 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -107313,23 +112094,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 159 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 157 /* PropertySignature */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 246 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -107337,14 +112118,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 288 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 248 /* 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 === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 248 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 208 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -107363,14 +112144,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 199 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 213 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -107432,9 +112213,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -107444,7 +112225,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 153 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -107461,7 +112242,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 === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 153 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -107505,6 +112286,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -107519,6 +112301,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -107529,13 +112316,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -107561,7 +112350,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -107586,28 +112375,56 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isPropertyNameLiteral(entityName)) { + var name = ts.getNameOrArgument(entityName); + var nameText = ts.getElementOrPropertyAccessName(entityName); + entityName = entityName.expression; + if (nameText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -107617,46 +112434,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* 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); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 159 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -107668,90 +112487,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 280 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 281 /* SpreadAssignment */: + var expression = node.expression; + // Use the expression as the name of the SpreadAssignment, otherwise show as . + ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); + break; + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: + case 241 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + addNodeWithRecursiveChild(node, node.body); + break; + case 247 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 261 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 166 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 246 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && ts.getElementOrPropertyAccessName(assignmentTarget) !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else if (ts.isBindableStaticAccessExpression(assignmentTarget)) { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, ts.getNameOrArgument(assignmentTarget)); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -107774,8 +112671,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -107789,7 +112686,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -107798,7 +112695,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -107806,7 +112703,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -107819,12 +112809,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -107840,7 +112830,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 !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 248 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -107870,7 +112860,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 248 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -107878,35 +112868,37 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 248 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text + : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -107914,24 +112906,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 164 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -107941,28 +112936,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 246 /* TypeAliasDeclaration */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -107972,21 +112967,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -107999,18 +112988,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -108041,7 +113030,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 === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -108055,13 +113044,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 153 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 288 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 241 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -108069,14 +113058,14 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(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 === 60 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -108093,7 +113082,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -108114,14 +113107,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -108135,8 +113138,8 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, _preferences) { - var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext }); + function organizeImports(sourceFile, formatContext, host, program, preferences) { + var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); var coalesceAndOrganizeImports = function (importGroup) { return coalesceImports(removeUnusedImports(importGroup, sourceFile, program)); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); @@ -108464,7 +113467,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 93 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 95 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -108581,7 +113584,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -108589,23 +113592,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 227 /* DoStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 278 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 239 /* 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, 89 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -108613,24 +113616,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 250 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -108672,7 +113675,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 201 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -109207,10 +114210,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 126 /* DeclareKeyword */) { + if (token === 129 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 131 /* ModuleKeyword */) { + if (token === 134 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -109228,7 +114231,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 93 /* ImportKeyword */) { + if (token === 95 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -109244,9 +114247,9 @@ var ts; return true; } else { - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -109254,7 +114257,7 @@ var ts; return true; } } - else if (token === 60 /* EqualsToken */) { + else if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -109277,7 +114280,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -109287,13 +114290,13 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 120 /* AsKeyword */) { + if (token === 122 /* AsKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -109311,7 +114314,7 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 86 /* ExportKeyword */) { + if (token === 88 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); if (token === 18 /* OpenBraceToken */) { @@ -109323,7 +114326,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -109333,9 +114336,9 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -109343,11 +114346,11 @@ var ts; } } } - else if (token === 93 /* ImportKeyword */) { + else if (token === 95 /* ImportKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 60 /* EqualsToken */) { + if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -109360,7 +114363,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 135 /* RequireKeyword */) { + if (token === 138 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -109375,7 +114378,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 73 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 75 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -109509,14 +114512,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 === 81 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 83 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 153 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -109563,7 +114566,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { // Exclude the quotes start += 1; width -= 2; @@ -109572,9 +114575,10 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -109605,7 +114609,7 @@ var ts; if (node.getStart(sourceFile) > pos) { break outer; } - if (positionShouldSnapToNode(pos, node, nextNode)) { + if (positionShouldSnapToNode(sourceFile, pos, node)) { // 1. Blocks are effectively redundant with SyntaxLists. // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping // of things that should be considered independently. @@ -109614,7 +114618,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -109677,12 +114681,11 @@ var ts; * count too, unless that position belongs to the next node. In effect, makes * selections able to snap to preceding tokens when the cursor is on the tail * end of them with only whitespace ahead. + * @param sourceFile The source file containing the nodes. * @param pos The position to check. * @param node The candidate node to snap to. - * @param nextNode The next sibling node in the tree. - * @param sourceFile The source file containing the nodes. */ - function positionShouldSnapToNode(pos, node, nextNode) { + function positionShouldSnapToNode(sourceFile, pos, node) { // Can’t use 'ts.positionBelongsToNode()' here because it cleverly accounts // for missing nodes, which can’t really be considered when deciding what // to select. @@ -109691,9 +114694,8 @@ var ts; return true; } var nodeEnd = node.getEnd(); - var nextNodeStart = nextNode && nextNode.getStart(); if (nodeEnd === pos) { - return pos !== nextNodeStart; + return ts.getTouchingPropertyName(sourceFile, pos).pos < node.end; } return false; } @@ -109728,14 +114730,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 134 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 56 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 137 /* ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 154 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -109743,7 +114745,7 @@ var ts; // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; })), closeBraceToken, ]; @@ -109755,7 +114757,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -109768,14 +114770,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } return node.getChildren(); @@ -109842,7 +114844,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(313 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(317 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -109851,14 +114853,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 266 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 267 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -109951,7 +114953,7 @@ var ts; var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -110010,7 +115012,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* 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 }; @@ -110063,10 +115065,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 197 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 210 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -110133,17 +115135,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 199 /* ParenthesizedExpression */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* 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 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -110214,11 +115216,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -110267,7 +115269,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 === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -110332,14 +115334,14 @@ 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(28 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(29 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } 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); - var suffixDisplayParts = suffix.concat(returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); + var prefixDisplayParts = __spreadArrays(callTargetDisplayParts, prefix); + var suffixDisplayParts = __spreadArrays(suffix, returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); var documentation = candidateSignature.getDocumentationComment(checker); var tags = candidateSignature.getJsDocTags(); return { isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; @@ -110363,10 +115365,10 @@ var ts; var parameters = (typeParameters || ts.emptyArray).map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -110378,7 +115380,7 @@ var ts; } }); var parameters = checker.getExpandedParameters(candidateSignature).map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: __spreadArrays(typeParameterParts, [ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -110442,6 +115444,10 @@ var ts; if (!sourceFile) return undefined; var program = host.getProgram(); + // If this is source file of project reference source (instead of redirect) there is no generated position + if (program.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) { + return undefined; + } var options = program.getCompilerOptions(); var outPath = options.outFile || options.out; var declarationPath = outPath ? @@ -110579,7 +115585,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -110589,7 +115595,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 243 /* 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)); @@ -110622,11 +115628,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -110643,12 +115649,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 255 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -110706,13 +115712,13 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ - case 97 /* NullKeyword */: - case 73 /* Identifier */: // identifier includes undefined + // falls through + case 99 /* NullKeyword */: + case 75 /* Identifier */: // identifier includes undefined return true; default: return false; @@ -110735,7 +115741,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -110772,7 +115778,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 101 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 103 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -110823,11 +115829,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 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + return location.kind === 75 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 271 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -110854,13 +115860,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 === 101 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 103 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 101 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(101 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 103 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(103 /* 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 */) { @@ -110870,7 +115876,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 193 /* 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)) { @@ -110890,7 +115896,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 196 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 101 /* 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 @@ -110908,7 +115914,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -110925,14 +115931,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(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* 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(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -110945,29 +115951,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 128 /* ConstructorKeyword */ && location.parent.kind === 161 /* 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 === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 128 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 161 /* 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 === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 161 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 164 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -110977,7 +115983,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 213 /* 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 @@ -110985,7 +115991,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(77 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(79 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -110993,37 +115999,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(111 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(113 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* 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(78 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(80 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(85 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(87 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 248 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 75 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 135 /* NamespaceKeyword */ : 134 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -111042,7 +116048,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 154 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -111050,21 +116056,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + if (declaration.kind === 165 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 164 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 246 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -111076,11 +116082,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 282 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -111106,32 +116112,32 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 251 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(135 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 258 /* ExportAssignment */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 83 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 261 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(93 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(95 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 252 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(135 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(138 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -111140,7 +116146,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -111154,7 +116160,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(101 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(103 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -111165,7 +116171,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -111203,10 +116209,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 === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 288 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 208 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -111249,7 +116255,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(94 /* InKeyword */)); + displayParts.push(ts.keywordPart(96 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -111259,7 +116265,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(56 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -111294,7 +116300,7 @@ var ts; if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(38 /* PlusToken */)); + displayParts.push(ts.operatorPart(39 /* 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")); @@ -111319,16 +116325,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 200 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 241 /* VariableDeclaration */ && declaration.kind !== 243 /* 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 === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 288 /* SourceFile */ || parent.kind === 249 /* ModuleBlock */) { return false; } } @@ -111351,32 +116357,24 @@ var ts; */ function transpileModule(input, transpileOptions) { var diagnostics = []; - var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : ts.getDefaultCompilerOptions(); - options.isolatedModules = true; + var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {}; + // mix in default options + var defaultOptions = ts.getDefaultCompilerOptions(); + for (var key in defaultOptions) { + if (ts.hasProperty(defaultOptions, key) && options[key] === undefined) { + options[key] = defaultOptions[key]; + } + } + for (var _i = 0, transpileOptionValueCompilerOptions_1 = ts.transpileOptionValueCompilerOptions; _i < transpileOptionValueCompilerOptions_1.length; _i++) { + var option = transpileOptionValueCompilerOptions_1[_i]; + options[option.name] = option.transpileOptionValue; + } // transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths. options.suppressOutputPathCheck = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, - // so pass --noLib to avoid reporting a file not found error. - options.noLib = true; - // Clear out other settings that would not be used in transpiling this module - options.lib = undefined; - options.types = undefined; - options.noEmit = undefined; - options.noEmitOnError = undefined; - options.paths = undefined; - options.rootDirs = undefined; - options.declaration = undefined; - options.composite = undefined; - options.declarationDir = undefined; - options.out = undefined; - options.outFile = undefined; - // We are not doing a full typecheck, we are not resolving the whole context, - // so pass --noResolve to avoid reporting missing file errors. - options.noResolve = true; // if jsx is specified then treat file as .tsx - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -111581,7 +116579,9 @@ var ts; var res = cb({ advance: advance, readTokenInfo: readTokenInfo, + readEOFTokenRange: readEOFTokenRange, isOnToken: isOnToken, + isOnEOF: isOnEOF, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, @@ -111621,11 +116621,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 32 /* GreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -111633,12 +116633,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 271 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* 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 === 73 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 75 /* Identifier */; } } return false; @@ -111654,23 +116654,18 @@ var ts; container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 42 /* SlashToken */ || t === 65 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -111687,11 +116682,7 @@ var ts; scanner.scan(); } var currentToken = getNextToken(n, expectedScanAction); - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var token = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); // consume trailing trivia if (trailingTrivia) { trailingTrivia = undefined; @@ -111701,11 +116692,7 @@ var ts; if (!ts.isTrivia(currentToken)) { break; } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var trivia = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); if (!trailingTrivia) { trailingTrivia = []; } @@ -111724,7 +116711,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -111758,11 +116745,19 @@ var ts; } return token; } + function readEOFTokenRange() { + ts.Debug.assert(isOnEOF()); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); } + function isOnEOF() { + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + return current === 1 /* EndOfFileToken */; + } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, // then kind needs to be fixed. This might happen in cases @@ -111794,10 +116789,16 @@ var ts; formatting.anyContext = ts.emptyArray; var RuleAction; (function (RuleAction) { - RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; - RuleAction[RuleAction["Space"] = 2] = "Space"; - RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; - RuleAction[RuleAction["Delete"] = 8] = "Delete"; + RuleAction[RuleAction["StopProcessingSpaceActions"] = 1] = "StopProcessingSpaceActions"; + RuleAction[RuleAction["StopProcessingTokenActions"] = 2] = "StopProcessingTokenActions"; + RuleAction[RuleAction["InsertSpace"] = 4] = "InsertSpace"; + RuleAction[RuleAction["InsertNewLine"] = 8] = "InsertNewLine"; + RuleAction[RuleAction["DeleteSpace"] = 16] = "DeleteSpace"; + RuleAction[RuleAction["DeleteToken"] = 32] = "DeleteToken"; + RuleAction[RuleAction["InsertTrailingSemicolon"] = 64] = "InsertTrailingSemicolon"; + RuleAction[RuleAction["StopAction"] = 3] = "StopAction"; + RuleAction[RuleAction["ModifySpaceAction"] = 28] = "ModifySpaceAction"; + RuleAction[RuleAction["ModifyTokenAction"] = 96] = "ModifyTokenAction"; })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); var RuleFlags; (function (RuleFlags) { @@ -111813,8 +116814,10 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { - allTokens.push(token); + for (var token = 0 /* FirstToken */; token <= 151 /* LastToken */; token++) { + if (token !== 1 /* EndOfFileToken */) { + allTokens.push(token); + } } function anyTokenExcept() { var tokens = []; @@ -111824,259 +116827,262 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; - var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArrays(allTokens, [1 /* EndOfFileToken */])); + var keywords = tokenRangeFromRange(76 /* FirstKeyword */, 151 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 74 /* LastBinaryOperator */); + var binaryKeywordOperators = [96 /* InKeyword */, 97 /* InstanceOfKeyword */, 151 /* OfKeyword */, 122 /* AsKeyword */, 132 /* IsKeyword */]; + var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 75 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostincrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; - var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; + var unaryPreincrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostincrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; + var unaryPredecrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostdecrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [73 /* Identifier */].concat(ts.typeKeywords); + var typeNames = __spreadArrays([75 /* Identifier */], 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([73 /* Identifier */, 3 /* MultiLineCommentTrivia */, 77 /* ClassKeyword */, 86 /* ExportKeyword */, 93 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([75 /* Identifier */, 3 /* MultiLineCommentTrivia */, 79 /* ClassKeyword */, 88 /* ExportKeyword */, 95 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 83 /* DoKeyword */, 104 /* TryKeyword */, 89 /* FinallyKeyword */, 84 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 85 /* DoKeyword */, 106 /* TryKeyword */, 91 /* FinallyKeyword */, 86 /* 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, 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 */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), // in other cases there should be no space between '?' and next token - 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", 93 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 95 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 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 */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 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 */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 84 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 108 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 86 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 110 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 91 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, 73 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 91 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 93 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 75 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 93 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [127 /* GetKeyword */, 138 /* SetKeyword */], 73 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 118 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [118 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 98 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [106 /* VarKeyword */, 102 /* ThrowKeyword */, 96 /* NewKeyword */, 82 /* DeleteKeyword */, 98 /* ReturnKeyword */, 105 /* TypeOfKeyword */, 123 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [112 /* LetKeyword */, 78 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [130 /* GetKeyword */, 141 /* SetKeyword */], 75 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 120 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [120 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 100 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterCertainKeywords", [108 /* VarKeyword */, 104 /* ThrowKeyword */, 98 /* NewKeyword */, 84 /* DeleteKeyword */, 100 /* ReturnKeyword */, 107 /* TypeOfKeyword */, 126 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [114 /* LetKeyword */, 80 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 107 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 109 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 122 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 122 /* AsyncKeyword */, 91 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 125 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 125 /* AsyncKeyword */, 93 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [73 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [75 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 73 /* 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, 60 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 60 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 75 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [131 /* ModuleKeyword */, 135 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [134 /* ModuleKeyword */, 138 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 119 /* AbstractKeyword */, - 77 /* ClassKeyword */, - 126 /* DeclareKeyword */, - 81 /* DefaultKeyword */, - 85 /* EnumKeyword */, - 86 /* ExportKeyword */, - 87 /* ExtendsKeyword */, - 127 /* GetKeyword */, - 110 /* ImplementsKeyword */, - 93 /* ImportKeyword */, - 111 /* InterfaceKeyword */, - 131 /* ModuleKeyword */, - 132 /* NamespaceKeyword */, - 114 /* PrivateKeyword */, - 116 /* PublicKeyword */, - 115 /* ProtectedKeyword */, - 134 /* ReadonlyKeyword */, - 138 /* SetKeyword */, - 117 /* StaticKeyword */, - 141 /* TypeKeyword */, - 145 /* FromKeyword */, - 130 /* KeyOfKeyword */, - 128 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [87 /* ExtendsKeyword */, 110 /* ImplementsKeyword */, 145 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + 121 /* AbstractKeyword */, + 79 /* ClassKeyword */, + 129 /* DeclareKeyword */, + 83 /* DefaultKeyword */, + 87 /* EnumKeyword */, + 88 /* ExportKeyword */, + 89 /* ExtendsKeyword */, + 130 /* GetKeyword */, + 112 /* ImplementsKeyword */, + 95 /* ImportKeyword */, + 113 /* InterfaceKeyword */, + 134 /* ModuleKeyword */, + 135 /* NamespaceKeyword */, + 116 /* PrivateKeyword */, + 118 /* PublicKeyword */, + 117 /* ProtectedKeyword */, + 137 /* ReadonlyKeyword */, + 141 /* SetKeyword */, + 119 /* StaticKeyword */, + 144 /* TypeKeyword */, + 148 /* FromKeyword */, + 133 /* KeyOfKeyword */, + 131 /* InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [89 /* ExtendsKeyword */, 112 /* ImplementsKeyword */, 148 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 73 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 75 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), // generics and type assertions - 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 */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 73 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 75 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 119 /* AbstractKeyword */, - 73 /* Identifier */, - 86 /* ExportKeyword */, - 81 /* DefaultKeyword */, - 77 /* ClassKeyword */, - 117 /* StaticKeyword */, - 116 /* PublicKeyword */, - 114 /* PrivateKeyword */, - 115 /* ProtectedKeyword */, - 127 /* GetKeyword */, - 138 /* SetKeyword */, + 121 /* AbstractKeyword */, + 75 /* Identifier */, + 88 /* ExportKeyword */, + 83 /* DefaultKeyword */, + 79 /* ClassKeyword */, + 119 /* StaticKeyword */, + 118 /* PublicKeyword */, + 116 /* PrivateKeyword */, + 117 /* ProtectedKeyword */, + 130 /* GetKeyword */, + 141 /* SetKeyword */, 22 /* OpenBracketToken */, - 40 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 96 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 28 /* LessThanToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + 41 /* AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 98 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 125 /* 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 */), + rule("SpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 4 /* InsertSpace */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - 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 */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty brackets - 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 */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 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 */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing template string braces - 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 */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space after { and before } in JSX expression - 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 */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), // 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, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 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, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - 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 */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 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 */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(122 /* AsyncKeyword */, 75 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(125 /* AsyncKeyword */, 77 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 90 /* ForKeyword */, 123 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 92 /* ForKeyword */, 126 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 83 /* DoKeyword */, 84 /* ElseKeyword */, 75 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 85 /* DoKeyword */, 86 /* ElseKeyword */, 77 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [106 /* TryKeyword */, 91 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; - return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); + return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } formatting.getAllRules = getAllRules; /** @@ -112114,6 +117120,9 @@ var ts; /// /// Contexts /// + function optionEquals(optionName, optionValue) { + return function (context) { return context.options && context.options[optionName] === optionValue; }; + } function isOptionEnabled(optionName) { return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; }; } @@ -112130,45 +117139,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 229 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 179 /* ConditionalType */: + case 216 /* AsExpression */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 167 /* TypePredicate */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 190 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 252 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 241 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 155 /* Parameter */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: - return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 154 /* TypeParameter */: + return context.currentTokenSpan.kind === 96 /* InKeyword */ || context.nextTokenSpan.kind === 96 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 231 /* ForOfStatement */: + return context.currentTokenSpan.kind === 151 /* OfKeyword */ || context.nextTokenSpan.kind === 151 /* OfKeyword */; } return false; } @@ -112180,22 +117194,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 158 /* PropertyDeclaration */ || + contextKind === 157 /* PropertySignature */ || + contextKind === 155 /* Parameter */ || + contextKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 209 /* ConditionalExpression */ || + context.contextNode.kind === 179 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 188 /* ObjectBindingPattern */ || + context.contextNode.kind === 185 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -112221,31 +117235,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 192 /* ObjectLiteralExpression */: + case 249 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 164 /* CallSignature */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 201 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 245 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -112254,40 +117271,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 243 /* FunctionDeclaration */ || context.contextNode.kind === 200 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 172 /* TypeLiteral */: + case 248 /* ModuleDeclaration */: + case 259 /* ExportDeclaration */: + case 260 /* NamedExports */: + case 253 /* ImportDeclaration */: + case 256 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 278 /* CatchClause */: + case 249 /* ModuleBlock */: + case 236 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 222 /* 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 !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 201 /* ArrowFunction */ && blockParent.kind !== 200 /* FunctionExpression */) { return true; } } @@ -112296,31 +117313,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 235 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 278 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 192 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 195 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 196 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -112332,28 +117350,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 201 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 187 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 264 /* JsxElement */ && context.contextNode.kind !== 268 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 274 /* JsxExpression */ || context.contextNode.kind === 273 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 271 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 271 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 265 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -112368,45 +117386,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 242 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 248 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 172 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 165 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { + if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 198 /* TypeAssertionExpression */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -112417,16 +117435,78 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 198 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 109 /* VoidKeyword */ && context.currentTokenParent.kind === 204 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 211 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 217 /* NonNullExpression */; + } + function isSemicolonDeletionContext(context) { + var nextTokenKind = context.nextTokenSpan.kind; + var nextTokenStart = context.nextTokenSpan.pos; + if (ts.isTrivia(nextTokenKind)) { + var nextRealToken = context.nextTokenParent === context.currentTokenParent + ? ts.findNextToken(context.currentTokenParent, ts.findAncestor(context.currentTokenParent, function (a) { return !a.parent; }), context.sourceFile) + : context.nextTokenParent.getFirstToken(context.sourceFile); + if (!nextRealToken) { + return true; + } + nextTokenKind = nextRealToken.kind; + nextTokenStart = nextRealToken.getStart(context.sourceFile); + } + var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; + var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; + if (startLine === endLine) { + return nextTokenKind === 19 /* CloseBraceToken */ + || nextTokenKind === 1 /* EndOfFileToken */; + } + if (nextTokenKind === 221 /* SemicolonClassElement */ || + nextTokenKind === 26 /* SemicolonToken */) { + return false; + } + if (context.contextNode.kind === 245 /* InterfaceDeclaration */ || + context.contextNode.kind === 246 /* TypeAliasDeclaration */) { + // Can’t remove semicolon after `foo`; it would parse as a method declaration: + // + // interface I { + // foo; + // (): void + // } + return !ts.isPropertySignature(context.currentTokenParent) + || !!context.currentTokenParent.type + || nextTokenKind !== 20 /* OpenParenToken */; + } + if (ts.isPropertyDeclaration(context.currentTokenParent)) { + return !context.currentTokenParent.initializer; + } + return context.currentTokenParent.kind !== 229 /* ForStatement */ + && context.currentTokenParent.kind !== 223 /* EmptyStatement */ + && context.currentTokenParent.kind !== 221 /* SemicolonClassElement */ + && nextTokenKind !== 22 /* OpenBracketToken */ + && nextTokenKind !== 20 /* OpenParenToken */ + && nextTokenKind !== 39 /* PlusToken */ + && nextTokenKind !== 40 /* MinusToken */ + && nextTokenKind !== 43 /* SlashToken */ + && nextTokenKind !== 13 /* RegularExpressionLiteral */ + && nextTokenKind !== 27 /* CommaToken */ + && nextTokenKind !== 210 /* TemplateExpression */ + && nextTokenKind !== 15 /* TemplateHead */ + && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* DotToken */; + } + function isSemicolonInsertionContext(context) { + var contextAncestor = ts.findAncestor(context.currentTokenParent, function (ancestor) { + if (ancestor.end !== context.currentTokenSpan.end) { + return "quit"; + } + return ts.syntaxMayBeASICandidate(ancestor.kind); + }); + return !!contextAncestor && ts.isASICandidate(contextAncestor, context.sourceFile); } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -112436,7 +117516,7 @@ var ts; var formatting; (function (formatting) { function getFormatContext(options) { - return { options: options, getRule: getRulesMap() }; + return { options: options, getRules: getRulesMap() }; } formatting.getFormatContext = getFormatContext; var rulesMapCache; @@ -112446,11 +117526,45 @@ var ts; } return rulesMapCache; } + /** + * For a given rule action, gets a mask of other rule actions that + * cannot be applied at the same position. + */ + function getRuleActionExclusion(ruleAction) { + var mask = 0; + if (ruleAction & 1 /* StopProcessingSpaceActions */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 2 /* StopProcessingTokenActions */) { + mask |= 96 /* ModifyTokenAction */; + } + if (ruleAction & 28 /* ModifySpaceAction */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 96 /* ModifyTokenAction */) { + mask |= 96 /* ModifyTokenAction */; + } + return mask; + } function createRulesMap(rules) { var map = buildMap(rules); return function (context) { var bucket = map[getRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind)]; - return bucket && ts.find(bucket, function (rule) { return ts.every(rule.context, function (c) { return c(context); }); }); + if (bucket) { + var rules_1 = []; + var ruleActionMask = 0; + for (var _i = 0, bucket_1 = bucket; _i < bucket_1.length; _i++) { + var rule = bucket_1[_i]; + var acceptRuleActions = ~getRuleActionExclusion(ruleActionMask); + if (rule.action & acceptRuleActions && ts.every(rule.context, function (c) { return c(context); })) { + rules_1.push(rule); + ruleActionMask |= rule.action; + } + } + if (rules_1.length) { + return rules_1; + } + } }; } function buildMap(rules) { @@ -112458,8 +117572,8 @@ var ts; var map = new Array(mapRowLength * mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(map.length); - for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) { - var rule = rules_1[_i]; + for (var _i = 0, rules_2 = rules; _i < rules_2.length; _i++) { + var rule = rules_2[_i]; var specificRule = rule.leftTokenRange.isSpecific && rule.rightTokenRange.isSpecific; for (var _a = 0, _b = rule.leftTokenRange.tokens; _a < _b.length; _a++) { var left = _b[_a]; @@ -112477,16 +117591,16 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 151 /* LastKeyword */ && column <= 151 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 151 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = maskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; + RulesPosition[RulesPosition["StopRulesAny"] = maskBitSize * 1] = "StopRulesAny"; RulesPosition[RulesPosition["ContextRulesSpecific"] = maskBitSize * 2] = "ContextRulesSpecific"; RulesPosition[RulesPosition["ContextRulesAny"] = maskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = maskBitSize * 4] = "NoContextRulesSpecific"; @@ -112508,11 +117622,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action & 3 /* StopAction */ ? + specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -112537,6 +117651,16 @@ var ts; (function (ts) { var formatting; (function (formatting) { + function createTextRangeWithKind(pos, end, kind) { + var textRangeWithKind = { pos: pos, end: end, kind: kind }; + if (ts.Debug.isDebugging) { + Object.defineProperty(textRangeWithKind, "__debugKind", { + get: function () { return ts.Debug.formatSyntaxKind(kind); }, + }); + } + return textRangeWithKind; + } + formatting.createTextRangeWithKind = createTextRangeWithKind; var Constants; (function (Constants) { Constants[Constants["Unknown"] = -1] = "Unknown"; @@ -112660,17 +117784,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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 249 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 288 /* SourceFile */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -112805,7 +117929,7 @@ var ts; return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) { - var options = _a.options, getRule = _a.getRule; + var options = _a.options, getRules = _a.getRules; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); var previousRange; @@ -112895,19 +118019,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: return 79 /* ClassKeyword */; + case 245 /* InterfaceDeclaration */: return 113 /* InterfaceKeyword */; + case 243 /* FunctionDeclaration */: return 93 /* FunctionKeyword */; + case 247 /* EnumDeclaration */: return 247 /* EnumDeclaration */; + case 162 /* GetAccessor */: return 130 /* GetKeyword */; + case 163 /* SetAccessor */: return 141 /* SetKeyword */; + case 160 /* MethodDeclaration */: if (node.asteriskToken) { - return 40 /* AsteriskToken */; + return 41 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -112957,22 +118081,22 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 84 /* ElseKeyword */: - case 108 /* WhileKeyword */: - case 58 /* AtToken */: + case 86 /* ElseKeyword */: + case 110 /* WhileKeyword */: + case 59 /* AtToken */: return false; - case 42 /* SlashToken */: - case 30 /* GreaterThanToken */: + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 185 /* MappedType */) { return false; } break; @@ -113019,6 +118143,12 @@ var ts; } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } + if (!node.parent && formattingScanner.isOnEOF()) { + var token = formattingScanner.readEOFTokenRange(); + if (token.end <= node.end && previousRange) { + processPair(token, sourceFile.getLineAndCharacterOfPosition(token.pos).line, node, previousRange, previousRangeStartLine, previousParent, contextNode, nodeDynamicIndentation); + } + } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; @@ -113064,7 +118194,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 156 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 11 /* JsxText */) { @@ -113072,7 +118202,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 191 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -113240,35 +118370,39 @@ var ts; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = getRule(formattingContext); - var trimTrailingWhitespaces; + var rules = getRules(formattingContext); + var trimTrailingWhitespaces = false; var lineAction = 0 /* None */; - if (rule) { - lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - switch (lineAction) { - case 2 /* LineRemoved */: - // Handle the case where the next line is moved to be the end of this line. - // In this case we don't indent the next line in the next pass. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); - } - break; - case 1 /* LineAdded */: - // Handle the case where token2 is moved to the new line. - // In this case we indent token2 in the next pass but we set - // sameLineIndent flag to notify the indenter that the indentation is within the line. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); - } - break; - default: - ts.Debug.assert(lineAction === 0 /* None */); - } - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = !(rule.action & 8 /* Delete */) && rule.flags !== 1 /* CanDeleteNewLines */; + if (rules) { + // Apply rules in reverse order so that higher priority rules (which are first in the array) + // win in a conflict with lower priority rules. + ts.forEachRight(rules, function (rule) { + lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + switch (lineAction) { + case 2 /* LineRemoved */: + // Handle the case where the next line is moved to be the end of this line. + // In this case we don't indent the next line in the next pass. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); + } + break; + case 1 /* LineAdded */: + // Handle the case where token2 is moved to the new line. + // In this case we indent token2 in the next pass but we set + // sameLineIndent flag to notify the indenter that the indentation is within the line. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); + } + break; + default: + ts.Debug.assert(lineAction === 0 /* None */); + } + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespaces = !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + }); } else { - trimTrailingWhitespaces = true; + trimTrailingWhitespaces = currentItem.kind !== 1 /* EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -113405,20 +118539,28 @@ var ts; edits.push(ts.createTextChangeFromStartLength(start, len, newText)); } } + function recordInsert(start, text) { + if (text) { + edits.push(ts.createTextChangeFromStartLength(start, 0, text)); + } + } function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* Ignore */: + case 1 /* StopProcessingSpaceActions */: // no action required return 0 /* None */; - case 8 /* Delete */: + case 16 /* DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } break; - case 4 /* NewLine */: + case 32 /* DeleteToken */: + recordDelete(previousRange.pos, previousRange.end - previousRange.pos); + break; + case 8 /* InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines @@ -113432,7 +118574,7 @@ var ts; return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; } break; - case 2 /* Space */: + case 4 /* InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { return 0 /* None */; @@ -113442,6 +118584,9 @@ var ts; recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } + break; + case 64 /* InsertTrailingSemicolon */: + recordInsert(previousRange.end, ";"); } return 0 /* None */; } @@ -113455,8 +118600,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -113465,6 +118609,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -113490,34 +118635,34 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 201 /* ArrowFunction */: if (node.typeParameters === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.parameters === list) { return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.arguments === list) { return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 168 /* TypeReference */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -113526,8 +118671,8 @@ var ts; switch (kind) { case 20 /* OpenParenToken */: return 21 /* CloseParenToken */; - case 28 /* LessThanToken */: - return 30 /* GreaterThanToken */; + case 29 /* LessThanToken */: + return 31 /* GreaterThanToken */; case 18 /* OpenBraceToken */: return 19 /* CloseBraceToken */; } @@ -113615,7 +118760,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -113634,7 +118780,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 208 /* 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 */) { @@ -113788,7 +118934,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 === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 288 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -113836,8 +118982,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); + if (parent.kind === 226 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 86 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -113871,40 +119017,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -113927,7 +119073,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 242 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -114000,83 +119146,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 225 /* ExpressionStatement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 191 /* ArrayLiteralExpression */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 185 /* MappedType */: + case 174 /* TupleType */: + case 250 /* CaseBlock */: + case 276 /* DefaultClause */: + case 275 /* CaseClause */: + case 199 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 224 /* VariableStatement */: + case 258 /* ExportAssignment */: + case 234 /* ReturnStatement */: + case 209 /* ConditionalExpression */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: + case 265 /* JsxSelfClosingElement */: + case 274 /* JsxExpression */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 155 /* Parameter */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 181 /* ParenthesizedType */: + case 197 /* TaggedTemplateExpression */: + case 205 /* AwaitExpression */: + case 260 /* NamedExports */: + case 256 /* NamedImports */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 158 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 241 /* VariableDeclaration */: + case 279 /* PropertyAssignment */: + case 208 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 192 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 208 /* BinaryExpression */) { + return true; + } + break; + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return childKind !== 222 /* Block */; + case 259 /* ExportDeclaration */: + return childKind !== 260 /* NamedExports */; + case 253 /* ImportDeclaration */: + return childKind !== 254 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 256 /* NamedImports */); + case 264 /* JsxElement */: + return childKind !== 267 /* JsxClosingElement */; + case 268 /* JsxFragment */: + return childKind !== 270 /* JsxClosingFragment */; + case 178 /* IntersectionType */: + case 177 /* UnionType */: + if (childKind === 172 /* TypeLiteral */) { return false; } // falls through @@ -114087,11 +119237,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: + return parent.kind !== 222 /* Block */; default: return false; } @@ -114233,7 +119383,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 192 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -114398,7 +119548,7 @@ var ts; } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 241 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -114430,7 +119580,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { var firstStatement = ts.firstOrUndefined(ctr.body.statements); if (!firstStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, [newStatement].concat(ctr.body.statements)); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays([newStatement], ctr.body.statements)); } else { this.insertNodeBefore(sourceFile, firstStatement, newStatement); @@ -114439,7 +119589,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, ctr.body.statements.concat([newStatement])); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays(ctr.body.statements, [newStatement])); } else { this.insertNodeAfter(sourceFile, lastStatement, newStatement); @@ -114472,7 +119622,7 @@ var ts; if (getMembersOrProperties(cls).length === 0) { if (ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(cls), { node: cls, sourceFile: sourceFile })) { // For `class C {\n}`, don't add the trailing "\n" - var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, getClassOrObjectBraceEnds(cls, sourceFile).concat([sourceFile])); // TODO: GH#4130 remove 'as any' + var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, __spreadArrays(getClassOrObjectBraceEnds(cls, sourceFile), [sourceFile])); // TODO: GH#4130 remove 'as any' return { prefix: this.newLineCharacter, suffix: comma + (shouldSuffix ? this.newLineCharacter : "") }; } else { @@ -114511,22 +119661,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 155 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -114535,12 +119685,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + if (node.kind === 201 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(91 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(93 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -114549,14 +119699,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 222 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(100 /* 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 === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 200 /* FunctionExpression */ ? 93 /* FunctionKeyword */ : 79 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -114807,29 +119957,34 @@ var ts; var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + noIndent + (options.suffix || ""); } + function getFormatCodeSettingsForWriting(_a, sourceFile) { + var options = _a.options; + var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore; + var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile); + return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore }); + } /** Note: this may mutate `nodeIn`. */ function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) { var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta; var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text; if (validate) validate(node, text); - var formatOptions = formatContext.options; + var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile); var initialIndentation = indentation !== undefined ? indentation : ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos); if (delta === undefined) { - delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatContext.options, nodeIn) ? (formatOptions.indentSize || 0) : 0; + delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? (formatOptions.indentSize || 0) : 0; } var file = { text: text, getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); } }; - var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, formatContext); + var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, __assign(__assign({}, formatContext), { options: formatOptions })); return applyChanges(text, changes); } /** Note: output node may be mutated input node. */ function getNonformattedText(node, sourceFile, newLineCharacter) { - var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); - var writer = createWriter(newLineCharacter, omitTrailingSemicolon); + var writer = createWriter(newLineCharacter); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -114864,9 +120019,9 @@ var ts; nodeArray.end = getEnd(nodes); return nodeArray; } - function createWriter(newLine, omitTrailingSemicolon) { + function createWriter(newLine) { var lastNonTriviaPosition = 0; - var writer = omitTrailingSemicolon ? ts.getTrailingSemicolonOmittingWriter(ts.createTextWriter(newLine)) : ts.createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var onEmitNode = function (hint, node, printCallback) { if (node) { setPos(node, lastNonTriviaPosition); @@ -115017,6 +120172,8 @@ var ts; getColumn: getColumn, getIndent: getIndent, isAtStartOfLine: isAtStartOfLine, + hasTrailingComment: function () { return writer.hasTrailingComment(); }, + hasTrailingWhitespace: function () { return writer.hasTrailingWhitespace(); }, clear: clear }; } @@ -115081,14 +120238,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 153 /* 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 152 /* Parameter */: { + case 155 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -115103,14 +120260,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 189 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -115118,13 +120275,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -115133,7 +120290,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -115180,13 +120337,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 253 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 278 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; @@ -115197,14 +120354,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -115365,10 +120522,10 @@ var ts; }); 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 assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) - : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(147 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(147 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -115384,7 +120541,7 @@ var ts; ts.Diagnostics.This_expression_is_not_callable.code, ts.Diagnostics.This_expression_is_not_constructable.code, ]; - var errorCodes = [ + var errorCodes = __spreadArrays([ ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, @@ -115400,13 +120557,13 @@ var ts; ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator.code, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code, propertyAccessCode - ].concat(callableConstructableErrorCodes); + ], callableConstructableErrorCodes); codefix.registerCodeFix({ fixIds: [fixId], errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -115420,27 +120577,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -115454,7 +120622,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -115467,64 +120635,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = function (identifier) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + return "continue"; + } + var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); + var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); + var variableStatement = ts.getAncestor(declaration, 224 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; + } + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; + } + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); }); - if (isUsedElsewhere) { - return; - } - return declaration.initializer; + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { - return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 243 /* FunctionDeclaration */ || + ancestor.parent.kind === 200 /* FunctionExpression */ || + ancestor.parent.kind === 201 /* ArrowFunction */ || + ancestor.parent.kind === 160 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -115587,16 +120837,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || fixedNodes.tryAdd(initializer)) { - changeTracker.insertModifierBefore(sourceFile, 78 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 80 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 75 /* Identifier */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -115610,8 +120860,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 75 /* Identifier */: + case 208 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -115631,6 +120881,42 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addMissingDeclareProperty"; + var errorCodes = [ + ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration.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); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Prefix_with_declare, fixId, ts.Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var fixedNodes = new ts.NodeSet(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start, fixedNodes); }); + }, + }); + function makeChange(changeTracker, sourceFile, pos, fixedNodes) { + var token = ts.getTokenAtPosition(sourceFile, pos); + if (!ts.isIdentifier(token)) { + return; + } + var declaration = token.parent; + if (declaration.kind === 158 /* PropertyDeclaration */ && + (!fixedNodes || fixedNodes.tryAdd(declaration))) { + changeTracker.insertModifierBefore(sourceFile, 129 /* DeclareKeyword */, declaration); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -115752,33 +121038,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 241 /* VariableDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 158 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -115800,7 +121086,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 299 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); 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); @@ -115840,8 +121126,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -115945,7 +121231,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 73 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 101 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 103 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -116032,13 +121318,8 @@ var ts; if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, 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); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -116057,14 +121338,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -116099,7 +121377,7 @@ var ts; function annotate(changes, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 157 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -116139,14 +121417,14 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); + var jsDocNode = parent.kind === 201 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 158 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -116156,14 +121434,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 306 /* JSDocParameterTag */: { + case 310 /* 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 307 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -116175,25 +121453,31 @@ var ts; } 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); + return inferTypeFromReferences(program, references, cancellationToken).single(); + } + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); + case 161 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 128 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -116202,54 +121486,109 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - 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); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + var builtinConstructors = { + string: function () { return checker.getStringType(); }, + number: function () { return checker.getNumberType(); }, + Array: function (t) { return checker.createArrayType(t); }, + Promise: function (t) { return checker.createPromiseType(t); }, + }; + var builtins = [ + checker.getStringType(), + checker.getNumberType(), + checker.createArrayType(checker.getAnyType()), + checker.createPromiseType(checker.getAnyType()), + ]; + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function createEmptyUsage() { + return { + isNumber: undefined, + isString: undefined, + isNumberOrString: undefined, + candidateTypes: undefined, + properties: undefined, + calls: undefined, + constructs: undefined, + numberIndex: undefined, + stringIndex: undefined, + candidateThisTypes: undefined, + inferredTypes: undefined, + }; + } + function combineUsages(usages) { + var combinedProperties = ts.createUnderscoreEscapedMap(); + for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) { + var u = usages_1[_i]; + if (u.properties) { + u.properties.forEach(function (p, name) { + if (!combinedProperties.has(name)) { + combinedProperties.set(name, []); + } + combinedProperties.get(name).push(p); + }); + } } - return inferFromContext(usageContext, checker); + var properties = ts.createUnderscoreEscapedMap(); + combinedProperties.forEach(function (ps, name) { + properties.set(name, combineUsages(ps)); + }); + return { + isNumber: usages.some(function (u) { return u.isNumber; }), + isString: usages.some(function (u) { return u.isString; }), + isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }), + candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }), + properties: properties, + calls: ts.flatMap(usages, function (u) { return u.calls; }), + constructs: ts.flatMap(usages, function (u) { return u.constructs; }), + numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }), + stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }), + candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }), + inferredTypes: undefined, + }; + } + function single() { + return combineTypes(inferTypesFromReferencesSingle(references)); } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = createEmptyUsage(); + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = (usageContext.constructContexts || []).concat(usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return 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) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.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])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = combineTypes(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -116257,242 +121596,255 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = createEmptyUsage(); + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return combineTypes(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = createEmptyUsage(); for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferTypes(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 225 /* ExpressionStatement */: + addCandidateType(usage, checker.getVoidType()); + break; + case 207 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 206 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 208 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 193 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 194 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 158 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 241 /* 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)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - usageContext.isNumber = true; + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + usage.isNumber = true; break; - case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + case 39 /* PlusToken */: + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: // MultiplicativeOperator - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + // falls through + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: // ShiftOperator - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // falls through + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator - case 49 /* AmpersandToken */: - case 50 /* BarToken */: - case 51 /* CaretToken */: + // falls through + case 50 /* AmpersandToken */: + case 51 /* BarToken */: + case 52 /* CaretToken */: // CompoundAssignmentOperator - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 71 /* BarEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: + // falls through + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 73 /* BarEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator - case 39 /* MinusToken */: + // falls through + case 40 /* MinusToken */: // RelationalOperator - case 28 /* LessThanToken */: - case 31 /* LessThanEqualsToken */: - case 30 /* GreaterThanToken */: - case 32 /* GreaterThanEqualsToken */: + // falls through + case 29 /* LessThanToken */: + case 32 /* LessThanEqualsToken */: + case 31 /* GreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; - case 61 /* PlusEqualsToken */: - case 38 /* PlusToken */: + case 63 /* PlusEqualsToken */: + case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; + } + else if (otherOperandType.flags & 1 /* Any */) { + // do nothing, maybe we'll learn something elsewhere } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators - case 60 /* EqualsToken */: - case 33 /* EqualsEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + case 62 /* EqualsToken */: + case 34 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 94 /* InKeyword */: + case 96 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; - // LogicalOperator - case 55 /* BarBarToken */: + // LogicalOperator Or NullishCoalescing + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 241 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: // nothing to infer here break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], - returnType: {} + return_: createEmptyUsage() }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.return_); + if (parent.kind === 195 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || createEmptyUsage(); + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = createEmptyUsage(); + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -116501,17 +121853,19 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { - if (fallback === void 0) { fallback = checker.getAnyType(); } + function combineFromUsage(usage) { + return combineTypes(inferTypes(usage)); + } + function combineTypes(inferences) { if (!inferences.length) - return fallback; + return checker.getAnyType(); // 1. string or number individually override string | number // 2. non-any, non-void overrides any or void // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types @@ -116534,12 +121888,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function combineAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -116575,109 +121928,173 @@ var ts; }); 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) { + function inferTypes(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - 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) { - types.push(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 + if (usage.numberIndex) { + types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); } + if (usage.properties && usage.properties.size + || usage.calls && usage.calls.length + || usage.constructs && usage.constructs.length + || usage.stringIndex) { + types.push(inferStructuralType(usage)); + } + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + types.push.apply(types, inferNamedTypesFromProperties(usage)); return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + function inferStructuralType(usage) { + var members = ts.createUnderscoreEscapedMap(); + if (usage.properties) { + usage.properties.forEach(function (u, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = combineFromUsage(u); + members.set(name, symbol); + }); + } + var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; + var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; + var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); + return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 + } + function inferNamedTypesFromProperties(usage) { + if (!usage.properties || !usage.properties.size) + return []; + var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); }); + if (0 < types.length && types.length < 3) { + return types.map(function (t) { return inferInstantiationFromUsage(t, usage); }); } + return []; + } + function allPropertiesAreAssignableToUsage(type, usage) { + if (!usage.properties) + return false; + return !ts.forEachEntry(usage.properties, function (propUsage, name) { + var source = checker.getTypeOfPropertyOfType(type, name); + if (!source) { + return true; + } + if (propUsage.calls) { + var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); + } + else { + return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage)); + } + }); } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + /** + * inference is limited to + * 1. generic types with a single parameter + * 2. inference to/from calls with a single signature + */ + function inferInstantiationFromUsage(type, usage) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + return type; + } + var generic = type.target; + var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters); + if (!singleTypeParameter) + return type; 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])); + usage.properties.forEach(function (propUsage, name) { + var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name); + ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference."); + types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter)); + }); + return builtinConstructors[type.symbol.escapedName](combineTypes(types)); + } + function inferTypeParameters(genericType, usageType, typeParameter) { + if (genericType === typeParameter) { + return [usageType]; + } + else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); + } + else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference + var genericArgs = checker.getTypeArguments(genericType); + var usageArgs = checker.getTypeArguments(usageType); + var types = []; + if (genericArgs && usageArgs) { + for (var i = 0; i < genericArgs.length; i++) { + if (usageArgs[i]) { + types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter)); } } } + return types; } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + if (genericSigs.length === 1 && usageSigs.length === 1) { + return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } - return undefined; + return []; + } + function inferFromSignatures(genericSig, usageSig, typeParameter) { + var types = []; + for (var i = 0; i < genericSig.parameters.length; i++) { + var genericParam = genericSig.parameters[i]; + var usageParam = usageSig.parameters[i]; + var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]); + if (!usageParam) { + break; + } + var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); + if (elementType) { + genericParamType = elementType; + } + var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); + } + var genericReturn = checker.getReturnTypeOfSignature(genericSig); + var usageReturn = checker.getReturnTypeOfSignature(usageSig); + types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter)); + return types; } - function getSignatureFromCallContext(callContext, checker) { + function getFunctionFromCalls(calls) { + return checker.createAnonymousType(undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } + function getSignatureFromCalls(calls) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); + var _loop_12 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); + if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { + symbol.flags |= 16777216 /* Optional */; + } parameters.push(symbol); + }; + for (var i = 0; i < length; i++) { + _loop_12(i); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -116706,12 +122123,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -116743,7 +122160,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(117 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(119 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -116766,7 +122183,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 === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 225 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -116774,27 +122191,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 201 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 222 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -116815,17 +122232,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 200 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 73 /* Identifier */) { + if (node.name.kind !== 75 /* 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, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 88 /* 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 @@ -116836,7 +122253,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 88 /* 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 @@ -116899,12 +122316,12 @@ var ts; return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 122 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 125 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_13 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -116916,7 +122333,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_13(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -117210,10 +122627,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 73 /* Identifier */: // identifier includes undefined + case 75 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -117235,8 +122652,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -117348,6 +122765,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -117439,10 +122857,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -117468,7 +122886,7 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(node.name.text, node, 67220415 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. res.set(text, makeUniqueName("_" + text, identifiers)); } @@ -117488,29 +122906,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 === 60 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 62 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 195 /* 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 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -117550,8 +122968,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -117559,11 +122977,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -117602,18 +123020,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); + case 160 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(88 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -117642,12 +123061,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -117660,7 +123077,7 @@ 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(86 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(88 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -117669,14 +123086,14 @@ var ts; } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(86 /* ExportKeyword */), ts.createToken(78 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(88 /* ExportKeyword */), ts.createToken(80 /* 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(86 /* ExportKeyword */)]; + var modifiers = [ts.createToken(88 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -117684,10 +123101,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -117705,18 +123122,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 188 /* 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 + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 189 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -117727,10 +123146,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -117752,7 +123171,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` var idName = namedBindingsNames.get(propertyName); if (idName === undefined) { idName = makeUniqueName(propertyName, identifiers); @@ -117799,11 +123218,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -117878,8 +123297,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -117906,7 +123327,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -118004,7 +123425,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -118017,7 +123438,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -118025,14 +123446,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -118069,28 +123490,29 @@ var ts; ImportKind[ImportKind["Default"] = 1] = "Default"; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; + ImportKind[ImportKind["ConstEquals"] = 4] = "ConstEquals"; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { - var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); + ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { + function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { var result = []; forEachExternalModule(checker, allSourceFiles, function (moduleSymbol, moduleFile) { // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(sourceFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); if (defaultInfo && defaultInfo.name === symbolName && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); } @@ -118104,7 +123526,7 @@ var ts; return result; } function isTypeOnlySymbol(s, checker) { - return !(ts.skipAlias(s, checker).flags & 67220415 /* Value */); + return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); @@ -118113,7 +123535,7 @@ var ts; var addToExisting = tryAddToExistingImport(existingImports); // Don't bother providing an action to add a new import if we can add to an existing one. var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences); - return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); + return __spreadArrays((useNamespace ? [useNamespace] : ts.emptyArray), addImport); } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -118142,21 +123564,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 253 /* 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 === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 256 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 253 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 255 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -118167,22 +123589,35 @@ 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 === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 253 /* ImportDeclaration */ || i.kind === 252 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } function getNewImportInfos(program, sourceFile, position, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); + var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); - // Sort to keep the shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + // Sort by presence in package.json, then shortest paths first + return ts.sort(choicesForEachExportingModule, function (a, b) { + var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); + var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); + if (allowsImportingA && !allowsImportingB) { + return -1; + } + if (allowsImportingB && !allowsImportingA) { + return 1; + } + return a.moduleSpecifier.length - b.moduleSpecifier.length; + }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -118190,9 +123625,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 253 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 263 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -118202,7 +123637,7 @@ var ts; var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ? getFixesInfoForUMDImport(context, symbolToken) : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken) : undefined; - return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -118212,7 +123647,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } @@ -118224,10 +123659,10 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67220415 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } - function getUmdImportKind(compilerOptions) { + function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { return 1 /* Default */; @@ -118238,6 +123673,9 @@ var ts; case ts.ModuleKind.AMD: case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 4 /* ConstEquals */; + } return 3 /* Equals */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: @@ -118246,7 +123684,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -118259,24 +123697,25 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - ts.Debug.assert(symbolName !== "default" /* Default */); - var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); + var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, host); + var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program, host) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); function addSymbol(moduleSymbol, exportedSymbol, importKind) { originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); } - forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, program.getCompilerOptions()); + var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind); } @@ -118288,20 +123727,41 @@ var ts; }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(moduleSymbol, checker); + function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); if (!exported) return undefined; var symbol = exported.symbol, kind = exported.kind; var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); return info && __assign({ symbol: symbol, kind: kind }, info); } - function getDefaultLikeExportWorker(moduleSymbol, checker) { + function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); if (defaultExport) return { symbol: defaultExport, kind: 1 /* Default */ }; var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); - return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: 3 /* Equals */ }; + return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions, checker) }; + } + function getExportEqualsImportKind(importingFile, compilerOptions, checker) { + if (ts.getAllowSyntheticDefaultImports(compilerOptions) && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return 1 /* Default */; + } + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 1 /* Default */ : 4 /* ConstEquals */; + } + for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isImportEqualsDeclaration(statement)) { + return 3 /* Equals */; + } + if (ts.isImportDeclaration(statement) && statement.importClause && statement.importClause.name) { + var moduleSymbol = checker.getImmediateAliasedSymbol(statement.importClause.symbol); + if (moduleSymbol && moduleSymbol.name !== "default" /* Default */) { + return 1 /* Default */; + } + } + } + return 3 /* Equals */; } function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -118312,7 +123772,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -118328,7 +123788,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -118362,12 +123822,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -118385,7 +123845,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -118410,21 +123870,46 @@ var ts; ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); } if (namespaceLikeImport) { - ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ - ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) - : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) : + namespaceLikeImport.importKind === 4 /* ConstEquals */ ? createConstEqualsRequireDeclaration(namespaceLikeImport.name, quotedModuleSpecifier) : + ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); } } + function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) { + return ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.createIdentifier(name), + /*type*/ undefined, ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) + ], 2 /* Const */)); + } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(checker, from, allSourceFiles, cb) { - forEachExternalModule(checker, allSourceFiles, function (module, sourceFile) { - if (sourceFile === undefined || sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { - cb(module); + function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, cb) { + var filteredCount = 0; + var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host); + var allSourceFiles = program.getSourceFiles(); + forEachExternalModule(program.getTypeChecker(), allSourceFiles, function (module, sourceFile) { + if (sourceFile === undefined) { + if (!packageJson || packageJson.allowsImportingAmbientModule(module, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } + } + else if (sourceFile && sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { + if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } } }); + if (host.log) { + host.log("forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); + } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; function forEachExternalModule(checker, allSourceFiles, cb) { @@ -118479,6 +123964,109 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; + function createAutoImportFilter(fromFile, program, host) { + var packageJsons = host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host); + var dependencyGroups = 1 /* Dependencies */ | 2 /* DevDependencies */ | 8 /* OptionalDependencies */; + // Mix in `getProbablySymlinks` from Program when host doesn't have it + // in order for non-Project hosts to have a symlinks cache. + var moduleSpecifierResolutionHost = { + directoryExists: ts.maybeBind(host, host.directoryExists), + fileExists: ts.maybeBind(host, host.fileExists), + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + readFile: ts.maybeBind(host, host.readFile), + useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || program.getProbableSymlinks, + }; + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName, dependencyGroups) || packageJson.has(ts.getTypesPackageName(packageName), dependencyGroups)) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, allSourceFiles); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, allSourceFiles); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + /** + * Use for a specific module specifier that has already been resolved. + * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve + * the best module specifier for a given module _and_ determine if it’s importable. + */ + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, allSourceFiles) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, allSourceFiles, program.redirectTargetsMap); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -118522,12 +124110,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (property access)"); 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 === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -118556,10 +124144,10 @@ var ts; flags |= 1920 /* Namespace */; } if (meaning & 2 /* Type */) { - flags |= 67897832 /* Type */; + flags |= 788968 /* Type */; } if (meaning & 1 /* Value */) { - flags |= 67220415 /* Value */; + flags |= 111551 /* Value */; } return flags; } @@ -118630,7 +124218,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -118657,7 +124245,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_14(info); } }); })); @@ -118718,7 +124306,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 213 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -118744,7 +124332,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 208 /* 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))); @@ -118754,7 +124342,7 @@ var ts; var contextualType = checker.getContextualType(token.parent); typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; } - return typeNode || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return typeNode || ts.createKeywordTypeNode(124 /* 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); }); @@ -118763,7 +124351,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -118787,7 +124375,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(139 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(142 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -118807,7 +124395,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, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 160 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -119015,7 +124603,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 101 /* ThisKeyword */) + if (token.kind !== 103 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -119054,7 +124642,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 128 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -119098,6 +124686,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -119125,14 +124750,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 87 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 89 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(110 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(112 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 87 /* ExtendsKeyword */ && - heritageClauses[1].token === 110 /* ImplementsKeyword */) { + heritageClauses[0].token === 89 /* ExtendsKeyword */ && + heritageClauses[1].token === 112 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* CommaToken */)); @@ -119219,7 +124844,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 === 28 /* LessThanToken */) { + if (token.kind === 29 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -119239,7 +124864,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* 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)); @@ -119271,7 +124896,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 128 /* InferKeyword */) + if (token.kind === 131 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -119280,7 +124905,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 28 /* LessThanToken */) { + else if (token.kind === 29 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -119290,7 +124915,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -119301,23 +124926,23 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(144 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(147 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 93 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 95 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 155 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -119328,7 +124953,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -119337,7 +124962,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 === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -119346,14 +124971,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 155 /* Parameter */: + case 154 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return true; } } @@ -119400,26 +125025,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 160 /* 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 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* 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); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 75 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -119455,11 +125080,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); 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 223 /* IfStatement */: + case 226 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -119470,15 +125095,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -119520,7 +125145,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, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -119544,7 +125169,7 @@ 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 === 292 /* JSDocNullableType */) { + if (typeNode.kind === 295 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -119564,7 +125189,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 295 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -119581,22 +125206,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 216 /* AsExpression */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 162 /* GetAccessor */: + case 166 /* IndexSignature */: + case 185 /* MappedType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 198 /* TypeAssertionExpression */: + case 241 /* VariableDeclaration */: return true; default: return false; @@ -119625,12 +125250,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -119650,14 +125278,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 93 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -119672,11 +125300,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 73 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 75 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 122 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 125 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -119784,18 +125412,40 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); + var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); switch (declaration.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 158 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: { + var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); + var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + var orderedAccessors = allAccessors.secondAccessor + ? [allAccessors.firstAccessor, allAccessors.secondAccessor] + : [allAccessors.firstAccessor]; + for (var _i = 0, orderedAccessors_1 = orderedAccessors; _i < orderedAccessors_1.length; _i++) { + var accessor = orderedAccessors_1[_i]; + if (ts.isGetAccessorDeclaration(accessor)) { + out(ts.createGetAccessor( + /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); + } + else { + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); + var parameter = ts.getSetAccessorValueParameter(accessor); + var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; + out(ts.createSetAccessor( + /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(preferences))); + } + } + break; + } + case 159 /* MethodSignature */: + case 160 /* 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 @@ -119808,23 +125458,25 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; } - for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { - var signature = signatures_1[_i]; + for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) { + var signature = signatures_1[_a]; // 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)); } - if (declarations.length > signatures.length) { - var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); - } - else { - ts.Debug.assert(declarations.length === signatures.length); - out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + if (!ambient) { + if (declarations.length > signatures.length) { + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + } + else { + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); + out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + } } break; } @@ -119836,14 +125488,14 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 160 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(57 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -119857,15 +125509,14 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(41 /* 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); @@ -119882,8 +125533,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(121 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(124 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -119911,11 +125562,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(121 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(124 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -119926,7 +125577,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -119937,10 +125588,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(116 /* PublicKeyword */); + return ts.createToken(118 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(115 /* ProtectedKeyword */); + return ts.createToken(117 /* ProtectedKeyword */); } return undefined; } @@ -120012,7 +125663,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 195 /* CallExpression */ : 196 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -120123,7 +125774,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(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -120131,7 +125782,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(142 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(145 /* 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)); @@ -120252,6 +125903,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -120273,8 +125957,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 95 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 187 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -120326,8 +126010,8 @@ 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(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); - var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(137 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); @@ -120357,7 +126041,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 123 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 126 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -120368,7 +126052,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 96 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 98 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -120379,6 +126063,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -120395,8 +126113,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -120416,16 +126134,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -120434,7 +126152,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + ts.Debug.assert(!wasDefault, "Can't have a default flag here"); return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } default: @@ -120448,40 +126166,40 @@ 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, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 83 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 88 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(83 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 224 /* 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. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* 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))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -120495,27 +126213,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 257 /* ImportSpecifier */: + case 261 /* 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 251 /* ImportClause */: { + case 254 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 255 /* 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 */; @@ -120536,11 +126254,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 257 /* 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); @@ -120553,7 +126271,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 261 /* 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";` @@ -120562,7 +126280,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -120586,13 +126304,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 255 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 255 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -120609,7 +126327,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 255 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -120630,7 +126348,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -120669,7 +126387,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -120688,7 +126406,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -120809,6 +126527,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -120900,6 +126619,9 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -120952,20 +126674,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 158 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 155 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 161 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 160 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -120983,13 +126705,13 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 4194304 /* Ambient */) { + if (nodeToCheck.flags & 8388608 /* Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -121008,7 +126730,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 241 /* 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`! @@ -121020,13 +126742,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 99 /* SuperKeyword */: + case 101 /* 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 === 192 /* CallExpression */) { + if (node.parent.kind === 195 /* 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)) { @@ -121041,8 +126763,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -121054,20 +126776,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 222 /* Block */: + if (node.parent && node.parent.kind === 239 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -121079,19 +126801,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 182 /* ThisType */: + case 103 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -121100,20 +126822,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 233 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -121167,7 +126889,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 === 152 /* Parameter */) { + if (current.kind === 155 /* 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; } @@ -121178,7 +126900,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 288 /* SourceFile */) { return scopes; } } @@ -121268,32 +126990,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 244 /* 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 === 246 /* ModuleBlock */ + return scope.kind === 249 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -121359,20 +127081,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(114 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(116 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(122 /* AsyncKeyword */)); + modifiers.push(ts.createToken(125 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(122 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(125 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* 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; @@ -121389,7 +127111,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(40 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(41 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -121397,8 +127119,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -121466,7 +127188,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -121513,9 +127235,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 142 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 145 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(142 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); } } /** @@ -121523,6 +127245,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -121533,16 +127256,17 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(114 /* PrivateKeyword */)); + modifiers.push(ts.createToken(116 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } - modifiers.push(ts.createToken(134 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(137 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -121571,7 +127295,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 225 /* 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( @@ -121590,7 +127314,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 225 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -121604,6 +127328,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -121677,7 +127458,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 234 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -121740,11 +127521,11 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; - for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { - var member = members_2[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.pos > maxPos) { return prevMember || members[0]; } @@ -121782,11 +127563,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -121855,7 +127636,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 !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 243 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -121908,7 +127689,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -121918,7 +127699,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -121940,7 +127721,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -121958,7 +127739,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -122171,30 +127952,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 282 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 253 /* ImportDeclaration */ && + parent.kind !== 257 /* ImportSpecifier */; + case 212 /* SpreadElement */: + case 188 /* ObjectBindingPattern */: + case 190 /* BindingElement */: return false; - case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + case 75 /* Identifier */: + return parent.kind !== 190 /* BindingElement */ && + parent.kind !== 257 /* ImportSpecifier */ && + parent.kind !== 261 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 222 /* Block */: + case 288 /* SourceFile */: + case 249 /* ModuleBlock */: + case 275 /* CaseClause */: return true; default: return false; @@ -122210,6 +127991,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -122219,22 +128001,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -122249,11 +128043,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; + } + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function isStatementAndHasJSDoc(n) { return ts.isStatement(n) && ts.hasJSDocNodes(n); @@ -122290,7 +128109,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 67220415 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); if (symbol && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -122304,15 +128123,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(311 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(315 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -122320,10 +128150,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(310 /* JSDocTemplateTag */); + var template = ts.createNode(314 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(154 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -122373,10 +128203,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 116 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 118 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 114 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 116 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -122404,7 +128234,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -122414,7 +128244,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(117 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(119 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -122437,7 +128267,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 155 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -122483,24 +128313,22 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 101 /* ThisKeyword */ && + node.expression.kind === 103 /* ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 103 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -122525,7 +128353,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -122582,11 +128410,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -122621,7 +128449,7 @@ var ts; deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return __spreadArrays(getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference), addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { @@ -122639,10 +128467,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -122664,25 +128492,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 253 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 255 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -122710,20 +128538,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 253 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 252 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -122765,7 +128593,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -122793,19 +128621,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -122814,7 +128642,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 255 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -122824,9 +128652,9 @@ var ts; } if (namedBindings) { if (namedBindingsUnused) { - changes.delete(sourceFile, namedBindings); + changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 256 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -122839,14 +128667,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 188 /* 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); } @@ -122920,7 +128748,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -122973,13 +128801,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -122991,7 +128819,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -123001,18 +128829,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -123022,11 +128850,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 188 /* 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; @@ -123078,18 +128906,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -123097,17 +128925,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -123117,13 +128945,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -123131,9 +128959,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -123164,55 +128992,55 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(88 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { - return [decl].concat(getNamesToExportInCommonJS(decl).map(createExportAssignment)); + return __spreadArrays([decl], getNamesToExportInCommonJS(decl).map(createExportAssignment)); } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 225 /* ExpressionStatement */: + return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 60 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 62 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -123335,7 +129163,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -123367,7 +129195,7 @@ var ts; function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); var classNames = ts.isConstructorDeclaration(functionDeclaration) ? getClassNames(functionDeclaration) : []; - var names = ts.deduplicate(functionNames.concat(classNames), ts.equateValues); + var names = ts.deduplicate(__spreadArrays(functionNames, classNames), ts.equateValues); var checker = program.getTypeChecker(); var references = ts.flatMap(names, /*mapfn*/ function (/*mapfn*/ name) { return ts.FindAllReferences.getReferenceEntriesForNode(-1, name, program, program.getSourceFiles(), cancellationToken); }); var groupedReferences = groupReferences(references); @@ -123474,15 +129302,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -123492,7 +129320,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -123511,14 +129339,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -123560,11 +129388,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 161 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -123572,8 +129400,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -123583,7 +129411,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 81 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 83 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -123698,7 +129526,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(56 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, /*initializer*/ undefined); ts.suppressLeadingAndTrailingTrivia(propertySignature); copyComments(parameterDeclaration.name, propertySignature.name); @@ -123744,15 +129572,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 83 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -123763,30 +129591,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 83 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: - var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + case 161 /* Constructor */: + var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 128 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 213 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -123798,10 +129626,10 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 73 /* Identifier */ ? new IdentifierObject(73 /* Identifier */, pos, end) : + kind === 75 /* Identifier */ ? new IdentifierObject(75 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 12679168 /* ContextFlags */; + node.flags = parent.flags & 25358336 /* ContextFlags */; return node; } var NodeObject = /** @class */ (function () { @@ -123815,7 +129643,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -123872,8 +129700,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 312 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 292 /* FirstJSDocNode */ || kid.kind > 316 /* LastJSDocNode */; }); + return child.kind < 152 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -123884,7 +129712,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 152 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -123930,7 +129758,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 73 /* Identifier */) { + if (token === 75 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -123942,7 +129770,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(313 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(317 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -124065,7 +129893,9 @@ var ts; var IdentifierObject = /** @class */ (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { - return _super.call(this, pos, end) || this; + var _this = _super.call(this, pos, end) || this; + _this.kind = 75 /* Identifier */; + return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { get: function () { @@ -124076,7 +129906,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 73 /* Identifier */; + IdentifierObject.prototype.kind = 75 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -124112,9 +129942,15 @@ var ts; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; }; + TypeObject.prototype.isNullableType = function () { + return this.checker.isNullableType(this); + }; TypeObject.prototype.getNonNullableType = function () { return this.checker.getNonNullableType(this); }; + TypeObject.prototype.getNonOptionalType = function () { + return this.checker.getNonOptionalType(this); + }; TypeObject.prototype.getConstraint = function () { return this.checker.getBaseConstraintOfType(this); }; @@ -124219,7 +130055,9 @@ var ts; var SourceFileObject = /** @class */ (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - return _super.call(this, kind, pos, end) || this; + var _this = _super.call(this, kind, pos, end) || this; + _this.kind = 288 /* SourceFile */; + return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -124277,10 +130115,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -124300,31 +130138,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 172 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -124335,19 +130173,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 259 /* 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 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -124359,7 +130197,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -124368,7 +130206,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -124565,7 +130403,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -124685,16 +130523,20 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; }, getCurrentDirectory: function () { return currentDirectory; }, getProgram: getProgram, - fileExists: host.fileExists && (function (f) { return host.fileExists(f); }), - readFile: host.readFile && (function (f, encoding) { return host.readFile(f, encoding); }), - getDocumentPositionMapper: host.getDocumentPositionMapper && (function (generatedFileName, sourceFileName) { return host.getDocumentPositionMapper(generatedFileName, sourceFileName); }), - getSourceFileLike: host.getSourceFileLike && (function (f) { return host.getSourceFileLike(f); }), + fileExists: ts.maybeBind(host, host.fileExists), + readFile: ts.maybeBind(host, host.readFile), + getDocumentPositionMapper: ts.maybeBind(host, host.getDocumentPositionMapper), + getSourceFileLike: ts.maybeBind(host, host.getSourceFileLike), log: log }); function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - throw new Error("Could not find sourceFile: '" + fileName + "' in " + (program && JSON.stringify(program.getSourceFiles().map(function (f) { return f.fileName; }))) + "."); + var error = new Error("Could not find source file: '" + fileName + "'."); + // We've been having trouble debugging this, so attach sidecar data for the tsserver log. + // See https://github.com/microsoft/TypeScript/issues/30180. + error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); + throw error; } return sourceFile; } @@ -124763,13 +130605,29 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; + compilerHost.resolveModuleNames = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); + compilerHost.resolveTypeReferenceDirectives = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); }; } + if (host.setResolvedProjectReferenceCallbacks) { + compilerHost.setResolvedProjectReferenceCallbacks = function (callbacks) { return host.setResolvedProjectReferenceCallbacks(callbacks); }; + } + if (host.useSourceOfProjectReferenceRedirect) { + compilerHost.useSourceOfProjectReferenceRedirect = function () { return host.useSourceOfProjectReferenceRedirect(); }; + } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -124905,7 +130763,7 @@ var ts; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return semanticDiagnostics.concat(declarationDiagnostics); + return __spreadArrays(semanticDiagnostics, declarationDiagnostics); } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); @@ -124913,12 +130771,12 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + return __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names - var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); + var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } @@ -124930,7 +130788,7 @@ var ts; } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); - return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }); + return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host); } function getQuickInfoAtPosition(fileName, position) { synchronizeHostData(); @@ -124974,15 +130832,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 99 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 101 /* SuperKeyword */: return true; default: return false; @@ -125008,13 +130866,13 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }, highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); + var sourceFilesToSearch = ts.mapDefined(filesToSearch, function (fileName) { return program.getSourceFile(fileName); }); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -125084,16 +130942,16 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: case 10 /* StringLiteral */: - case 88 /* FalseKeyword */: - case 103 /* TrueKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 73 /* Identifier */: + case 90 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 75 /* Identifier */: break; // Cant create the text span default: @@ -125109,7 +130967,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 === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 248 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -125174,7 +131032,7 @@ var ts; _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, + _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -125298,7 +131156,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -125561,7 +131419,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 263 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -125577,14 +131435,15 @@ var ts; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 153 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 192 /* ObjectLiteralExpression */ || node.parent.parent.kind === 272 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -125626,7 +131485,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -125673,7 +131532,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 4194304 /* Ambient */) { + if (tokenAtLocation.flags & 8388608 /* Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -125706,114 +131565,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 190 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 156 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -125831,19 +131690,19 @@ var ts; return spanInOpenParenToken(node); case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 57 /* ColonToken */: + case 58 /* ColonToken */: return spanInColonToken(node); - case 30 /* GreaterThanToken */: - case 28 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return spanInWhileKeyword(node); - case 84 /* ElseKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + case 86 /* ElseKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 151 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -125855,14 +131714,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 === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + if ((node.kind === 75 /* Identifier */ || + node.kind === 212 /* SpreadElement */ || + node.kind === 279 /* PropertyAssignment */ || + node.kind === 280 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 208 /* 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 @@ -125871,7 +131730,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 60 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -125884,22 +131743,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 156 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 208 /* 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 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -125908,21 +131767,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 279 /* 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 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 241 /* VariableDeclaration */: + case 155 /* 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)) { @@ -125930,7 +131789,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -125960,7 +131819,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 230 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -125972,7 +131831,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 231 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -126013,7 +131872,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 244 /* ClassDeclaration */ && functionDeclaration.kind !== 161 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -126036,26 +131895,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 230 /* 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 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* 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 === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 242 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -126080,21 +131939,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 190 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 189 /* ArrayBindingPattern */ && node.kind !== 188 /* ObjectBindingPattern */); + var elements = node.kind === 191 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -126102,18 +131961,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 === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 208 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -126121,25 +131980,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 249 /* 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 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -126147,7 +132006,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 188 /* 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); @@ -126163,7 +132022,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 189 /* 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); @@ -126178,12 +132037,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 227 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 195 /* CallExpression */ || + node.parent.kind === 196 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 199 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -126192,21 +132051,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 199 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -126216,20 +132075,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 279 /* PropertyAssignment */ || + node.parent.kind === 155 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 198 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 227 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -126237,7 +132096,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 231 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -126282,10 +132141,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -126307,9 +132165,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -126380,6 +132240,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -126408,6 +132269,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -126419,6 +132281,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -126562,13 +132425,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -126576,13 +132439,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -126953,7 +132817,7 @@ var ts; typeAcquisition: configFile.typeAcquisition, files: configFile.fileNames, raw: configFile.raw, - errors: realizeDiagnostics(result.parseDiagnostics.concat(configFile.errors), "\r\n") + errors: realizeDiagnostics(__spreadArrays(result.parseDiagnostics, configFile.errors), "\r\n") }; }); }; @@ -127040,8 +132904,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index e47b92d5fec71..65a0812289917 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.6"; + const versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ const version: string; } @@ -65,17 +65,17 @@ declare namespace ts { } } declare namespace ts { - type Path = string & { + export type Path = string & { __pathBrand: any; }; - interface TextRange { + export interface TextRange { pos: number; end: number; } - type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - 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 { + export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | 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; + export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; + export enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, @@ -104,359 +104,367 @@ declare namespace ts { 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, + QuestionDotToken = 28, + LessThanToken = 29, + LessThanSlashToken = 30, + GreaterThanToken = 31, + LessThanEqualsToken = 32, + GreaterThanEqualsToken = 33, + EqualsEqualsToken = 34, + ExclamationEqualsToken = 35, + EqualsEqualsEqualsToken = 36, + ExclamationEqualsEqualsToken = 37, + EqualsGreaterThanToken = 38, + PlusToken = 39, + MinusToken = 40, + AsteriskToken = 41, + AsteriskAsteriskToken = 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 = 58, + AtToken = 59, + QuestionQuestionToken = 60, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - BacktickToken = 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 = 72, - Identifier = 73, - BreakKeyword = 74, - CaseKeyword = 75, - CatchKeyword = 76, - ClassKeyword = 77, - ConstKeyword = 78, - ContinueKeyword = 79, - DebuggerKeyword = 80, - DefaultKeyword = 81, - DeleteKeyword = 82, - DoKeyword = 83, - ElseKeyword = 84, - EnumKeyword = 85, - ExportKeyword = 86, - ExtendsKeyword = 87, - FalseKeyword = 88, - FinallyKeyword = 89, - ForKeyword = 90, - FunctionKeyword = 91, - IfKeyword = 92, - ImportKeyword = 93, - InKeyword = 94, - InstanceOfKeyword = 95, - NewKeyword = 96, - NullKeyword = 97, - ReturnKeyword = 98, - SuperKeyword = 99, - SwitchKeyword = 100, - ThisKeyword = 101, - ThrowKeyword = 102, - TrueKeyword = 103, - TryKeyword = 104, - TypeOfKeyword = 105, - VarKeyword = 106, - VoidKeyword = 107, - WhileKeyword = 108, - WithKeyword = 109, - ImplementsKeyword = 110, - InterfaceKeyword = 111, - LetKeyword = 112, - PackageKeyword = 113, - PrivateKeyword = 114, - ProtectedKeyword = 115, - PublicKeyword = 116, - StaticKeyword = 117, - YieldKeyword = 118, - AbstractKeyword = 119, - AsKeyword = 120, - AnyKeyword = 121, - AsyncKeyword = 122, - AwaitKeyword = 123, - BooleanKeyword = 124, - ConstructorKeyword = 125, - DeclareKeyword = 126, - GetKeyword = 127, - InferKeyword = 128, - IsKeyword = 129, - KeyOfKeyword = 130, - ModuleKeyword = 131, - NamespaceKeyword = 132, - NeverKeyword = 133, - ReadonlyKeyword = 134, - RequireKeyword = 135, - NumberKeyword = 136, - ObjectKeyword = 137, - SetKeyword = 138, - StringKeyword = 139, - SymbolKeyword = 140, - TypeKeyword = 141, - UndefinedKeyword = 142, - UniqueKeyword = 143, - UnknownKeyword = 144, - FromKeyword = 145, - GlobalKeyword = 146, - BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocComment = 297, - JSDocTypeLiteral = 298, - JSDocSignature = 299, - JSDocTag = 300, - JSDocAugmentsTag = 301, - JSDocAuthorTag = 302, - JSDocClassTag = 303, - JSDocCallbackTag = 304, - JSDocEnumTag = 305, - JSDocParameterTag = 306, - JSDocReturnTag = 307, - JSDocThisTag = 308, - JSDocTypeTag = 309, - JSDocTemplateTag = 310, - JSDocTypedefTag = 311, - JSDocPropertyTag = 312, - SyntaxList = 313, - NotEmittedStatement = 314, - PartiallyEmittedExpression = 315, - CommaListExpression = 316, - MergeDeclarationMarker = 317, - EndOfDeclarationMarker = 318, - Count = 319, - FirstAssignment = 60, - LastAssignment = 72, - FirstCompoundAssignment = 61, - LastCompoundAssignment = 72, - FirstReservedWord = 74, - LastReservedWord = 109, - FirstKeyword = 74, - LastKeyword = 148, - FirstFutureReservedWord = 110, - LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + BacktickToken = 61, + EqualsToken = 62, + PlusEqualsToken = 63, + MinusEqualsToken = 64, + AsteriskEqualsToken = 65, + AsteriskAsteriskEqualsToken = 66, + SlashEqualsToken = 67, + PercentEqualsToken = 68, + LessThanLessThanEqualsToken = 69, + GreaterThanGreaterThanEqualsToken = 70, + GreaterThanGreaterThanGreaterThanEqualsToken = 71, + AmpersandEqualsToken = 72, + BarEqualsToken = 73, + CaretEqualsToken = 74, + Identifier = 75, + BreakKeyword = 76, + CaseKeyword = 77, + CatchKeyword = 78, + ClassKeyword = 79, + ConstKeyword = 80, + ContinueKeyword = 81, + DebuggerKeyword = 82, + DefaultKeyword = 83, + DeleteKeyword = 84, + DoKeyword = 85, + ElseKeyword = 86, + EnumKeyword = 87, + ExportKeyword = 88, + ExtendsKeyword = 89, + FalseKeyword = 90, + FinallyKeyword = 91, + ForKeyword = 92, + FunctionKeyword = 93, + IfKeyword = 94, + ImportKeyword = 95, + InKeyword = 96, + InstanceOfKeyword = 97, + NewKeyword = 98, + NullKeyword = 99, + ReturnKeyword = 100, + SuperKeyword = 101, + SwitchKeyword = 102, + ThisKeyword = 103, + ThrowKeyword = 104, + TrueKeyword = 105, + TryKeyword = 106, + TypeOfKeyword = 107, + VarKeyword = 108, + VoidKeyword = 109, + WhileKeyword = 110, + WithKeyword = 111, + ImplementsKeyword = 112, + InterfaceKeyword = 113, + LetKeyword = 114, + PackageKeyword = 115, + PrivateKeyword = 116, + ProtectedKeyword = 117, + PublicKeyword = 118, + StaticKeyword = 119, + YieldKeyword = 120, + AbstractKeyword = 121, + AsKeyword = 122, + AssertsKeyword = 123, + AnyKeyword = 124, + AsyncKeyword = 125, + AwaitKeyword = 126, + BooleanKeyword = 127, + ConstructorKeyword = 128, + DeclareKeyword = 129, + GetKeyword = 130, + InferKeyword = 131, + IsKeyword = 132, + KeyOfKeyword = 133, + ModuleKeyword = 134, + NamespaceKeyword = 135, + NeverKeyword = 136, + ReadonlyKeyword = 137, + RequireKeyword = 138, + NumberKeyword = 139, + ObjectKeyword = 140, + SetKeyword = 141, + StringKeyword = 142, + SymbolKeyword = 143, + TypeKeyword = 144, + UndefinedKeyword = 145, + UniqueKeyword = 146, + UnknownKeyword = 147, + FromKeyword = 148, + GlobalKeyword = 149, + BigIntKeyword = 150, + OfKeyword = 151, + QualifiedName = 152, + ComputedPropertyName = 153, + TypeParameter = 154, + Parameter = 155, + Decorator = 156, + PropertySignature = 157, + PropertyDeclaration = 158, + MethodSignature = 159, + MethodDeclaration = 160, + Constructor = 161, + GetAccessor = 162, + SetAccessor = 163, + CallSignature = 164, + ConstructSignature = 165, + IndexSignature = 166, + TypePredicate = 167, + TypeReference = 168, + FunctionType = 169, + ConstructorType = 170, + TypeQuery = 171, + TypeLiteral = 172, + ArrayType = 173, + TupleType = 174, + OptionalType = 175, + RestType = 176, + UnionType = 177, + IntersectionType = 178, + ConditionalType = 179, + InferType = 180, + ParenthesizedType = 181, + ThisType = 182, + TypeOperator = 183, + IndexedAccessType = 184, + MappedType = 185, + LiteralType = 186, + ImportType = 187, + ObjectBindingPattern = 188, + ArrayBindingPattern = 189, + BindingElement = 190, + ArrayLiteralExpression = 191, + ObjectLiteralExpression = 192, + PropertyAccessExpression = 193, + ElementAccessExpression = 194, + CallExpression = 195, + NewExpression = 196, + TaggedTemplateExpression = 197, + TypeAssertionExpression = 198, + ParenthesizedExpression = 199, + FunctionExpression = 200, + ArrowFunction = 201, + DeleteExpression = 202, + TypeOfExpression = 203, + VoidExpression = 204, + AwaitExpression = 205, + PrefixUnaryExpression = 206, + PostfixUnaryExpression = 207, + BinaryExpression = 208, + ConditionalExpression = 209, + TemplateExpression = 210, + YieldExpression = 211, + SpreadElement = 212, + ClassExpression = 213, + OmittedExpression = 214, + ExpressionWithTypeArguments = 215, + AsExpression = 216, + NonNullExpression = 217, + MetaProperty = 218, + SyntheticExpression = 219, + TemplateSpan = 220, + SemicolonClassElement = 221, + Block = 222, + EmptyStatement = 223, + VariableStatement = 224, + ExpressionStatement = 225, + IfStatement = 226, + DoStatement = 227, + WhileStatement = 228, + ForStatement = 229, + ForInStatement = 230, + ForOfStatement = 231, + ContinueStatement = 232, + BreakStatement = 233, + ReturnStatement = 234, + WithStatement = 235, + SwitchStatement = 236, + LabeledStatement = 237, + ThrowStatement = 238, + TryStatement = 239, + DebuggerStatement = 240, + VariableDeclaration = 241, + VariableDeclarationList = 242, + FunctionDeclaration = 243, + ClassDeclaration = 244, + InterfaceDeclaration = 245, + TypeAliasDeclaration = 246, + EnumDeclaration = 247, + ModuleDeclaration = 248, + ModuleBlock = 249, + CaseBlock = 250, + NamespaceExportDeclaration = 251, + ImportEqualsDeclaration = 252, + ImportDeclaration = 253, + ImportClause = 254, + NamespaceImport = 255, + NamedImports = 256, + ImportSpecifier = 257, + ExportAssignment = 258, + ExportDeclaration = 259, + NamedExports = 260, + ExportSpecifier = 261, + MissingDeclaration = 262, + ExternalModuleReference = 263, + JsxElement = 264, + JsxSelfClosingElement = 265, + JsxOpeningElement = 266, + JsxClosingElement = 267, + JsxFragment = 268, + JsxOpeningFragment = 269, + JsxClosingFragment = 270, + JsxAttribute = 271, + JsxAttributes = 272, + JsxSpreadAttribute = 273, + JsxExpression = 274, + CaseClause = 275, + DefaultClause = 276, + HeritageClause = 277, + CatchClause = 278, + PropertyAssignment = 279, + ShorthandPropertyAssignment = 280, + SpreadAssignment = 281, + EnumMember = 282, + UnparsedPrologue = 283, + UnparsedPrepend = 284, + UnparsedText = 285, + UnparsedInternalText = 286, + UnparsedSyntheticReference = 287, + SourceFile = 288, + Bundle = 289, + UnparsedSource = 290, + InputFiles = 291, + JSDocTypeExpression = 292, + JSDocAllType = 293, + JSDocUnknownType = 294, + JSDocNullableType = 295, + JSDocNonNullableType = 296, + JSDocOptionalType = 297, + JSDocFunctionType = 298, + JSDocVariadicType = 299, + JSDocNamepathType = 300, + JSDocComment = 301, + JSDocTypeLiteral = 302, + JSDocSignature = 303, + JSDocTag = 304, + JSDocAugmentsTag = 305, + JSDocAuthorTag = 306, + JSDocClassTag = 307, + JSDocCallbackTag = 308, + JSDocEnumTag = 309, + JSDocParameterTag = 310, + JSDocReturnTag = 311, + JSDocThisTag = 312, + JSDocTypeTag = 313, + JSDocTemplateTag = 314, + JSDocTypedefTag = 315, + JSDocPropertyTag = 316, + SyntaxList = 317, + NotEmittedStatement = 318, + PartiallyEmittedExpression = 319, + CommaListExpression = 320, + MergeDeclarationMarker = 321, + EndOfDeclarationMarker = 322, + SyntheticReferenceExpression = 323, + Count = 324, + FirstAssignment = 62, + LastAssignment = 74, + FirstCompoundAssignment = 63, + LastCompoundAssignment = 74, + FirstReservedWord = 76, + LastReservedWord = 111, + FirstKeyword = 76, + LastKeyword = 151, + FirstFutureReservedWord = 112, + LastFutureReservedWord = 120, + FirstTypeNode = 167, + LastTypeNode = 187, FirstPunctuation = 18, - LastPunctuation = 72, + LastPunctuation = 74, FirstToken = 0, - LastToken = 148, + LastToken = 151, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, LastLiteralToken = 14, FirstTemplateToken = 14, LastTemplateToken = 17, - FirstBinaryOperator = 28, - LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 312, - FirstJSDocTagNode = 300, - LastJSDocTagNode = 312, - } - enum NodeFlags { + FirstBinaryOperator = 29, + LastBinaryOperator = 74, + FirstStatement = 224, + LastStatement = 240, + FirstNode = 152, + FirstJSDocNode = 292, + LastJSDocNode = 316, + FirstJSDocTagNode = 304, + LastJSDocTagNode = 316, + } + export enum NodeFlags { None = 0, Let = 1, Const = 2, NestedNamespace = 4, Synthesized = 8, Namespace = 16, - ExportContext = 32, - ContainsThis = 64, - HasImplicitReturn = 128, - HasExplicitReturn = 256, - GlobalAugmentation = 512, - HasAsyncFunctions = 1024, - DisallowInContext = 2048, - YieldContext = 4096, - DecoratorContext = 8192, - AwaitContext = 16384, - ThisNodeHasError = 32768, - JavaScriptFile = 65536, - ThisNodeOrAnySubNodesHasError = 131072, - HasAggregatedChildData = 262144, - JSDoc = 2097152, - JsonFile = 16777216, + OptionalChain = 32, + ExportContext = 64, + ContainsThis = 128, + HasImplicitReturn = 256, + HasExplicitReturn = 512, + GlobalAugmentation = 1024, + HasAsyncFunctions = 2048, + DisallowInContext = 4096, + YieldContext = 8192, + DecoratorContext = 16384, + AwaitContext = 32768, + ThisNodeHasError = 65536, + JavaScriptFile = 131072, + ThisNodeOrAnySubNodesHasError = 262144, + HasAggregatedChildData = 524288, + JSDoc = 4194304, + JsonFile = 33554432, BlockScoped = 3, - ReachabilityCheckFlags = 384, - ReachabilityAndEmitFlags = 1408, - ContextFlags = 12679168, - TypeExcludesFlags = 20480, + ReachabilityCheckFlags = 768, + ReachabilityAndEmitFlags = 2816, + ContextFlags = 25358336, + TypeExcludesFlags = 40960, } - enum ModifierFlags { + export enum ModifierFlags { None = 0, Export = 1, Ambient = 2, @@ -477,7 +485,7 @@ declare namespace ts { ExportDefault = 513, All = 3071 } - enum JsxFlags { + export enum JsxFlags { None = 0, /** An element from a named property of the JSX.IntrinsicElements interface */ IntrinsicNamedElement = 1, @@ -485,40 +493,43 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3 } - interface Node extends TextRange { + export interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; decorators?: NodeArray; modifiers?: ModifiersArray; parent: Node; } - interface JSDocContainer { + export interface JSDocContainer { } - type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; - type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; - type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; - type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; - interface NodeArray extends ReadonlyArray, TextRange { + export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; + export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; + export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; + export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; + export interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; } - interface Token extends Node { + export interface Token extends Node { kind: TKind; } - type DotDotDotToken = Token; - type QuestionToken = Token; - type ExclamationToken = Token; - type ColonToken = Token; - type EqualsToken = Token; - type AsteriskToken = Token; - type EqualsGreaterThanToken = Token; - type EndOfFileToken = Token & JSDocContainer; - type ReadonlyToken = Token; - type AwaitKeywordToken = Token; - type PlusToken = Token; - type MinusToken = Token; - type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; - type ModifiersArray = NodeArray; - interface Identifier extends PrimaryExpression, Declaration { + export type DotToken = Token; + export type DotDotDotToken = Token; + export type QuestionToken = Token; + export type QuestionDotToken = Token; + export type ExclamationToken = Token; + export type ColonToken = Token; + export type EqualsToken = Token; + export type AsteriskToken = Token; + export type EqualsGreaterThanToken = Token; + export type EndOfFileToken = Token & JSDocContainer; + export type ReadonlyToken = Token; + export type AwaitKeywordToken = Token; + export type PlusToken = Token; + export type MinusToken = Token; + export type AssertsToken = Token; + export type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; + export type ModifiersArray = NodeArray; + export interface Identifier extends PrimaryExpression, Declaration { kind: SyntaxKind.Identifier; /** * Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.) @@ -528,37 +539,37 @@ declare namespace ts { originalKeywordKind?: SyntaxKind; isInJSDocNamespace?: boolean; } - interface TransientIdentifier extends Identifier { + export interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } - interface QualifiedName extends Node { + export interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } - type EntityName = Identifier | QualifiedName; - type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; - interface Declaration extends Node { + export type EntityName = Identifier | QualifiedName; + export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; + export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression; + export interface Declaration extends Node { _declarationBrand: any; } - interface NamedDeclaration extends Declaration { + export interface NamedDeclaration extends Declaration { name?: DeclarationName; } - interface DeclarationStatement extends NamedDeclaration, Statement { + export interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } - interface ComputedPropertyName extends Node { + export interface ComputedPropertyName extends Node { parent: Declaration; kind: SyntaxKind.ComputedPropertyName; expression: Expression; } - interface Decorator extends Node { + export interface Decorator extends Node { kind: SyntaxKind.Decorator; parent: NamedDeclaration; expression: LeftHandSideExpression; } - interface TypeParameterDeclaration extends NamedDeclaration { + export interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; parent: DeclarationWithTypeParameterChildren | InferTypeNode; name: Identifier; @@ -567,22 +578,22 @@ declare namespace ts { default?: TypeNode; expression?: Expression; } - interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { + export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; type?: TypeNode; } - type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; - interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; + export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } - interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { + export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } - type BindingName = Identifier | BindingPattern; - interface VariableDeclaration extends NamedDeclaration { + export type BindingName = Identifier | BindingPattern; + export interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; parent: VariableDeclarationList | CatchClause; name: BindingName; @@ -590,12 +601,12 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface VariableDeclarationList extends Node { + export interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; parent: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } - interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { + export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; @@ -604,7 +615,7 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface BindingElement extends NamedDeclaration { + export interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; parent: BindingPattern; propertyName?: PropertyName; @@ -612,14 +623,14 @@ declare namespace ts { name: BindingName; initializer?: Expression; } - interface PropertySignature extends TypeElement, JSDocContainer { + export interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } - interface PropertyDeclaration extends ClassElement, JSDocContainer { + export interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; parent: ClassLikeDeclaration; name: PropertyName; @@ -628,20 +639,20 @@ declare namespace ts { type?: TypeNode; initializer?: Expression; } - interface ObjectLiteralElement extends NamedDeclaration { + export interface ObjectLiteralElement extends NamedDeclaration { _objectLiteralBrand: any; name?: PropertyName; } /** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */ - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; - interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; + export interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; initializer: Expression; } - interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { + export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; @@ -650,27 +661,27 @@ declare namespace ts { equalsToken?: Token; objectAssignmentInitializer?: Expression; } - interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { + export interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } - type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; - interface PropertyLikeDeclaration extends NamedDeclaration { + export type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; + export interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; } - interface ObjectBindingPattern extends Node { + export interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - interface ArrayBindingPattern extends Node { + export interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } - type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; - type ArrayBindingElement = BindingElement | OmittedExpression; + export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; + export type ArrayBindingElement = BindingElement | OmittedExpression; /** * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclarationBase. @@ -679,298 +690,299 @@ declare namespace ts { * - MethodDeclaration * - AccessorDeclaration */ - interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { + export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; exclamationToken?: ExclamationToken; body?: Block | Expression; } - type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; + export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; /** @deprecated Use SignatureDeclaration */ - type FunctionLike = SignatureDeclaration; - interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { + export type FunctionLike = SignatureDeclaration; + export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.FunctionDeclaration; name?: Identifier; body?: FunctionBody; } - interface MethodSignature extends SignatureDeclarationBase, TypeElement { + export interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; parent: ObjectTypeDeclaration; name: PropertyName; } - interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { + export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent: ClassLikeDeclaration; body?: FunctionBody; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ - interface SemicolonClassElement extends ClassElement { + export interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; parent: ClassLikeDeclaration; } - interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } - type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { + export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; + export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent: ObjectTypeDeclaration; } - interface TypeNode extends Node { + export interface TypeNode extends Node { _typeNodeBrand: any; } - interface KeywordTypeNode extends TypeNode { + export interface KeywordTypeNode extends TypeNode { 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 { + export interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; } - interface ThisTypeNode extends TypeNode { + export interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } - type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { + export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; + export interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; type: TypeNode; } - interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { + export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.ConstructorType; } - interface NodeWithTypeArguments extends TypeNode { + export interface NodeWithTypeArguments extends TypeNode { typeArguments?: NodeArray; } - type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; - interface TypeReferenceNode extends NodeWithTypeArguments { + export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; + export interface TypeReferenceNode extends NodeWithTypeArguments { kind: SyntaxKind.TypeReference; typeName: EntityName; } - interface TypePredicateNode extends TypeNode { + export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; + assertsModifier?: AssertsToken; parameterName: Identifier | ThisTypeNode; - type: TypeNode; + type?: TypeNode; } - interface TypeQueryNode extends TypeNode { + export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; exprName: EntityName; } - interface TypeLiteralNode extends TypeNode, Declaration { + export interface TypeLiteralNode extends TypeNode, Declaration { kind: SyntaxKind.TypeLiteral; members: NodeArray; } - interface ArrayTypeNode extends TypeNode { + export interface ArrayTypeNode extends TypeNode { kind: SyntaxKind.ArrayType; elementType: TypeNode; } - interface TupleTypeNode extends TypeNode { + export interface TupleTypeNode extends TypeNode { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } - interface OptionalTypeNode extends TypeNode { + export interface OptionalTypeNode extends TypeNode { kind: SyntaxKind.OptionalType; type: TypeNode; } - interface RestTypeNode extends TypeNode { + export interface RestTypeNode extends TypeNode { kind: SyntaxKind.RestType; type: TypeNode; } - type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; - interface UnionTypeNode extends TypeNode { + export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; + export interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; types: NodeArray; } - interface IntersectionTypeNode extends TypeNode { + export interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; types: NodeArray; } - interface ConditionalTypeNode extends TypeNode { + export interface ConditionalTypeNode extends TypeNode { kind: SyntaxKind.ConditionalType; checkType: TypeNode; extendsType: TypeNode; trueType: TypeNode; falseType: TypeNode; } - interface InferTypeNode extends TypeNode { + export interface InferTypeNode extends TypeNode { kind: SyntaxKind.InferType; typeParameter: TypeParameterDeclaration; } - interface ParenthesizedTypeNode extends TypeNode { + export interface ParenthesizedTypeNode extends TypeNode { kind: SyntaxKind.ParenthesizedType; type: TypeNode; } - interface TypeOperatorNode extends TypeNode { + export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword; type: TypeNode; } - interface IndexedAccessTypeNode extends TypeNode { + export interface IndexedAccessTypeNode extends TypeNode { kind: SyntaxKind.IndexedAccessType; objectType: TypeNode; indexType: TypeNode; } - interface MappedTypeNode extends TypeNode, Declaration { + export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; readonlyToken?: ReadonlyToken | PlusToken | MinusToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken | PlusToken | MinusToken; type?: TypeNode; } - interface LiteralTypeNode extends TypeNode { + export interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - interface StringLiteral extends LiteralExpression { + export interface StringLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.StringLiteral; } - type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; - interface Expression extends Node { + export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; + export interface Expression extends Node { _expressionBrand: any; } - interface OmittedExpression extends Expression { + export interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } - interface PartiallyEmittedExpression extends LeftHandSideExpression { + export interface PartiallyEmittedExpression extends LeftHandSideExpression { kind: SyntaxKind.PartiallyEmittedExpression; expression: Expression; } - interface UnaryExpression extends Expression { + export interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } /** Deprecated, please use UpdateExpression */ - type IncrementExpression = UpdateExpression; - interface UpdateExpression extends UnaryExpression { + export type IncrementExpression = UpdateExpression; + export interface UpdateExpression extends UnaryExpression { _updateExpressionBrand: any; } - type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; - interface PrefixUnaryExpression extends UpdateExpression { + export type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; + export interface PrefixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: PrefixUnaryOperator; operand: UnaryExpression; } - type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; - interface PostfixUnaryExpression extends UpdateExpression { + export type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; + export interface PostfixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface LeftHandSideExpression extends UpdateExpression { + export interface LeftHandSideExpression extends UpdateExpression { _leftHandSideExpressionBrand: any; } - interface MemberExpression extends LeftHandSideExpression { + export interface MemberExpression extends LeftHandSideExpression { _memberExpressionBrand: any; } - interface PrimaryExpression extends MemberExpression { + export interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } - interface NullLiteral extends PrimaryExpression, TypeNode { + export interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } - interface BooleanLiteral extends PrimaryExpression, TypeNode { + export interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - interface ThisExpression extends PrimaryExpression, KeywordTypeNode { + export interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } - interface SuperExpression extends PrimaryExpression { + export interface SuperExpression extends PrimaryExpression { kind: SyntaxKind.SuperKeyword; } - interface ImportExpression extends PrimaryExpression { + export interface ImportExpression extends PrimaryExpression { kind: SyntaxKind.ImportKeyword; } - interface DeleteExpression extends UnaryExpression { + export interface DeleteExpression extends UnaryExpression { kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; } - interface TypeOfExpression extends UnaryExpression { + export interface TypeOfExpression extends UnaryExpression { kind: SyntaxKind.TypeOfExpression; expression: UnaryExpression; } - interface VoidExpression extends UnaryExpression { + export interface VoidExpression extends UnaryExpression { kind: SyntaxKind.VoidExpression; expression: UnaryExpression; } - interface AwaitExpression extends UnaryExpression { + export interface AwaitExpression extends UnaryExpression { kind: SyntaxKind.AwaitExpression; expression: UnaryExpression; } - interface YieldExpression extends Expression { + export interface YieldExpression extends Expression { kind: SyntaxKind.YieldExpression; asteriskToken?: AsteriskToken; expression?: Expression; } - interface SyntheticExpression extends Expression { + export interface SyntheticExpression extends Expression { kind: SyntaxKind.SyntheticExpression; isSpread: boolean; type: Type; } - type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; - type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; - type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; - type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; - type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; - type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; - type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; - type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; - type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; - type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; - type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; - type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; - type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; - type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; - type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; - type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; - type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; - type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; - type BinaryOperatorToken = Token; - interface BinaryExpression extends Expression, Declaration { + export type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; + export type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; + export type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; + export type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; + export type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; + export type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; + export type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; + export type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; + export type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; + export type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; + export type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; + export type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; + export type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; + export type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; + export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; + export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; + export type AssignmentOperatorOrHigher = SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | AssignmentOperator; + export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; + export type BinaryOperatorToken = Token; + export interface BinaryExpression extends Expression, Declaration { kind: SyntaxKind.BinaryExpression; left: Expression; operatorToken: BinaryOperatorToken; right: Expression; } - type AssignmentOperatorToken = Token; - interface AssignmentExpression extends BinaryExpression { + export type AssignmentOperatorToken = Token; + export interface AssignmentExpression extends BinaryExpression { left: LeftHandSideExpression; operatorToken: TOperator; } - interface ObjectDestructuringAssignment extends AssignmentExpression { + export interface ObjectDestructuringAssignment extends AssignmentExpression { left: ObjectLiteralExpression; } - interface ArrayDestructuringAssignment extends AssignmentExpression { + export interface ArrayDestructuringAssignment extends AssignmentExpression { left: ArrayLiteralExpression; } - type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; - type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; - type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; - type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; - type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; - type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; - type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; - type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; - interface ConditionalExpression extends Expression { + export type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; + export type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression | Identifier | PropertyAccessExpression | ElementAccessExpression; + export type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; + export type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; + export type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; + export type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; + export type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; + export type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; + export interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; questionToken: QuestionToken; @@ -978,34 +990,37 @@ declare namespace ts { colonToken: ColonToken; whenFalse: Expression; } - type FunctionBody = Block; - type ConciseBody = FunctionBody | Expression; - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { + export type FunctionBody = Block; + export type ConciseBody = FunctionBody | Expression; + export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } - interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { + export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; name: never; } - interface LiteralLikeNode extends Node { + export interface LiteralLikeNode extends Node { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; } - interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { + export interface TemplateLiteralLikeNode extends LiteralLikeNode { + rawText?: string; + } + export interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; } - interface RegularExpressionLiteral extends LiteralExpression { + export interface RegularExpressionLiteral extends LiteralExpression { kind: SyntaxKind.RegularExpressionLiteral; } - interface NoSubstitutionTemplateLiteral extends LiteralExpression { + export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode, Declaration { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } - enum TokenFlags { + export enum TokenFlags { None = 0, Scientific = 16, Octal = 32, @@ -1013,45 +1028,45 @@ declare namespace ts { BinarySpecifier = 128, OctalSpecifier = 256, } - interface NumericLiteral extends LiteralExpression { + export interface NumericLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.NumericLiteral; } - interface BigIntLiteral extends LiteralExpression { + export interface BigIntLiteral extends LiteralExpression { kind: SyntaxKind.BigIntLiteral; } - interface TemplateHead extends LiteralLikeNode { + export interface TemplateHead extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateHead; parent: TemplateExpression; } - interface TemplateMiddle extends LiteralLikeNode { + export interface TemplateMiddle extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateMiddle; parent: TemplateSpan; } - interface TemplateTail extends LiteralLikeNode { + export interface TemplateTail extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateTail; parent: TemplateSpan; } - type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; - interface TemplateExpression extends PrimaryExpression { + export type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; + export interface TemplateExpression extends PrimaryExpression { kind: SyntaxKind.TemplateExpression; head: TemplateHead; templateSpans: NodeArray; } - interface TemplateSpan extends Node { + export interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; parent: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } - interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { + export interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } - interface ArrayLiteralExpression extends PrimaryExpression { + export interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; } - interface SpreadElement extends Expression { + export interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; parent: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; @@ -1062,413 +1077,426 @@ declare namespace ts { * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) */ - interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { + export interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { properties: NodeArray; } - interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { + export interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; } - type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; - type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; - interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { + export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; + export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; name: Identifier; } - interface SuperPropertyAccessExpression extends PropertyAccessExpression { + export interface PropertyAccessChain extends PropertyAccessExpression { + _optionalChainBrand: any; + } + export interface SuperPropertyAccessExpression extends PropertyAccessExpression { expression: SuperExpression; } /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ - interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { + export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { _propertyAccessExpressionLikeQualifiedNameBrand?: any; expression: EntityNameExpression; } - interface ElementAccessExpression extends MemberExpression { + export interface ElementAccessExpression extends MemberExpression { kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; argumentExpression: Expression; } - interface SuperElementAccessExpression extends ElementAccessExpression { + export interface ElementAccessChain extends ElementAccessExpression { + _optionalChainBrand: any; + } + export interface SuperElementAccessExpression extends ElementAccessExpression { expression: SuperExpression; } - type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; - interface CallExpression extends LeftHandSideExpression, Declaration { + export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; + export interface CallExpression extends LeftHandSideExpression, Declaration { kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; typeArguments?: NodeArray; arguments: NodeArray; } - interface SuperCall extends CallExpression { + export interface CallChain extends CallExpression { + _optionalChainBrand: any; + } + export type OptionalChain = PropertyAccessChain | ElementAccessChain | CallChain; + export interface SuperCall extends CallExpression { expression: SuperExpression; } - interface ImportCall extends CallExpression { + export interface ImportCall extends CallExpression { expression: ImportExpression; } - interface ExpressionWithTypeArguments extends NodeWithTypeArguments { + export interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; parent: HeritageClause | JSDocAugmentsTag; expression: LeftHandSideExpression; } - interface NewExpression extends PrimaryExpression, Declaration { + export interface NewExpression extends PrimaryExpression, Declaration { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments?: NodeArray; } - interface TaggedTemplateExpression extends MemberExpression { + export interface TaggedTemplateExpression extends MemberExpression { kind: SyntaxKind.TaggedTemplateExpression; tag: LeftHandSideExpression; typeArguments?: NodeArray; template: TemplateLiteral; } - type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; - interface AsExpression extends Expression { + export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; + export interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; type: TypeNode; } - interface TypeAssertion extends UnaryExpression { + export interface TypeAssertion extends UnaryExpression { kind: SyntaxKind.TypeAssertionExpression; type: TypeNode; expression: UnaryExpression; } - type AssertionExpression = TypeAssertion | AsExpression; - interface NonNullExpression extends LeftHandSideExpression { + export type AssertionExpression = TypeAssertion | AsExpression; + export interface NonNullExpression extends LeftHandSideExpression { kind: SyntaxKind.NonNullExpression; expression: Expression; } - interface MetaProperty extends PrimaryExpression { + export interface MetaProperty extends PrimaryExpression { kind: SyntaxKind.MetaProperty; keywordToken: SyntaxKind.NewKeyword | SyntaxKind.ImportKeyword; name: Identifier; } - interface JsxElement extends PrimaryExpression { + export interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } - type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; - type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; - type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; - interface JsxTagNamePropertyAccess extends PropertyAccessExpression { + export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; + export type JsxTagNameExpression = Identifier | ThisExpression | JsxTagNamePropertyAccess; + export interface JsxTagNamePropertyAccess extends PropertyAccessExpression { expression: JsxTagNameExpression; } - interface JsxAttributes extends ObjectLiteralExpressionBase { + export interface JsxAttributes extends ObjectLiteralExpressionBase { kind: SyntaxKind.JsxAttributes; parent: JsxOpeningLikeElement; } - interface JsxOpeningElement extends Expression { + export interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; parent: JsxElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxSelfClosingElement extends PrimaryExpression { + export interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; } - interface JsxFragment extends PrimaryExpression { + export interface JsxFragment extends PrimaryExpression { kind: SyntaxKind.JsxFragment; openingFragment: JsxOpeningFragment; children: NodeArray; closingFragment: JsxClosingFragment; } - interface JsxOpeningFragment extends Expression { + export interface JsxOpeningFragment extends Expression { kind: SyntaxKind.JsxOpeningFragment; parent: JsxFragment; } - interface JsxClosingFragment extends Expression { + export interface JsxClosingFragment extends Expression { kind: SyntaxKind.JsxClosingFragment; parent: JsxFragment; } - interface JsxAttribute extends ObjectLiteralElement { + export interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; parent: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } - interface JsxSpreadAttribute extends ObjectLiteralElement { + export interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; parent: JsxAttributes; expression: Expression; } - interface JsxClosingElement extends Node { + export interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; parent: JsxElement; tagName: JsxTagNameExpression; } - interface JsxExpression extends Expression { + export interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; parent: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } - interface JsxText extends LiteralLikeNode { + export interface JsxText extends LiteralLikeNode { kind: SyntaxKind.JsxText; containsOnlyTriviaWhiteSpaces: boolean; parent: JsxElement; } - type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; - interface Statement extends Node { + export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; + export interface Statement extends Node { _statementBrand: any; } - interface NotEmittedStatement extends Statement { + export interface NotEmittedStatement extends Statement { kind: SyntaxKind.NotEmittedStatement; } /** * A list of comma-separated expressions. This node is only created by transformations. */ - interface CommaListExpression extends Expression { + export interface CommaListExpression extends Expression { kind: SyntaxKind.CommaListExpression; elements: NodeArray; } - interface EmptyStatement extends Statement { + export interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } - interface DebuggerStatement extends Statement { + export interface DebuggerStatement extends Statement { kind: SyntaxKind.DebuggerStatement; } - interface MissingDeclaration extends DeclarationStatement { + export interface MissingDeclaration extends DeclarationStatement { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } - type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; - interface Block extends Statement { + export type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; + export interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; } - interface VariableStatement extends Statement, JSDocContainer { + export interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } - interface ExpressionStatement extends Statement, JSDocContainer { + export interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } - interface IfStatement extends Statement { + export interface IfStatement extends Statement { kind: SyntaxKind.IfStatement; expression: Expression; thenStatement: Statement; elseStatement?: Statement; } - interface IterationStatement extends Statement { + export interface IterationStatement extends Statement { statement: Statement; } - interface DoStatement extends IterationStatement { + export interface DoStatement extends IterationStatement { kind: SyntaxKind.DoStatement; expression: Expression; } - interface WhileStatement extends IterationStatement { + export interface WhileStatement extends IterationStatement { kind: SyntaxKind.WhileStatement; expression: Expression; } - type ForInitializer = VariableDeclarationList | Expression; - interface ForStatement extends IterationStatement { + export type ForInitializer = VariableDeclarationList | Expression; + export interface ForStatement extends IterationStatement { kind: SyntaxKind.ForStatement; initializer?: ForInitializer; condition?: Expression; incrementor?: Expression; } - type ForInOrOfStatement = ForInStatement | ForOfStatement; - interface ForInStatement extends IterationStatement { + export type ForInOrOfStatement = ForInStatement | ForOfStatement; + export interface ForInStatement extends IterationStatement { kind: SyntaxKind.ForInStatement; initializer: ForInitializer; expression: Expression; } - interface ForOfStatement extends IterationStatement { + export interface ForOfStatement extends IterationStatement { kind: SyntaxKind.ForOfStatement; awaitModifier?: AwaitKeywordToken; initializer: ForInitializer; expression: Expression; } - interface BreakStatement extends Statement { + export interface BreakStatement extends Statement { kind: SyntaxKind.BreakStatement; label?: Identifier; } - interface ContinueStatement extends Statement { + export interface ContinueStatement extends Statement { kind: SyntaxKind.ContinueStatement; label?: Identifier; } - type BreakOrContinueStatement = BreakStatement | ContinueStatement; - interface ReturnStatement extends Statement { + export type BreakOrContinueStatement = BreakStatement | ContinueStatement; + export interface ReturnStatement extends Statement { kind: SyntaxKind.ReturnStatement; expression?: Expression; } - interface WithStatement extends Statement { + export interface WithStatement extends Statement { kind: SyntaxKind.WithStatement; expression: Expression; statement: Statement; } - interface SwitchStatement extends Statement { + export interface SwitchStatement extends Statement { kind: SyntaxKind.SwitchStatement; expression: Expression; caseBlock: CaseBlock; possiblyExhaustive?: boolean; } - interface CaseBlock extends Node { + export interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; parent: SwitchStatement; clauses: NodeArray; } - interface CaseClause extends Node { + export interface CaseClause extends Node { kind: SyntaxKind.CaseClause; parent: CaseBlock; expression: Expression; statements: NodeArray; } - interface DefaultClause extends Node { + export interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; parent: CaseBlock; statements: NodeArray; } - type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement, JSDocContainer { + export type CaseOrDefaultClause = CaseClause | DefaultClause; + export interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; } - interface ThrowStatement extends Statement { + export interface ThrowStatement extends Statement { kind: SyntaxKind.ThrowStatement; expression?: Expression; } - interface TryStatement extends Statement { + export interface TryStatement extends Statement { kind: SyntaxKind.TryStatement; tryBlock: Block; catchClause?: CatchClause; finallyBlock?: Block; } - interface CatchClause extends Node { + export interface CatchClause extends Node { kind: SyntaxKind.CatchClause; parent: TryStatement; variableDeclaration?: VariableDeclaration; block: Block; } - type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; - type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; - interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { + export type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; + export type DeclarationWithTypeParameters = DeclarationWithTypeParameterChildren | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; + export type DeclarationWithTypeParameterChildren = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; + export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { + export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; /** May be undefined in `export default class { ... }`. */ name?: Identifier; } - interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { + export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } - type ClassLikeDeclaration = ClassDeclaration | ClassExpression; - interface ClassElement extends NamedDeclaration { + export type ClassLikeDeclaration = ClassDeclaration | ClassExpression; + export interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; } - interface TypeElement extends NamedDeclaration { + export interface TypeElement extends NamedDeclaration { _typeElementBrand: any; name?: PropertyName; questionToken?: QuestionToken; } - interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { + export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface HeritageClause extends Node { + export interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; parent: InterfaceDeclaration | ClassLikeDeclaration; token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } - interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { + export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } - interface EnumMember extends NamedDeclaration, JSDocContainer { + export interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent: EnumDeclaration; name: PropertyName; initializer?: Expression; } - interface EnumDeclaration extends DeclarationStatement, JSDocContainer { + export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } - type ModuleName = Identifier | StringLiteral; - type ModuleBody = NamespaceBody | JSDocNamespaceBody; - interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { + export type ModuleName = Identifier | StringLiteral; + export type ModuleBody = NamespaceBody | JSDocNamespaceBody; + export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent: ModuleBody | SourceFile; name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration; } - type NamespaceBody = ModuleBlock | NamespaceDeclaration; - interface NamespaceDeclaration extends ModuleDeclaration { + export type NamespaceBody = ModuleBlock | NamespaceDeclaration; + export interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; body: NamespaceBody; } - type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; - interface JSDocNamespaceDeclaration extends ModuleDeclaration { + export type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; + export interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; body?: JSDocNamespaceBody; } - interface ModuleBlock extends Node, Statement { + export interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; parent: ModuleDeclaration; statements: NodeArray; } - type ModuleReference = EntityName | ExternalModuleReference; + export type ModuleReference = EntityName | ExternalModuleReference; /** * One of: * - import x = require("mod"); * - import x = M.x; */ - interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { + export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } - interface ExternalModuleReference extends Node { + export interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; parent: ImportEqualsDeclaration; expression: Expression; } - interface ImportDeclaration extends Statement { + export interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; parent: SourceFile | ModuleBlock; importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; } - type NamedImportBindings = NamespaceImport | NamedImports; - interface ImportClause extends NamedDeclaration { + export type NamedImportBindings = NamespaceImport | NamedImports; + export interface ImportClause extends NamedDeclaration { kind: SyntaxKind.ImportClause; parent: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } - interface NamespaceImport extends NamedDeclaration { + export interface NamespaceImport extends NamedDeclaration { kind: SyntaxKind.NamespaceImport; parent: ImportClause; name: Identifier; } - interface NamespaceExportDeclaration extends DeclarationStatement { + export interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; } - interface ExportDeclaration extends DeclarationStatement, JSDocContainer { + export interface ExportDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ExportDeclaration; parent: SourceFile | ModuleBlock; /** Will not be assigned in the case of `export * from "foo";` */ @@ -1476,161 +1504,166 @@ declare namespace ts { /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier?: Expression; } - interface NamedImports extends Node { + export interface NamedImports extends Node { kind: SyntaxKind.NamedImports; parent: ImportClause; elements: NodeArray; } - interface NamedExports extends Node { + export interface NamedExports extends Node { kind: SyntaxKind.NamedExports; parent: ExportDeclaration; elements: NodeArray; } - type NamedImportsOrExports = NamedImports | NamedExports; - interface ImportSpecifier extends NamedDeclaration { + export type NamedImportsOrExports = NamedImports | NamedExports; + export interface ImportSpecifier extends NamedDeclaration { kind: SyntaxKind.ImportSpecifier; parent: NamedImports; propertyName?: Identifier; name: Identifier; } - interface ExportSpecifier extends NamedDeclaration { + export interface ExportSpecifier extends NamedDeclaration { kind: SyntaxKind.ExportSpecifier; parent: NamedExports; propertyName?: Identifier; name: Identifier; } - type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; + export type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; /** * This is either an `export =` or an `export default` declaration. * Unless `isExportEquals` is set, this node was parsed as an `export default`. */ - interface ExportAssignment extends DeclarationStatement { + export interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; parent: SourceFile; isExportEquals?: boolean; expression: Expression; } - interface FileReference extends TextRange { + export interface FileReference extends TextRange { fileName: string; } - interface CheckJsDirective extends TextRange { + export interface CheckJsDirective extends TextRange { enabled: boolean; } - type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; - interface CommentRange extends TextRange { + export type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; + export interface CommentRange extends TextRange { hasTrailingNewLine?: boolean; kind: CommentKind; } - interface SynthesizedComment extends CommentRange { + export interface SynthesizedComment extends CommentRange { text: string; pos: -1; end: -1; } - interface JSDocTypeExpression extends TypeNode { + export interface JSDocTypeExpression extends TypeNode { kind: SyntaxKind.JSDocTypeExpression; type: TypeNode; } - interface JSDocType extends TypeNode { + export interface JSDocType extends TypeNode { _jsDocTypeBrand: any; } - interface JSDocAllType extends JSDocType { + export interface JSDocAllType extends JSDocType { kind: SyntaxKind.JSDocAllType; } - interface JSDocUnknownType extends JSDocType { + export interface JSDocUnknownType extends JSDocType { kind: SyntaxKind.JSDocUnknownType; } - interface JSDocNonNullableType extends JSDocType { + export interface JSDocNonNullableType extends JSDocType { kind: SyntaxKind.JSDocNonNullableType; type: TypeNode; } - interface JSDocNullableType extends JSDocType { + export interface JSDocNullableType extends JSDocType { kind: SyntaxKind.JSDocNullableType; type: TypeNode; } - interface JSDocOptionalType extends JSDocType { + export interface JSDocOptionalType extends JSDocType { kind: SyntaxKind.JSDocOptionalType; type: TypeNode; } - interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { + export interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { kind: SyntaxKind.JSDocFunctionType; } - interface JSDocVariadicType extends JSDocType { + export interface JSDocVariadicType extends JSDocType { kind: SyntaxKind.JSDocVariadicType; type: TypeNode; } - type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; - interface JSDoc extends Node { + export interface JSDocNamepathType extends JSDocType { + kind: SyntaxKind.JSDocNamepathType; + type: TypeNode; + } + export type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; + export interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; parent: HasJSDoc; tags?: NodeArray; comment?: string; } - interface JSDocTag extends Node { + export interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; tagName: Identifier; comment?: string; } - interface JSDocUnknownTag extends JSDocTag { + export interface JSDocUnknownTag extends JSDocTag { kind: SyntaxKind.JSDocTag; } /** * Note that `@extends` is a synonym of `@augments`. * Both tags are represented by this interface. */ - interface JSDocAugmentsTag extends JSDocTag { + export interface JSDocAugmentsTag extends JSDocTag { kind: SyntaxKind.JSDocAugmentsTag; class: ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression; }; } - interface JSDocAuthorTag extends JSDocTag { + export interface JSDocAuthorTag extends JSDocTag { kind: SyntaxKind.JSDocAuthorTag; } - interface JSDocClassTag extends JSDocTag { + export interface JSDocClassTag extends JSDocTag { kind: SyntaxKind.JSDocClassTag; } - interface JSDocEnumTag extends JSDocTag { + export interface JSDocEnumTag extends JSDocTag, Declaration { + parent: JSDoc; kind: SyntaxKind.JSDocEnumTag; typeExpression?: JSDocTypeExpression; } - interface JSDocThisTag extends JSDocTag { + export interface JSDocThisTag extends JSDocTag { kind: SyntaxKind.JSDocThisTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTemplateTag extends JSDocTag { + export interface JSDocTemplateTag extends JSDocTag { kind: SyntaxKind.JSDocTemplateTag; constraint: JSDocTypeExpression | undefined; typeParameters: NodeArray; } - interface JSDocReturnTag extends JSDocTag { + export interface JSDocReturnTag extends JSDocTag { kind: SyntaxKind.JSDocReturnTag; typeExpression?: JSDocTypeExpression; } - interface JSDocTypeTag extends JSDocTag { + export interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; typeExpression: JSDocTypeExpression; } - interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { + export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocTypedefTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression?: JSDocTypeExpression | JSDocTypeLiteral; } - interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { + export interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { parent: JSDoc; kind: SyntaxKind.JSDocCallbackTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; typeExpression: JSDocSignature; } - interface JSDocSignature extends JSDocType, Declaration { + export interface JSDocSignature extends JSDocType, Declaration { kind: SyntaxKind.JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly JSDocTemplateTag[]; + parameters: readonly JSDocParameterTag[]; type: JSDocReturnTag | undefined; } - interface JSDocPropertyLikeTag extends JSDocTag, Declaration { + export interface JSDocPropertyLikeTag extends JSDocTag, Declaration { parent: JSDoc; name: EntityName; typeExpression?: JSDocTypeExpression; @@ -1638,19 +1671,19 @@ declare namespace ts { isNameFirst: boolean; isBracketed: boolean; } - interface JSDocPropertyTag extends JSDocPropertyLikeTag { + export interface JSDocPropertyTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocPropertyTag; } - interface JSDocParameterTag extends JSDocPropertyLikeTag { + export interface JSDocParameterTag extends JSDocPropertyLikeTag { kind: SyntaxKind.JSDocParameterTag; } - interface JSDocTypeLiteral extends JSDocType { + export interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; - jsDocPropertyTags?: ReadonlyArray; + jsDocPropertyTags?: readonly JSDocPropertyLikeTag[]; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } - enum FlowFlags { + export enum FlowFlags { Unreachable = 1, Start = 2, BranchLabel = 4, @@ -1660,72 +1693,77 @@ declare namespace ts { FalseCondition = 64, SwitchClause = 128, ArrayMutation = 256, - Referenced = 512, - Shared = 1024, - PreFinally = 2048, - AfterFinally = 4096, + Call = 512, + Referenced = 1024, + Shared = 2048, + PreFinally = 4096, + AfterFinally = 8192, Label = 12, Condition = 96 } - interface FlowLock { + export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation; + export interface FlowNodeBase { + flags: FlowFlags; + id?: number; + } + export interface FlowLock { locked?: boolean; } - interface AfterFinallyFlow extends FlowNodeBase, FlowLock { + export interface AfterFinallyFlow extends FlowNodeBase, FlowLock { antecedent: FlowNode; } - interface PreFinallyFlow extends FlowNodeBase { + export interface PreFinallyFlow extends FlowNodeBase { antecedent: FlowNode; lock: FlowLock; } - type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - interface FlowNodeBase { - flags: FlowFlags; - id?: number; - } - interface FlowStart extends FlowNodeBase { - container?: FunctionExpression | ArrowFunction | MethodDeclaration; + export interface FlowStart extends FlowNodeBase { + node?: FunctionExpression | ArrowFunction | MethodDeclaration; } - interface FlowLabel extends FlowNodeBase { + export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; } - interface FlowAssignment extends FlowNodeBase { + export interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } - interface FlowCondition extends FlowNodeBase { - expression: Expression; + export interface FlowCall extends FlowNodeBase { + node: CallExpression; + antecedent: FlowNode; + } + export interface FlowCondition extends FlowNodeBase { + node: Expression; antecedent: FlowNode; } - interface FlowSwitchClause extends FlowNodeBase { + export interface FlowSwitchClause extends FlowNodeBase { switchStatement: SwitchStatement; clauseStart: number; clauseEnd: number; antecedent: FlowNode; } - interface FlowArrayMutation extends FlowNodeBase { + export interface FlowArrayMutation extends FlowNodeBase { node: CallExpression | BinaryExpression; antecedent: FlowNode; } - type FlowType = Type | IncompleteType; - interface IncompleteType { + export type FlowType = Type | IncompleteType; + export interface IncompleteType { flags: TypeFlags; type: Type; } - interface AmdDependency { + export interface AmdDependency { path: string; name?: string; } - interface SourceFile extends Declaration { + export interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; statements: NodeArray; endOfFileToken: Token; fileName: string; text: string; - amdDependencies: ReadonlyArray; + amdDependencies: readonly AmdDependency[]; moduleName?: string; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray; - libReferenceDirectives: ReadonlyArray; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly FileReference[]; + libReferenceDirectives: readonly FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -1739,12 +1777,12 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; } - interface Bundle extends Node { + export interface Bundle extends Node { kind: SyntaxKind.Bundle; - prepends: ReadonlyArray; - sourceFiles: ReadonlyArray; + prepends: readonly (InputFiles | UnparsedSource)[]; + sourceFiles: readonly SourceFile[]; } - interface InputFiles extends Node { + export interface InputFiles extends Node { kind: SyntaxKind.InputFiles; javascriptPath?: string; javascriptText: string; @@ -1755,70 +1793,70 @@ declare namespace ts { declarationMapPath?: string; declarationMapText?: string; } - interface UnparsedSource extends Node { + export interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; fileName: string; text: string; - prologues: ReadonlyArray; - helpers: ReadonlyArray | undefined; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray | undefined; - libReferenceDirectives: ReadonlyArray; + prologues: readonly UnparsedPrologue[]; + helpers: readonly UnscopedEmitHelper[] | undefined; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly string[] | undefined; + libReferenceDirectives: readonly FileReference[]; hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; - syntheticReferences?: ReadonlyArray; - texts: ReadonlyArray; + syntheticReferences?: readonly UnparsedSyntheticReference[]; + texts: readonly UnparsedSourceText[]; } - type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; - type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; - interface UnparsedSection extends Node { + export type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; + export type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; + export interface UnparsedSection extends Node { kind: SyntaxKind; data?: string; parent: UnparsedSource; } - interface UnparsedPrologue extends UnparsedSection { + export interface UnparsedPrologue extends UnparsedSection { kind: SyntaxKind.UnparsedPrologue; data: string; parent: UnparsedSource; } - interface UnparsedPrepend extends UnparsedSection { + export interface UnparsedPrepend extends UnparsedSection { kind: SyntaxKind.UnparsedPrepend; data: string; parent: UnparsedSource; - texts: ReadonlyArray; + texts: readonly UnparsedTextLike[]; } - interface UnparsedTextLike extends UnparsedSection { + export interface UnparsedTextLike extends UnparsedSection { kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; parent: UnparsedSource; } - interface UnparsedSyntheticReference extends UnparsedSection { + export interface UnparsedSyntheticReference extends UnparsedSection { kind: SyntaxKind.UnparsedSyntheticReference; parent: UnparsedSource; } - interface JsonSourceFile extends SourceFile { + export interface JsonSourceFile extends SourceFile { statements: NodeArray; } - interface TsConfigSourceFile extends JsonSourceFile { + export interface TsConfigSourceFile extends JsonSourceFile { extendedSourceFiles?: string[]; } - interface JsonMinusNumericLiteral extends PrefixUnaryExpression { + export interface JsonMinusNumericLiteral extends PrefixUnaryExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: SyntaxKind.MinusToken; operand: NumericLiteral; } - interface JsonObjectExpressionStatement extends ExpressionStatement { + export interface JsonObjectExpressionStatement extends ExpressionStatement { expression: ObjectLiteralExpression | ArrayLiteralExpression | JsonMinusNumericLiteral | NumericLiteral | StringLiteral | BooleanLiteral | NullLiteral; } - interface ScriptReferenceHost { + export interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; getSourceFile(fileName: string): SourceFile | undefined; getSourceFileByPath(path: Path): SourceFile | undefined; getCurrentDirectory(): string; } - interface ParseConfigHost { + export interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; + readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[]; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. @@ -1832,26 +1870,26 @@ declare namespace ts { * specified like "./blah" to an absolute path to an actual * tsconfig file, e.g. "/root/blah/tsconfig.json" */ - type ResolvedConfigFileName = string & { + export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray) => void; - class OperationCanceledException { + export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; + export class OperationCanceledException { } - interface CancellationToken { + export interface CancellationToken { isCancellationRequested(): boolean; /** @throws OperationCanceledException if isCancellationRequested is true */ throwIfCancellationRequested(): void; } - interface Program extends ScriptReferenceHost { + export interface Program extends ScriptReferenceHost { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): ReadonlyArray; + getRootFileNames(): readonly string[]; /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -1863,33 +1901,42 @@ declare namespace ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** The first time this is called, it will return global diagnostics (no location). */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + getRelationCacheSizes(): { + assignable: number; + identity: number; + subtype: number; + }; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; - getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; + getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; } - interface ResolvedProjectReference { + export interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; - references?: ReadonlyArray; + references?: readonly (ResolvedProjectReference | undefined)[]; } - type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; - interface CustomTransformer { + export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; + export interface CustomTransformer { transformSourceFile(node: SourceFile): SourceFile; transformBundle(node: Bundle): Bundle; } - interface CustomTransformers { + export interface CustomTransformers { /** Custom transformers to evaluate before built-in .js transformations. */ before?: (TransformerFactory | CustomTransformerFactory)[]; /** Custom transformers to evaluate after built-in .js transformations. */ @@ -1897,7 +1944,7 @@ declare namespace ts { /** Custom transformers to evaluate after built-in .d.ts transformations. */ afterDeclarations?: (TransformerFactory | CustomTransformerFactory)[]; } - interface SourceMapSpan { + export interface SourceMapSpan { /** Line number in the .js file. */ emittedLine: number; /** Column number in the .js file. */ @@ -1912,25 +1959,26 @@ declare namespace ts { sourceIndex: number; } /** Return code used by getEmitOutput function to indicate status of the function */ - enum ExitStatus { + export enum ExitStatus { Success = 0, DiagnosticsPresent_OutputsSkipped = 1, DiagnosticsPresent_OutputsGenerated = 2, - InvalidProject_OutputsSkipped = 3 + InvalidProject_OutputsSkipped = 3, + ProjectReferenceCycle_OutputsSkupped = 4 } - interface EmitResult { + export interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; emittedFiles?: string[]; } - interface TypeChecker { + export interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; getDeclaredTypeOfSymbol(symbol: Symbol): Type; getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; + getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1938,6 +1986,7 @@ declare namespace ts { getReturnTypeOfSignature(signature: Signature): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; + getTypeArguments(type: TypeReference): readonly Type[]; /** Note that the resulting nodes cannot be checked. */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ @@ -1984,7 +2033,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): ReadonlyArray; + getRootSymbols(symbol: Symbol): readonly Symbol[]; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -2016,7 +2065,7 @@ declare namespace ts { */ runWithCancellationToken(token: CancellationToken, cb: (checker: TypeChecker) => T): T; } - enum NodeBuilderFlags { + export enum NodeBuilderFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2047,7 +2096,7 @@ declare namespace ts { InInitialEntityName = 16777216, InReverseMappedType = 33554432 } - enum TypeFormatFlags { + export enum TypeFormatFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, @@ -2070,31 +2119,49 @@ declare namespace ts { /** @deprecated */ WriteOwnNameForAnyLike = 0, NodeBuilderFlagsMask = 9469291 } - enum SymbolFormatFlags { + export enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, AllowAnyNodeKind = 4, UseAliasDefinedOutsideCurrentScope = 8, } - enum TypePredicateKind { + export enum TypePredicateKind { This = 0, - Identifier = 1 + Identifier = 1, + AssertsThis = 2, + AssertsIdentifier = 3 } - interface TypePredicateBase { + export interface TypePredicateBase { kind: TypePredicateKind; - type: Type; + type: Type | undefined; } - interface ThisTypePredicate extends TypePredicateBase { + export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; + parameterName: undefined; + parameterIndex: undefined; + type: Type; } - interface IdentifierTypePredicate extends TypePredicateBase { + export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; + type: Type; + } + export interface AssertsThisTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsThis; + parameterName: undefined; + parameterIndex: undefined; + type: Type | undefined; + } + export interface AssertsIdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsIdentifier; + parameterName: string; + parameterIndex: number; + type: Type | undefined; } - type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - enum SymbolFlags { + export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate; + export enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, @@ -2126,28 +2193,28 @@ declare namespace ts { ModuleExports = 134217728, Enum = 384, Variable = 3, - Value = 67220415, - Type = 67897832, + Value = 111551, + Type = 788968, Namespace = 1920, Module = 1536, Accessor = 98304, - FunctionScopedVariableExcludes = 67220414, - BlockScopedVariableExcludes = 67220415, - ParameterExcludes = 67220415, + FunctionScopedVariableExcludes = 111550, + BlockScopedVariableExcludes = 111551, + ParameterExcludes = 111551, PropertyExcludes = 0, - EnumMemberExcludes = 68008959, - FunctionExcludes = 67219887, - ClassExcludes = 68008383, - InterfaceExcludes = 67897736, - RegularEnumExcludes = 68008191, - ConstEnumExcludes = 68008831, + EnumMemberExcludes = 900095, + FunctionExcludes = 110991, + ClassExcludes = 899503, + InterfaceExcludes = 788872, + RegularEnumExcludes = 899327, + ConstEnumExcludes = 899967, ValueModuleExcludes = 110735, NamespaceModuleExcludes = 0, - MethodExcludes = 67212223, - GetAccessorExcludes = 67154879, - SetAccessorExcludes = 67187647, - TypeParameterExcludes = 67635688, - TypeAliasExcludes = 67897832, + MethodExcludes = 103359, + GetAccessorExcludes = 46015, + SetAccessorExcludes = 78783, + TypeParameterExcludes = 526824, + TypeAliasExcludes = 788968, AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, @@ -2155,7 +2222,7 @@ declare namespace ts { PropertyOrAccessor = 98308, ClassMember = 106500, } - interface Symbol { + export interface Symbol { flags: SymbolFlags; escapedName: __String; declarations: Declaration[]; @@ -2164,7 +2231,7 @@ declare namespace ts { exports?: SymbolTable; globalExports?: SymbolTable; } - enum InternalSymbolName { + export enum InternalSymbolName { Call = "__call", Constructor = "__constructor", New = "__new", @@ -2191,13 +2258,13 @@ declare namespace ts { * with a normal string (which is good, it cannot be misused on assignment or on usage), * while still being comparable with a normal string via === (also good) and castable from a string. */ - type __String = (string & { + export type __String = (string & { __escapedIdentifier: void; }) | (void & { __escapedIdentifier: void; }) | InternalSymbolName; /** ReadonlyMap where keys are `__String`s. */ - interface ReadonlyUnderscoreEscapedMap { + export interface ReadonlyUnderscoreEscapedMap { get(key: __String): T | undefined; has(key: __String): boolean; forEach(action: (value: T, key: __String) => void): void; @@ -2207,14 +2274,14 @@ declare namespace ts { entries(): Iterator<[__String, T]>; } /** Map where keys are `__String`s. */ - interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { + export interface UnderscoreEscapedMap extends ReadonlyUnderscoreEscapedMap { set(key: __String, value: T): this; delete(key: __String): boolean; clear(): void; } /** SymbolTable based on ES6 Map interface. */ - type SymbolTable = UnderscoreEscapedMap; - enum TypeFlags { + export type SymbolTable = UnderscoreEscapedMap; + export enum TypeFlags { Any = 1, Unknown = 2, String = 4, @@ -2263,35 +2330,35 @@ declare namespace ts { Narrowable = 133970943, NotUnionOrUnit = 67637251, } - type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; - interface Type { + export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + export interface Type { flags: TypeFlags; symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: ReadonlyArray; + aliasTypeArguments?: readonly Type[]; } - interface LiteralType extends Type { + export interface LiteralType extends Type { value: string | number | PseudoBigInt; freshType: LiteralType; regularType: LiteralType; } - interface UniqueESSymbolType extends Type { + export interface UniqueESSymbolType extends Type { symbol: Symbol; escapedName: __String; } - interface StringLiteralType extends LiteralType { + export interface StringLiteralType extends LiteralType { value: string; } - interface NumberLiteralType extends LiteralType { + export interface NumberLiteralType extends LiteralType { value: number; } - interface BigIntLiteralType extends LiteralType { + export interface BigIntLiteralType extends LiteralType { value: PseudoBigInt; } - interface EnumType extends Type { + export interface EnumType extends Type { } - enum ObjectFlags { + export enum ObjectFlags { Class = 1, Interface = 2, Reference = 4, @@ -2311,18 +2378,18 @@ declare namespace ts { ArrayLiteral = 65536, ClassOrInterface = 3, } - interface ObjectType extends Type { + export interface ObjectType extends Type { objectFlags: ObjectFlags; } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ - interface InterfaceType extends ObjectType { + export interface InterfaceType extends ObjectType { typeParameters: TypeParameter[] | undefined; outerTypeParameters: TypeParameter[] | undefined; localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; } - type BaseType = ObjectType | IntersectionType; - interface InterfaceTypeWithDeclaredMembers extends InterfaceType { + export type BaseType = ObjectType | IntersectionType | TypeVariable; + export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; @@ -2339,49 +2406,51 @@ declare namespace ts { * if the class or interface has no type parameters and the reference isn't specifying an * explicit "this" argument. */ - interface TypeReference extends ObjectType { + export interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: ReadonlyArray; + node?: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; + } + export interface DeferredTypeReference extends TypeReference { } - interface GenericType extends InterfaceType, TypeReference { + export interface GenericType extends InterfaceType, TypeReference { } - interface TupleType extends GenericType { + export interface TupleType extends GenericType { minLength: number; hasRestElement: boolean; readonly: boolean; associatedNames?: __String[]; } - interface TupleTypeReference extends TypeReference { + export interface TupleTypeReference extends TypeReference { target: TupleType; } - interface UnionOrIntersectionType extends Type { + export interface UnionOrIntersectionType extends Type { types: Type[]; } - interface UnionType extends UnionOrIntersectionType { + export interface UnionType extends UnionOrIntersectionType { } - interface IntersectionType extends UnionOrIntersectionType { + export interface IntersectionType extends UnionOrIntersectionType { } - type StructuredType = ObjectType | UnionType | IntersectionType; - interface EvolvingArrayType extends ObjectType { + export type StructuredType = ObjectType | UnionType | IntersectionType; + export interface EvolvingArrayType extends ObjectType { elementType: Type; finalArrayType?: Type; } - interface InstantiableType extends Type { + export interface InstantiableType extends Type { } - interface TypeParameter extends InstantiableType { + export interface TypeParameter extends InstantiableType { } - interface IndexedAccessType extends InstantiableType { + export interface IndexedAccessType extends InstantiableType { objectType: Type; indexType: Type; constraint?: Type; simplifiedForReading?: Type; simplifiedForWriting?: Type; } - type TypeVariable = TypeParameter | IndexedAccessType; - interface IndexType extends InstantiableType { + export type TypeVariable = TypeParameter | IndexedAccessType; + export interface IndexType extends InstantiableType { type: InstantiableType | UnionOrIntersectionType; } - interface ConditionalRoot { + export interface ConditionalRoot { node: ConditionalTypeNode; checkType: Type; extendsType: Type; @@ -2394,36 +2463,36 @@ declare namespace ts { aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } - interface ConditionalType extends InstantiableType { + export interface ConditionalType extends InstantiableType { root: ConditionalRoot; checkType: Type; extendsType: Type; resolvedTrueType: Type; resolvedFalseType: Type; } - interface SubstitutionType extends InstantiableType { + export interface SubstitutionType extends InstantiableType { typeVariable: TypeVariable; substitute: Type; } - enum SignatureKind { + export enum SignatureKind { Call = 0, Construct = 1 } - interface Signature { + export interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly TypeParameter[]; + parameters: readonly Symbol[]; } - enum IndexKind { + export enum IndexKind { String = 0, Number = 1 } - interface IndexInfo { + export interface IndexInfo { type: Type; isReadonly: boolean; declaration?: IndexSignatureDeclaration; } - enum InferencePriority { + export enum InferencePriority { NakedTypeVariable = 1, HomomorphicMappedType = 2, PartialHomomorphicMappedType = 4, @@ -2432,16 +2501,18 @@ declare namespace ts { LiteralKeyof = 32, NoConstraints = 64, AlwaysStrict = 128, - PriorityImpliesCombination = 56 + MaxValue = 256, + PriorityImpliesCombination = 56, + Circularity = -1 } /** @deprecated Use FileExtensionInfo instead. */ - type JsFileExtensionInfo = FileExtensionInfo; - interface FileExtensionInfo { + export type JsFileExtensionInfo = FileExtensionInfo; + export interface FileExtensionInfo { extension: string; isMixedContent: boolean; scriptKind?: ScriptKind; } - interface DiagnosticMessage { + export interface DiagnosticMessage { key: string; category: DiagnosticCategory; code: number; @@ -2454,19 +2525,19 @@ declare namespace ts { * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, * the difference is that messages are all preformatted in DMC. */ - interface DiagnosticMessageChain { + export interface DiagnosticMessageChain { messageText: string; category: DiagnosticCategory; code: number; next?: DiagnosticMessageChain[]; } - interface Diagnostic extends DiagnosticRelatedInformation { + export interface Diagnostic extends DiagnosticRelatedInformation { /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ reportsUnnecessary?: {}; source?: string; relatedInformation?: DiagnosticRelatedInformation[]; } - interface DiagnosticRelatedInformation { + export interface DiagnosticRelatedInformation { category: DiagnosticCategory; code: number; file: SourceFile | undefined; @@ -2474,25 +2545,25 @@ declare namespace ts { length: number | undefined; messageText: string | DiagnosticMessageChain; } - interface DiagnosticWithLocation extends Diagnostic { + export interface DiagnosticWithLocation extends Diagnostic { file: SourceFile; start: number; length: number; } - enum DiagnosticCategory { + export enum DiagnosticCategory { Warning = 0, Error = 1, Suggestion = 2, Message = 3 } - enum ModuleResolutionKind { + export enum ModuleResolutionKind { Classic = 1, NodeJs = 2 } - interface PluginImport { + export interface PluginImport { name: string; } - interface ProjectReference { + export interface ProjectReference { /** A normalized path on disk */ path: string; /** The path as the user originally wrote it */ @@ -2502,8 +2573,8 @@ declare namespace ts { /** True if it is intended that this reference form a circularity */ circular?: boolean; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; - interface CompilerOptions { + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; + export interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; allowUmdGlobalAccess?: boolean; @@ -2518,6 +2589,7 @@ declare namespace ts { emitDeclarationOnly?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + disableSourceOfProjectReferenceRedirect?: boolean; downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; @@ -2584,16 +2656,21 @@ declare namespace ts { /** Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; + useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } - interface TypeAcquisition { + export interface TypeAcquisition { + /** + * @deprecated typingOptions.enableAutoDiscovery + * Use typeAcquisition.enable instead. + */ enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; exclude?: string[]; [option: string]: string[] | boolean | undefined; } - enum ModuleKind { + export enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, @@ -2602,22 +2679,22 @@ declare namespace ts { ES2015 = 5, ESNext = 99 } - enum JsxEmit { + export enum JsxEmit { None = 0, Preserve = 1, React = 2, ReactNative = 3 } - enum NewLineKind { + export enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1 } - interface LineAndCharacter { + export interface LineAndCharacter { /** 0-based. */ line: number; character: number; } - enum ScriptKind { + export enum ScriptKind { Unknown = 0, JS = 1, JSX = 2, @@ -2631,7 +2708,7 @@ declare namespace ts { */ Deferred = 7 } - enum ScriptTarget { + export enum ScriptTarget { ES3 = 0, ES5 = 1, ES2015 = 2, @@ -2644,38 +2721,38 @@ declare namespace ts { JSON = 100, Latest = 99 } - enum LanguageVariant { + export enum LanguageVariant { Standard = 0, JSX = 1 } /** Either a parsed command line or a parsed tsconfig.json */ - interface ParsedCommandLine { + export interface ParsedCommandLine { options: CompilerOptions; typeAcquisition?: TypeAcquisition; fileNames: string[]; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; compileOnSave?: boolean; } - enum WatchDirectoryFlags { + export enum WatchDirectoryFlags { None = 0, Recursive = 1 } - interface ExpandResult { + export interface ExpandResult { fileNames: string[]; wildcardDirectories: MapLike; } - interface CreateProgramOptions { - rootNames: ReadonlyArray; + export interface CreateProgramOptions { + rootNames: readonly string[]; options: CompilerOptions; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; oldProgram?: Program; - configFileParsingDiagnostics?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; } - interface ModuleResolutionHost { + export interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string | undefined; trace?(s: string): void; @@ -2695,7 +2772,7 @@ declare namespace ts { * * Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred. */ - interface ResolvedModule { + export interface ResolvedModule { /** Path of the file the module was resolved to. */ resolvedFileName: string; /** True if `resolvedFileName` comes from `node_modules`. */ @@ -2706,7 +2783,7 @@ declare namespace ts { * Prefer this over `ResolvedModule`. * If changing this, remember to change `moduleResolutionIsEqualTo`. */ - interface ResolvedModuleFull extends ResolvedModule { + export interface ResolvedModuleFull extends ResolvedModule { /** * Extension of resolvedFileName. This must match what's at the end of resolvedFileName. * This is optional for backwards-compatibility, but will be added if not provided. @@ -2718,7 +2795,7 @@ declare namespace ts { * Unique identifier with a package name and version. * If changing this, remember to change `packageIdIsEqual`. */ - interface PackageId { + export interface PackageId { /** * Name of the package. * Should not include `@types`. @@ -2733,7 +2810,7 @@ declare namespace ts { /** Version of the package, e.g. "1.2.3" */ version: string; } - enum Extension { + export enum Extension { Ts = ".ts", Tsx = ".tsx", Dts = ".d.ts", @@ -2742,21 +2819,21 @@ declare namespace ts { Json = ".json", TsBuildInfo = ".tsbuildinfo" } - interface ResolvedModuleWithFailedLookupLocations { + export interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; } - interface ResolvedTypeReferenceDirective { + export interface ResolvedTypeReferenceDirective { primary: boolean; resolvedFileName: string | undefined; packageId?: PackageId; /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; } - interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { + export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: ReadonlyArray; + readonly failedLookupLocations: readonly string[]; } - interface CompilerHost extends ModuleResolutionHost { + export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getCancellationToken?(): CancellationToken; @@ -2767,25 +2844,25 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; - readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (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, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } - interface SourceMapRange extends TextRange { + export interface SourceMapRange extends TextRange { source?: SourceMapSource; } - interface SourceMapSource { + export interface SourceMapSource { fileName: string; text: string; skipTrivia?: (pos: number) => number; } - enum EmitFlags { + export enum EmitFlags { None = 0, SingleLine = 1, AdviseOnEmitNode = 2, @@ -2816,18 +2893,18 @@ declare namespace ts { Iterator = 8388608, NoAsciiEscaping = 16777216, } - interface EmitHelper { + export interface EmitHelper { readonly name: string; readonly scoped: boolean; readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; } - interface UnscopedEmitHelper extends EmitHelper { + export interface UnscopedEmitHelper extends EmitHelper { readonly scoped: false; readonly text: string; } - type EmitHelperUniqueNameCallback = (name: string) => string; - enum EmitHint { + export type EmitHelperUniqueNameCallback = (name: string) => string; + export enum EmitHint { SourceFile = 0, Expression = 1, IdentifierName = 2, @@ -2835,7 +2912,7 @@ declare namespace ts { Unspecified = 4, EmbeddedStatement = 5 } - interface TransformationContext { + export interface TransformationContext { /** Gets the compiler options supplied to the transformer. */ getCompilerOptions(): CompilerOptions; /** Starts a new lexical environment. */ @@ -2885,7 +2962,7 @@ declare namespace ts { */ onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; } - interface TransformationResult { + export interface TransformationResult { /** Gets the transformed source files. */ transformed: T[]; /** Gets diagnostics for the transformation. */ @@ -2914,17 +2991,17 @@ declare namespace ts { * A function that is used to initialize and return a `Transformer` callback, which in turn * will be used to transform one or more nodes. */ - type TransformerFactory = (context: TransformationContext) => Transformer; + export type TransformerFactory = (context: TransformationContext) => Transformer; /** * A function that transforms a node. */ - type Transformer = (node: T) => T; + export type Transformer = (node: T) => T; /** * A function that accepts and possibly transforms a node. */ - type Visitor = (node: Node) => VisitResult; - type VisitResult = T | T[] | undefined; - interface Printer { + export type Visitor = (node: Node) => VisitResult; + export type VisitResult = T | T[] | undefined; + export interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. * @param hint A value indicating the purpose of a node. This is primarily used to @@ -2952,7 +3029,7 @@ declare namespace ts { */ printBundle(bundle: Bundle): string; } - interface PrintHandlers { + export interface PrintHandlers { /** * A hook used by the Printer when generating unique names to avoid collisions with * globally defined names that exist outside of the current source file. @@ -2995,28 +3072,33 @@ declare namespace ts { */ substituteNode?(hint: EmitHint, node: Node): Node; } - interface PrinterOptions { + export interface PrinterOptions { removeComments?: boolean; newLine?: NewLineKind; omitTrailingSemicolon?: boolean; noEmitHelpers?: boolean; } - interface GetEffectiveTypeRootsHost { + export interface GetEffectiveTypeRootsHost { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } - interface TextSpan { + export interface ModuleSpecifierResolutionHost extends GetEffectiveTypeRootsHost { + useCaseSensitiveFileNames?(): boolean; + fileExists?(path: string): boolean; + readFile?(path: string): string | undefined; + } + export interface TextSpan { start: number; length: number; } - interface TextChangeRange { + export interface TextChangeRange { span: TextSpan; newLength: number; } - interface SyntaxList extends Node { + export interface SyntaxList extends Node { _children: Node[]; } - enum ListFormat { + export enum ListFormat { None = 0, SingleLine = 0, MultiLine = 1, @@ -3083,7 +3165,7 @@ declare namespace ts { IndexSignatureParameters = 8848, JSDocComment = 33 } - interface UserPreferences { + export interface UserPreferences { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; @@ -3095,22 +3177,23 @@ declare namespace ts { readonly providePrefixAndSuffixTextForRename?: boolean; } /** Represents a bigint literal value without requiring bigint support */ - interface PseudoBigInt { + export interface PseudoBigInt { negative: boolean; base10Value: string; } + export {}; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; declare namespace ts { - enum FileWatcherEventKind { + export enum FileWatcherEventKind { Created = 0, Changed = 1, Deleted = 2 } - type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; - type DirectoryWatcherCallback = (fileName: string) => void; - interface System { + export type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind) => void; + export type DirectoryWatcherCallback = (fileName: string) => void; + export interface System { args: string[]; newLine: string; useCaseSensitiveFileNames: boolean; @@ -3132,7 +3215,7 @@ declare namespace ts { getExecutingFilePath(): string; getCurrentDirectory(): string; getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; @@ -3151,11 +3234,12 @@ declare namespace ts { base64decode?(input: string): string; base64encode?(input: string): string; } - interface FileWatcher { + export interface FileWatcher { close(): void; } - function getNodeMajorVersion(): number | undefined; - let sys: System; + export function getNodeMajorVersion(): number | undefined; + export let sys: System; + export {}; } declare namespace ts { type ErrorCallback = (message: DiagnosticMessage, length: number) => void; @@ -3166,6 +3250,7 @@ declare namespace ts { getTokenPos(): number; getTokenText(): string; getTokenValue(): string; + hasUnicodeEscape(): boolean; hasExtendedUnicodeEscape(): boolean; hasPrecedingLineBreak(): boolean; isIdentifier(): boolean; @@ -3178,6 +3263,7 @@ declare namespace ts { scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; + reScanQuestionToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; @@ -3215,7 +3301,7 @@ declare namespace ts { } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; + function sortAndDeduplicateDiagnostics(diagnostics: readonly T[]): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3244,13 +3330,13 @@ declare namespace ts { * This function will then merge those changes into a single change range valid between V1 and * Vn. */ - function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: readonly TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; name: Identifier; }; - function isParameterPropertyDeclaration(node: Node): node is ParameterPropertyDeclaration; + function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration; function isEmptyBindingPattern(node: BindingName): node is BindingPattern; function isEmptyBindingElement(node: BindingElement): boolean; function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration; @@ -3316,7 +3402,7 @@ declare namespace ts { * * For binding patterns, parameter tags are matched by position. */ - function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray; + function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[]; /** * Gets the JSDoc type parameter tags for the node if present. * @@ -3327,7 +3413,7 @@ declare namespace ts { * node are returned first, so in the previous example, the template * tag on the containing function expression would be first. */ - function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray; + function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[]; /** * Return true if the node has JSDoc parameter tags. * @@ -3369,14 +3455,14 @@ declare namespace ts { */ function getJSDocReturnType(node: Node): TypeNode | undefined; /** Get all JSDoc tags related to a node, including those on parent nodes. */ - function getJSDocTags(node: Node): ReadonlyArray; + function getJSDocTags(node: Node): readonly JSDocTag[]; /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ - function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray; + function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. */ - function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray; + function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; } declare namespace ts { @@ -3430,8 +3516,12 @@ declare namespace ts { function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression; function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression; function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression; + function isPropertyAccessChain(node: Node): node is PropertyAccessChain; function isElementAccessExpression(node: Node): node is ElementAccessExpression; + function isElementAccessChain(node: Node): node is ElementAccessChain; function isCallExpression(node: Node): node is CallExpression; + function isCallChain(node: Node): node is CallChain; + function isOptionalChain(node: Node): node is PropertyAccessChain | ElementAccessChain | CallChain; function isNewExpression(node: Node): node is NewExpression; function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression; function isTypeAssertion(node: Node): node is TypeAssertion; @@ -3529,7 +3619,7 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; - function isJSDocAllType(node: JSDocAllType): node is JSDocAllType; + function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType; @@ -3601,7 +3691,7 @@ declare namespace ts { function isStringLiteralLike(node: Node): node is StringLiteralLike; } declare namespace ts { - function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; + export function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, @@ -3615,25 +3705,26 @@ declare namespace ts { * @remarks `forEachChild` must visit the children of a node in the order * that they appear in the source code. The language service depends on this property to locate nodes by position. */ - function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; - function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; - function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; + export function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; + export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; + export function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; /** * Parse json text into SyntaxTree and return node and parse errors if any * @param fileName * @param sourceText */ - function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; - function isExternalModule(file: SourceFile): boolean; - function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export function parseJsonText(fileName: string, sourceText: string): JsonSourceFile; + export function isExternalModule(file: SourceFile): boolean; + export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + export {}; } declare namespace ts { - function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; - type DiagnosticReporter = (diagnostic: Diagnostic) => void; + export function parseCommandLine(commandLine: readonly string[], readFile?: (path: string) => string | undefined): ParsedCommandLine; + export type DiagnosticReporter = (diagnostic: Diagnostic) => void; /** * Reports config file diagnostics */ - interface ConfigFileDiagnosticsReporter { + export interface ConfigFileDiagnosticsReporter { /** * Reports unrecoverable error when parsing config file */ @@ -3642,18 +3733,18 @@ declare namespace ts { /** * Interface extending ParseConfigHost to support ParseConfigFile that reads config file and reports errors */ - interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { + export interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { getCurrentDirectory(): string; } /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; + export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file */ - function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { + export function readConfigFile(fileName: string, readFile: (path: string) => string | undefined): { config?: any; error?: Diagnostic; }; @@ -3662,7 +3753,7 @@ declare namespace ts { * @param fileName The path to the config file * @param jsonText The text of the config file */ - function parseConfigFileTextToJson(fileName: string, jsonText: string): { + export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic; }; @@ -3670,11 +3761,11 @@ declare namespace ts { * Read tsconfig.json file * @param fileName The path to the config file */ - function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; + export function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile; /** * Convert the json syntax tree into the json value */ - function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; + export function convertToObject(sourceFile: JsonSourceFile, errors: Push): any; /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -3682,7 +3773,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3690,8 +3781,8 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; - interface ParsedTsconfig { + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; + export interface ParsedTsconfig { raw: any; options?: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -3700,18 +3791,19 @@ declare namespace ts { */ extendedConfigPath?: string; } - interface ExtendedConfigCacheEntry { + export interface ExtendedConfigCacheEntry { extendedResult: TsConfigSourceFile; extendedConfig: ParsedTsconfig | undefined; } - function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; }; - function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { + export function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypeAcquisition; errors: Diagnostic[]; }; + export {}; } declare namespace ts { function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; @@ -3755,7 +3847,7 @@ declare namespace ts { 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; + function createNodeArray(elements?: readonly T[], 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 | PseudoBigInt): NumericLiteral; @@ -3793,62 +3885,64 @@ declare namespace ts { function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - function createParameter(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + function createParameter(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createPropertySignature(modifiers: ReadonlyArray | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function updatePropertySignature(node: PropertySignature, modifiers: ReadonlyArray | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function createProperty(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function createMethodSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createProperty(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function createMethodSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; - function createMethod(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function createConstructor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function createGetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function createSetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function createCallSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createMethod(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; - function createConstructSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - function createIndexSignature(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; - function updateIndexSignature(node: IndexSignatureDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; + function createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; - function createTypeReferenceNode(typeName: string | EntityName, typeArguments: ReadonlyArray | undefined): TypeReferenceNode; + function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode; function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; - function createFunctionTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): FunctionTypeNode; + function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; - function createConstructorTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructorTypeNode; + function createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; + function createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; - function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createTupleTypeNode(elementTypes: readonly TypeNode[]): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]): TupleTypeNode; function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; function createRestTypeNode(type: TypeNode): RestTypeNode; function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; - function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; + function createUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; - function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; + function createIntersectionTypeNode(types: readonly TypeNode[]): IntersectionTypeNode; function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray): IntersectionTypeNode; - function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: ReadonlyArray): UnionOrIntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: readonly TypeNode[]): UnionOrIntersectionTypeNode; function createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; @@ -3861,36 +3955,42 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; - function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ReadonlyArray): ArrayBindingPattern; + function createObjectBindingPattern(elements: readonly BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: readonly BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: readonly ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: readonly ArrayBindingElement[]): ArrayBindingPattern; function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; - function createArrayLiteral(elements?: ReadonlyArray, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; - function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; + function createArrayLiteral(elements?: readonly Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier): PropertyAccessChain; + function updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier): PropertyAccessChain; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; - function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; + function createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain; + function updateElementAccessChain(node: ElementAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, argumentExpression: Expression): ElementAccessChain; + function createCall(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallExpression; + function createCallChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallChain; + function updateCallChain(node: CallChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallChain; + function createNew(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; /** @deprecated */ function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; /** @deprecated */ function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; - function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -3908,22 +4008,22 @@ declare namespace ts { /** @deprecated */ function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function createTemplateHead(text: string): TemplateHead; - function createTemplateMiddle(text: string): TemplateMiddle; - function createTemplateTail(text: string): TemplateTail; - function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; + function createTemplateExpression(head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function createTemplateHead(text: string, rawText?: string): TemplateHead; + function createTemplateMiddle(text: string, rawText?: string): TemplateMiddle; + function createTemplateTail(text: string, rawText?: string): TemplateTail; + function createNoSubstitutionTemplateLiteral(text: string, rawText?: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3933,10 +4033,10 @@ declare namespace ts { function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; - function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function updateBlock(node: Block, statements: ReadonlyArray): Block; - function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; + function createBlock(statements: readonly Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: readonly Statement[]): Block; + function createVariableStatement(modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; function createExpressionStatement(expression: Expression): ExpressionStatement; function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; @@ -3975,76 +4075,76 @@ declare namespace ts { function createDebuggerStatement(): DebuggerStatement; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - function createVariableDeclarationList(declarations: ReadonlyArray, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; - function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function createEnumDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, members: ReadonlyArray): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, members: ReadonlyArray): EnumDeclaration; - function createModuleDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; - function createModuleBlock(statements: ReadonlyArray): ModuleBlock; - function updateModuleBlock(node: ModuleBlock, statements: ReadonlyArray): ModuleBlock; - function createCaseBlock(clauses: ReadonlyArray): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: ReadonlyArray): CaseBlock; + function createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; + function createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + function createModuleBlock(statements: readonly Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; + function createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ReadonlyArray): NamedImports; - function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; + function createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; - function createNamedExports(elements: ReadonlyArray): NamedExports; - function updateNamedExports(node: NamedExports, elements: ReadonlyArray): NamedExports; + function createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; + function createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; - function createJsxElement(openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; + function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxFragment(openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function createJsxFragment(openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxText(text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function updateJsxText(node: JsxText, text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function createJsxOpeningFragment(): JsxOpeningFragment; function createJsxJsxClosingFragment(): JsxClosingFragment; - function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxAttributes(properties: ReadonlyArray): JsxAttributes; - function updateJsxAttributes(node: JsxAttributes, properties: ReadonlyArray): JsxAttributes; + function createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; - function createCaseClause(expression: Expression, statements: ReadonlyArray): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: ReadonlyArray): CaseClause; - function createDefaultClause(statements: ReadonlyArray): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; - function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; + function createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; + function createDefaultClause(statements: readonly Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause; + function createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause; function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; @@ -4055,7 +4155,7 @@ declare namespace ts { function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; - function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; + function updateSourceFileNode(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; /** * Creates a shallow, memberwise clone of a node for mutation. */ @@ -4077,20 +4177,20 @@ declare namespace ts { */ function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createCommaList(elements: ReadonlyArray): CommaListExpression; - function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; + function createCommaList(elements: readonly Expression[]): CommaListExpression; + function updateCommaList(node: CommaListExpression, elements: readonly Expression[]): CommaListExpression; + function createBundle(sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; - function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; + function updateBundle(node: Bundle, sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -4102,6 +4202,7 @@ declare namespace ts { function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createNullishCoalesce(left: Expression, right: Expression): BinaryExpression; function createLogicalNot(operand: Expression): PrefixUnaryExpression; function createVoidZero(): VoidExpression; function createExportDefault(expression: Expression): ExportAssignment; @@ -4158,7 +4259,7 @@ declare namespace ts { /** * Sets the constant value to emit for an expression. */ - function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): PropertyAccessExpression | ElementAccessExpression; + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): ElementAccessExpression | PropertyAccessExpression; /** * Adds an EmitHelper to a node. */ @@ -4263,23 +4364,25 @@ declare namespace ts { function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; } declare namespace ts { + function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined; + function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[]; function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } 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): ReadonlyArray; - interface FormatDiagnosticsHost { + export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; + export function resolveTripleslashReference(moduleName: string, containingFile: string): string; + export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + export interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; getNewLine(): string; } - function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; - function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; - function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + export function formatDiagnostics(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; + export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; + export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; + export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4290,7 +4393,7 @@ declare namespace ts { * @param createProgramOptions - The options for creating a program. * @returns A 'Program' object. */ - function createProgram(createProgramOptions: CreateProgramOptions): Program; + export function createProgram(createProgramOptions: CreateProgramOptions): Program; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4305,16 +4408,17 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; - /** @deprecated */ interface ResolveProjectReferencePathHost { + export function createProgram(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): Program; + /** @deprecated */ export interface ResolveProjectReferencePathHost { fileExists(fileName: string): boolean; } /** * Returns the target config filename of a project reference. * Note: The file might not exist. */ - function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; - /** @deprecated */ function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export function resolveProjectReferencePath(ref: ProjectReference): ResolvedConfigFileName; + /** @deprecated */ export function resolveProjectReferencePath(host: ResolveProjectReferencePathHost, ref: ProjectReference): ResolvedConfigFileName; + export {}; } declare namespace ts { interface EmitOutput { @@ -4366,31 +4470,31 @@ declare namespace ts { /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Get the diagnostics for compiler options */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics that dont belong to any file */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics from config file parsing */ - getConfigFileParsingDiagnostics(): ReadonlyArray; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Get the syntax diagnostics, for all source files if source file is not supplied */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the declaration diagnostics, for all source files if source file is not supplied */ - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** * Get all the dependencies of the file */ - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; + getAllDependencies(sourceFile: SourceFile): readonly string[]; /** * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program * The semantic diagnostics are cached and managed here @@ -4399,7 +4503,7 @@ declare namespace ts { * In case of SemanticDiagnosticsBuilderProgram if the source file is not provided, * it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Emits the JavaScript and declaration files. * When targetSource file is specified, emits the files corresponding to that source file, @@ -4425,7 +4529,7 @@ declare namespace ts { * Gets the semantic diagnostics from the program for the next affected file and caches it * Returns undefined if the iteration is complete */ - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; } /** * The builder that can handle the changes in program and iterate through changed file to emit the files @@ -4442,19 +4546,19 @@ declare namespace ts { /** * Create the builder to manage semantic diagnostics and cache them */ - function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ - function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ - function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): BuilderProgram; + function createAbstractBuilder(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram; } declare namespace ts { interface ReadBuildProgramHost { @@ -4465,21 +4569,21 @@ declare namespace ts { function readBuilderProgram(compilerOptions: CompilerOptions, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram | undefined; function createIncrementalCompilerHost(options: CompilerOptions, system?: System): CompilerHost; interface IncrementalProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - configFileParsingDiagnostics?: ReadonlyArray; - projectReferences?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; createProgram?: CreateProgram; } function createIncrementalProgram({ rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram }: IncrementalProgramOptions): T; - type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; + type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number) => void; /** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */ - type CreateProgram = (rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray | undefined) => T; + type CreateProgram = (rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[] | undefined) => T; /** Host that has watch functionality used in --watch mode */ interface WatchHost { /** If provided, called with Diagnostic message that informs about change in watch status */ - onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions): void; + onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number): void; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4515,7 +4619,7 @@ declare namespace ts { /** If provided, used in resolutions as well as handling directory structure */ getDirectories?(path: string): string[]; /** If provided, used to cache and handle directory structure modifications */ - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; /** Symbol links resolution */ realpath?(path: string): string; /** If provided would be used to write log about compilation */ @@ -4523,9 +4627,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[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; } interface WatchCompilerHost extends ProgramHost, WatchHost { /** If provided, callback to invoke after every new program creation */ @@ -4540,7 +4644,7 @@ declare namespace ts { /** Compiler options */ options: CompilerOptions; /** Project References */ - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; } /** * Host to create watch with config file @@ -4554,7 +4658,7 @@ declare namespace ts { * Used to generate source file names from the config file and its include, exclude, files rules * and also to cache the directory stucture */ - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; } interface Watch { /** Synchronize with host and get updated program */ @@ -4578,7 +4682,7 @@ declare namespace ts { * Create the watch compiler host for either configFile or fileNames and its options */ function createWatchCompilerHost(configFileName: string, optionsToExtend: CompilerOptions | undefined, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfConfigFile; - function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray): WatchCompilerHostOfFilesAndCompilerOptions; + function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions; /** * Creates the watch from the host for root files and compiler options */ @@ -4631,8 +4735,8 @@ declare namespace ts { function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter; function createSolutionBuilderHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary): SolutionBuilderHost; function createSolutionBuilderWithWatchHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): SolutionBuilderWithWatchHost; - function createSolutionBuilder(host: SolutionBuilderHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; - function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilder(host: SolutionBuilderHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; enum InvalidatedProjectKind { Build = 0, UpdateBundle = 1, @@ -4657,14 +4761,14 @@ declare namespace ts { getBuilderProgram(): T | undefined; getProgram(): Program | undefined; getSourceFile(fileName: string): SourceFile | undefined; - getSourceFiles(): ReadonlyArray; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSourceFiles(): readonly SourceFile[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getAllDependencies(sourceFile: SourceFile): readonly string[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } interface UpdateBundleProject extends InvalidatedProjectBase { @@ -4727,7 +4831,7 @@ declare namespace ts.server { readonly kind: EventBeginInstallTypes | EventEndInstallTypes; readonly eventId: number; readonly typingsInstallerVersion: string; - readonly packagesToInstall: ReadonlyArray; + readonly packagesToInstall: readonly string[]; } interface BeginInstallTypes extends InstallTypes { readonly kind: EventBeginInstallTypes; @@ -4780,8 +4884,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): ReadonlyArray; - getConstructSignatures(): ReadonlyArray; + getCallSignatures(): readonly Signature[]; + getConstructSignatures(): readonly Signature[]; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4809,7 +4913,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): ReadonlyArray; + getLineStarts(): readonly number[]; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -4858,7 +4962,7 @@ declare namespace ts { fileName: Path; packageName: string; } - interface LanguageServiceHost extends GetEffectiveTypeRootsHost { + interface LanguageServiceHost extends ModuleSpecifierResolutionHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; getProjectVersion?(): string; @@ -4866,7 +4970,7 @@ declare namespace ts { getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; - getProjectReferences?(): ReadonlyArray | undefined; + getProjectReferences?(): readonly ProjectReference[] | undefined; getLocalizedDiagnosticMessages?(): any; getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; @@ -4874,15 +4978,14 @@ declare namespace ts { log?(s: string): void; trace?(s: string): void; error?(s: string): void; - useCaseSensitiveFileNames?(): boolean; - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. @@ -4920,17 +5023,17 @@ 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, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined; getSmartSelectionRange(fileName: string, position: number): SelectionRange; - getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; - getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): readonly ImplementationLocation[] | 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): ReadonlyArray | undefined; + getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4950,7 +5053,7 @@ declare namespace ts { getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: FormatCodeSettings, preferences: UserPreferences): readonly CodeFixAction[]; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise; applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise; @@ -4963,8 +5066,8 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined; - organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; + organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program | undefined; dispose(): void; @@ -5113,8 +5216,8 @@ declare namespace ts { fixAllDescription?: string; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray; + changes: readonly FileTextChanges[]; + commands?: readonly CodeActionCommand[]; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -5235,6 +5338,11 @@ declare namespace ts { Block = 1, Smart = 2 } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorOptions { BaseIndentSize?: number; IndentSize: number; @@ -5287,6 +5395,7 @@ declare namespace ts { readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; readonly insertSpaceBeforeTypeAnnotation?: boolean; readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly semicolons?: SemicolonPreference; } function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; interface DefinitionInfo extends DocumentSpan { @@ -5296,7 +5405,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions?: ReadonlyArray; + definitions?: readonly DefinitionInfo[]; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -5665,6 +5774,7 @@ declare namespace ts { } } declare namespace ts { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier(): Classifier; } declare namespace ts { diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index cc593ef2db30f..54643542c23c9 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -14,6 +14,13 @@ and limitations under the License. ***************************************************************************** */ "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -73,7 +80,7 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -91,7 +98,7 @@ var ts; ts.emptyArray = []; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -126,7 +133,7 @@ var ts; } ts.createMapFromTemplate = createMapFromTemplate; // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name + // eslint-disable-next-line no-in-operator ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { @@ -190,7 +197,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -287,6 +294,21 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Like `forEach`, but iterates in reverse order. + */ + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ function firstDefined(array, callback) { if (array === undefined) { @@ -783,7 +805,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -840,6 +862,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1230,6 +1253,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1368,6 +1403,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1427,7 +1468,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1461,7 +1502,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1935,11 +1976,33 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2016,8 +2079,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2066,6 +2131,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2081,7 +2147,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2189,6 +2255,9 @@ var ts; Debug.assertNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1 /* Normal */) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -2369,6 +2438,47 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + // require() will throw an exception if the module is not installed + // It may also return undefined if not installed properly + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { // https://semver.org/#spec-item-2 // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative @@ -2767,358 +2877,366 @@ var ts; 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"; + SyntaxKind[SyntaxKind["QuestionDotToken"] = 28] = "QuestionDotToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 29] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 30] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 31] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 32] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 33] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 34] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 35] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 36] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 37] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 38] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 39] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 40] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 41] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 42] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 43] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 44] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 45] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 46] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 47] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 49] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 50] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 51] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 52] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 53] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 54] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 55] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 56] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 57] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 58] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 59] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - SyntaxKind[SyntaxKind["BacktickToken"] = 59] = "BacktickToken"; + SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 60] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 61] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 62] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 63] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 64] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 65] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 66] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 67] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 69] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 70] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 71] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 72] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 74] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 73] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 75] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 74] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 75] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 76] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 77] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 78] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 79] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 80] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 81] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 82] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 83] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 84] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 85] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 86] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 87] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 88] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 89] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 90] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 91] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 92] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 93] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 94] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 95] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 96] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 97] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 98] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 99] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 100] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 101] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 102] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 103] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 104] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 105] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 106] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 107] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 108] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 109] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 76] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 77] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 78] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 79] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 80] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 81] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 82] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 83] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 84] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 85] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 86] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 87] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 88] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 89] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 90] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 91] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 92] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 93] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 94] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 95] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 96] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 97] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 98] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 99] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 100] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 101] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 102] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 103] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 104] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 105] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 106] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 107] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 108] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 109] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 110] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 111] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 110] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 111] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 112] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 113] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 114] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 115] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 116] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 117] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 118] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 112] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 113] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 114] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 115] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 116] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 117] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 118] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 119] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 120] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 119] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 120] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 121] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 122] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 123] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 124] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 125] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 126] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 127] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 128] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 129] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 130] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 131] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 132] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 133] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 134] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 135] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 136] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 137] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 138] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 139] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 140] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 141] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 142] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 143] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 144] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 121] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 122] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 123] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 124] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 125] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 126] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 127] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 128] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 129] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 130] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 131] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 132] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 133] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 134] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 135] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 136] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 137] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 138] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 139] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 140] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 141] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 142] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 143] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 144] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 145] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 146] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 147] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 148] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 149] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 150] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 151] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 152] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 153] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 154] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 155] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 156] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 157] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 158] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 159] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 160] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 161] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 162] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 163] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 164] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 165] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 166] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 167] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 168] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 169] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 170] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 171] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 172] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 173] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 174] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 175] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 176] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 177] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 178] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 179] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 180] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 181] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 182] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 183] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 184] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 185] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 186] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 187] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 188] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 189] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 190] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 191] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 192] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 193] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 194] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 195] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 196] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 197] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 198] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 199] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 200] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 201] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 202] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 203] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 204] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 205] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 206] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 207] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 208] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 209] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 210] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 211] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 212] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 213] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 214] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 215] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 216] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 217] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 218] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 219] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 220] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 221] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 222] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 223] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 224] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 225] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 226] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 227] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 228] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 229] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 230] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 231] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 232] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 233] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 234] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 235] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 236] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 237] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 238] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 239] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 240] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 241] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 242] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 243] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 244] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 245] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 246] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 247] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 248] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 249] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 250] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 251] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 252] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 253] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 254] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 255] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 256] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 257] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 258] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 259] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 260] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 261] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 262] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 263] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 264] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 265] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 266] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 267] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 268] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 269] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 270] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 271] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 272] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 273] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 274] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 275] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 276] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 277] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 278] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 279] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 280] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 281] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 282] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 283] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 284] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 285] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 286] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 287] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 288] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 289] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 290] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 291] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 292] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 293] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 297] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 298] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 299] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 300] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 301] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 302] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 303] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 304] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 305] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 306] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 307] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 308] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 309] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 310] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 311] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 312] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 294] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 295] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 296] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 297] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 298] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 299] = "JSDocVariadicType"; + // https://jsdoc.app/about-namepaths.html + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 300] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 301] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 302] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 303] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 304] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 305] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 306] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 307] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 308] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 309] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 310] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 311] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 312] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 313] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 314] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 315] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 316] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 313] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 317] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 314] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 315] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 316] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 317] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 318] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 318] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 319] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 320] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 321] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 322] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 323] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 319] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 324] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 61] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 72] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 74] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 74] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 76] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 111] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 76] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 151] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 112] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 120] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 167] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 187] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 74] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 151] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 312] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 300] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 312] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 74] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 224] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 240] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 152] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 292] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 316] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 304] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 316] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 121] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 151] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3128,20 +3246,21 @@ var ts; NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain"; + NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 1024] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2048] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4096] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData"; // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid // walking the tree if the flags are not set. However, these flags are just a approximation // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. @@ -3151,23 +3270,23 @@ var ts; // removal, it is likely that users will add the import anyway. // The advantage of this approach is its simplicity. For the case of batch compilation, // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta"; - NodeFlags[NodeFlags["JSDoc"] = 2097152] = "JSDoc"; - /* @internal */ NodeFlags[NodeFlags["Ambient"] = 4194304] = "Ambient"; - /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 8388608] = "InWithStatement"; - NodeFlags[NodeFlags["JsonFile"] = 16777216] = "JsonFile"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta"; + NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc"; + /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient"; + /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement"; + NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 12679168] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags"; // Represents all flags that are potentially set once and // never cleared on SourceFiles which get re-used in between incremental parses. // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. - /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags"; + /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -3206,7 +3325,10 @@ var ts; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; - RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + RelationComparisonResult[RelationComparisonResult["Reported"] = 4] = "Reported"; + RelationComparisonResult[RelationComparisonResult["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable"; + RelationComparisonResult[RelationComparisonResult["ReportsUnreliable"] = 16] = "ReportsUnreliable"; + RelationComparisonResult[RelationComparisonResult["ReportsMask"] = 24] = "ReportsMask"; })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ var GeneratedIdentifierFlags; @@ -3242,6 +3364,8 @@ var ts; /* @internal */ TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator"; /* @internal */ + TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; + /* @internal */ TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; @@ -3257,12 +3381,13 @@ var ts; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; - FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Call"] = 512] = "Call"; + FlowFlags[FlowFlags["Referenced"] = 1024] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 2048] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 4096] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 8192] = "AfterFinally"; /** @internal */ - FlowFlags[FlowFlags["Cached"] = 8192] = "Cached"; + FlowFlags[FlowFlags["Cached"] = 16384] = "Cached"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -3272,6 +3397,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3292,6 +3424,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3357,7 +3491,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3407,27 +3540,40 @@ var ts; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + TypePredicateKind[TypePredicateKind["AssertsThis"] = 2] = "AssertsThis"; + TypePredicateKind[TypePredicateKind["AssertsIdentifier"] = 3] = "AssertsIdentifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3465,32 +3611,32 @@ var ts; SymbolFlags[SymbolFlags["All"] = 67108863] = "All"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 67220415] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 67897832] = "Type"; + SymbolFlags[SymbolFlags["Value"] = 111551] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 788968] = "Type"; SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; // Variables can be redeclared, but can not redeclare a block-scoped declaration with the // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 67220414] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 111550] = "FunctionScopedVariableExcludes"; // Block-scoped declarations are not allowed to be re-declared // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 67220415] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 67220415] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 111551] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 111551] = "ParameterExcludes"; SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 68008959] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 67219887] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 68008383] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 67897736] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 68008191] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 68008831] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 110991] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899503] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 788872] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 110735] = "ValueModuleExcludes"; SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 67212223] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 67154879] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 67187647] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 67635688] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 67897832] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 103359] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 46015] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 78783] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 526824] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 788968] = "TypeAliasExcludes"; SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; @@ -3498,11 +3644,15 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; /* @internal */ + SymbolFlags[SymbolFlags["ExportSupportsDefaultModifier"] = 112] = "ExportSupportsDefaultModifier"; + /* @internal */ + SymbolFlags[SymbolFlags["ExportDoesNotSupportDefaultModifier"] = -113] = "ExportDoesNotSupportDefaultModifier"; + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable"; /* @internal */ - SymbolFlags[SymbolFlags["LateBindingContainer"] = 6240] = "LateBindingContainer"; + SymbolFlags[SymbolFlags["LateBindingContainer"] = 6256] = "LateBindingContainer"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ var EnumKind; @@ -3740,7 +3890,9 @@ var ts; InferencePriority[InferencePriority["LiteralKeyof"] = 32] = "LiteralKeyof"; InferencePriority[InferencePriority["NoConstraints"] = 64] = "NoConstraints"; InferencePriority[InferencePriority["AlwaysStrict"] = 128] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 256] = "MaxValue"; InferencePriority[InferencePriority["PriorityImpliesCombination"] = 56] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ var InferenceFlags; @@ -3818,6 +3970,9 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + // NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind. + // Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES + // module kind). ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); @@ -4402,7 +4557,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -4556,6 +4711,38 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + /* @internal */ + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; /** * Returns true if file status changed */ @@ -4582,6 +4769,8 @@ var ts; ts.getFileWatcherEventKind = getFileWatcherEventKind; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + /*@internal*/ + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4686,6 +4875,32 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + /** + * patch writefile to create folder before writing the file + */ + /*@internal*/ + function patchWriteFileEnsuringDirectory(sys) { + // patch writefile to create folder before writing the file + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -4702,12 +4917,14 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does // not actually work. var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -4719,9 +4936,12 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; + var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); var FileSystemEntryKind; @@ -4732,6 +4952,7 @@ var ts; var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -4798,8 +5019,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -4825,6 +5048,90 @@ var ts; base64encode: function (input) { return bufferFrom(input).toString("base64"); }, }; return nodeSystem; + /** + * Uses the builtin inspector APIs to capture a CPU profile + * See https://nodejs.org/api/inspector.html#inspector_example_usage for details + */ + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + /** + * Strips non-TS paths from the profile, so users with private projects shouldn't + * need to worry about leaking paths by submitting a cpu profile to us + */ + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + // do nothing and ignore fallible fs operation + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + // do nothing and ignore fallible fs operation + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { // See https://github.com/Microsoft/TypeScript/issues/25652 return Buffer.from && Buffer.from !== Int8Array.from @@ -4868,7 +5175,7 @@ var ts; return useNonPollingWatchers ? createNonPollingWatchFile() : // Default to do not use polling interval as it is before this experiment branch - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, /*pollingInterval*/ undefined); }; } function getWatchDirectory() { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows @@ -4942,7 +5249,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -5000,6 +5307,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } /** Watcher for the file system entry depending on whether it is missing or present */ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : @@ -5016,6 +5329,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -5040,7 +5354,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); // Watch the missing file or directory or error presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; @@ -5052,11 +5368,23 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations + // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } /** * Watch the file or directory using fs.watchFile since fs.watch threw exception * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } /** @@ -5089,7 +5417,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -5117,7 +5445,14 @@ var ts; // Default is UTF-8 with no byte order mark return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); // If a BOM is required, emit one if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; @@ -5134,6 +5469,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -5189,6 +5525,7 @@ var ts; return fileSystemEntryExists(path, 1 /* Directory */); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } function realpath(path) { @@ -5266,16 +5603,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -5287,14 +5614,7 @@ var ts; } if (sys) { // patch writefile to create folder before writing the file - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -5313,10 +5633,9 @@ var ts; /* @internal */ var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; } - // tslint:disable-next-line variable-name ts.Diagnostics = { Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), @@ -5379,7 +5698,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -5434,7 +5752,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -5532,6 +5849,7 @@ var ts; A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -5564,7 +5882,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -5578,6 +5896,16 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(1359, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_1359", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(1360, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_1360", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), 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."), @@ -5621,7 +5949,7 @@ var ts; Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), @@ -5869,6 +6197,9 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -5991,6 +6322,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), 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}'."), @@ -6077,6 +6416,9 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -6087,6 +6429,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -6112,6 +6455,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -6299,6 +6643,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + 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}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -6317,9 +6662,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), 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}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -6358,6 +6705,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -6444,6 +6793,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -6473,6 +6824,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6590,6 +6942,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -6600,94 +6960,95 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 73 /* Identifier */; + return token >= 75 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119 /* AbstractKeyword */, - any: 121 /* AnyKeyword */, - as: 120 /* AsKeyword */, - bigint: 147 /* BigIntKeyword */, - boolean: 124 /* BooleanKeyword */, - break: 74 /* BreakKeyword */, - case: 75 /* CaseKeyword */, - catch: 76 /* CatchKeyword */, - class: 77 /* ClassKeyword */, - continue: 79 /* ContinueKeyword */, - const: 78 /* ConstKeyword */ + abstract: 121 /* AbstractKeyword */, + any: 124 /* AnyKeyword */, + as: 122 /* AsKeyword */, + asserts: 123 /* AssertsKeyword */, + bigint: 150 /* BigIntKeyword */, + boolean: 127 /* BooleanKeyword */, + break: 76 /* BreakKeyword */, + case: 77 /* CaseKeyword */, + catch: 78 /* CatchKeyword */, + class: 79 /* ClassKeyword */, + continue: 81 /* ContinueKeyword */, + const: 80 /* ConstKeyword */ }, - _a["" + "constructor"] = 125 /* ConstructorKeyword */, - _a.debugger = 80 /* DebuggerKeyword */, - _a.declare = 126 /* DeclareKeyword */, - _a.default = 81 /* DefaultKeyword */, - _a.delete = 82 /* DeleteKeyword */, - _a.do = 83 /* DoKeyword */, - _a.else = 84 /* ElseKeyword */, - _a.enum = 85 /* EnumKeyword */, - _a.export = 86 /* ExportKeyword */, - _a.extends = 87 /* ExtendsKeyword */, - _a.false = 88 /* FalseKeyword */, - _a.finally = 89 /* FinallyKeyword */, - _a.for = 90 /* ForKeyword */, - _a.from = 145 /* FromKeyword */, - _a.function = 91 /* FunctionKeyword */, - _a.get = 127 /* GetKeyword */, - _a.if = 92 /* IfKeyword */, - _a.implements = 110 /* ImplementsKeyword */, - _a.import = 93 /* ImportKeyword */, - _a.in = 94 /* InKeyword */, - _a.infer = 128 /* InferKeyword */, - _a.instanceof = 95 /* InstanceOfKeyword */, - _a.interface = 111 /* InterfaceKeyword */, - _a.is = 129 /* IsKeyword */, - _a.keyof = 130 /* KeyOfKeyword */, - _a.let = 112 /* LetKeyword */, - _a.module = 131 /* ModuleKeyword */, - _a.namespace = 132 /* NamespaceKeyword */, - _a.never = 133 /* NeverKeyword */, - _a.new = 96 /* NewKeyword */, - _a.null = 97 /* NullKeyword */, - _a.number = 136 /* NumberKeyword */, - _a.object = 137 /* ObjectKeyword */, - _a.package = 113 /* PackageKeyword */, - _a.private = 114 /* PrivateKeyword */, - _a.protected = 115 /* ProtectedKeyword */, - _a.public = 116 /* PublicKeyword */, - _a.readonly = 134 /* ReadonlyKeyword */, - _a.require = 135 /* RequireKeyword */, - _a.global = 146 /* GlobalKeyword */, - _a.return = 98 /* ReturnKeyword */, - _a.set = 138 /* SetKeyword */, - _a.static = 117 /* StaticKeyword */, - _a.string = 139 /* StringKeyword */, - _a.super = 99 /* SuperKeyword */, - _a.switch = 100 /* SwitchKeyword */, - _a.symbol = 140 /* SymbolKeyword */, - _a.this = 101 /* ThisKeyword */, - _a.throw = 102 /* ThrowKeyword */, - _a.true = 103 /* TrueKeyword */, - _a.try = 104 /* TryKeyword */, - _a.type = 141 /* TypeKeyword */, - _a.typeof = 105 /* TypeOfKeyword */, - _a.undefined = 142 /* UndefinedKeyword */, - _a.unique = 143 /* UniqueKeyword */, - _a.unknown = 144 /* UnknownKeyword */, - _a.var = 106 /* VarKeyword */, - _a.void = 107 /* VoidKeyword */, - _a.while = 108 /* WhileKeyword */, - _a.with = 109 /* WithKeyword */, - _a.yield = 118 /* YieldKeyword */, - _a.async = 122 /* AsyncKeyword */, - _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a["" + "constructor"] = 128 /* ConstructorKeyword */, + _a.debugger = 82 /* DebuggerKeyword */, + _a.declare = 129 /* DeclareKeyword */, + _a.default = 83 /* DefaultKeyword */, + _a.delete = 84 /* DeleteKeyword */, + _a.do = 85 /* DoKeyword */, + _a.else = 86 /* ElseKeyword */, + _a.enum = 87 /* EnumKeyword */, + _a.export = 88 /* ExportKeyword */, + _a.extends = 89 /* ExtendsKeyword */, + _a.false = 90 /* FalseKeyword */, + _a.finally = 91 /* FinallyKeyword */, + _a.for = 92 /* ForKeyword */, + _a.from = 148 /* FromKeyword */, + _a.function = 93 /* FunctionKeyword */, + _a.get = 130 /* GetKeyword */, + _a.if = 94 /* IfKeyword */, + _a.implements = 112 /* ImplementsKeyword */, + _a.import = 95 /* ImportKeyword */, + _a.in = 96 /* InKeyword */, + _a.infer = 131 /* InferKeyword */, + _a.instanceof = 97 /* InstanceOfKeyword */, + _a.interface = 113 /* InterfaceKeyword */, + _a.is = 132 /* IsKeyword */, + _a.keyof = 133 /* KeyOfKeyword */, + _a.let = 114 /* LetKeyword */, + _a.module = 134 /* ModuleKeyword */, + _a.namespace = 135 /* NamespaceKeyword */, + _a.never = 136 /* NeverKeyword */, + _a.new = 98 /* NewKeyword */, + _a.null = 99 /* NullKeyword */, + _a.number = 139 /* NumberKeyword */, + _a.object = 140 /* ObjectKeyword */, + _a.package = 115 /* PackageKeyword */, + _a.private = 116 /* PrivateKeyword */, + _a.protected = 117 /* ProtectedKeyword */, + _a.public = 118 /* PublicKeyword */, + _a.readonly = 137 /* ReadonlyKeyword */, + _a.require = 138 /* RequireKeyword */, + _a.global = 149 /* GlobalKeyword */, + _a.return = 100 /* ReturnKeyword */, + _a.set = 141 /* SetKeyword */, + _a.static = 119 /* StaticKeyword */, + _a.string = 142 /* StringKeyword */, + _a.super = 101 /* SuperKeyword */, + _a.switch = 102 /* SwitchKeyword */, + _a.symbol = 143 /* SymbolKeyword */, + _a.this = 103 /* ThisKeyword */, + _a.throw = 104 /* ThrowKeyword */, + _a.true = 105 /* TrueKeyword */, + _a.try = 106 /* TryKeyword */, + _a.type = 144 /* TypeKeyword */, + _a.typeof = 107 /* TypeOfKeyword */, + _a.undefined = 145 /* UndefinedKeyword */, + _a.unique = 146 /* UniqueKeyword */, + _a.unknown = 147 /* UnknownKeyword */, + _a.var = 108 /* VarKeyword */, + _a.void = 109 /* VoidKeyword */, + _a.while = 110 /* WhileKeyword */, + _a.with = 111 /* WithKeyword */, + _a.yield = 120 /* YieldKeyword */, + _a.async = 125 /* AsyncKeyword */, + _a.await = 126 /* AwaitKeyword */, + _a.of = 151 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - 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 */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 74 /* CaretEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6734,6 +7095,14 @@ var ts; */ 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,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 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, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 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, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 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, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 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, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + /** + * Generated by scripts/regenerate-unicode-identifier-parts.js on node v12.4.0 with unicode 12.1 + * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords + * unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and + * unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start + */ + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 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, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 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, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 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, 2809, 2809, 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, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 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, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 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, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 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, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 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, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 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, 43824, 43866, 43868, 43879, 43888, 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, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 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, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -6760,15 +7129,17 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -6941,6 +7312,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7264,11 +7636,12 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -7292,17 +7665,18 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */; }, + isIdentifier: function () { return token === 75 /* Identifier */ || token > 111 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -7312,6 +7686,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -7326,6 +7701,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7425,7 +7809,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -7633,6 +8017,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024 /* UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: @@ -7715,21 +8100,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92 /* backslash */) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024 /* UnicodeEscape */; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters pos += 6; start = pos; @@ -7753,7 +8158,7 @@ var ts; } } } - return token = 73 /* Identifier */; + return token = 75 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -7817,14 +8222,14 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); // Special handling for shebang if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); @@ -7888,12 +8293,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 34 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* ExclamationEqualsToken */; } pos++; - return token = 52 /* ExclamationToken */; + return token = 53 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -7902,19 +8307,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* PercentEqualsToken */; + return pos += 2, token = 68 /* PercentEqualsToken */; } pos++; - return token = 43 /* PercentToken */; + return token = 44 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 54 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* AmpersandEqualsToken */; + return pos += 2, token = 72 /* AmpersandEqualsToken */; } pos++; - return token = 49 /* AmpersandToken */; + return token = 50 /* AmpersandToken */; case 40 /* openParen */: pos++; return token = 20 /* OpenParenToken */; @@ -7923,13 +8328,13 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AsteriskEqualsToken */; + return pos += 2, token = 65 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 41 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -7937,28 +8342,28 @@ var ts; asteriskSeen = true; continue; } - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 44 /* PlusPlusToken */; + return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* PlusEqualsToken */; + return pos += 2, token = 63 /* PlusEqualsToken */; } pos++; - return token = 38 /* PlusToken */; + return token = 39 /* PlusToken */; case 44 /* comma */: pos++; return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 45 /* MinusMinusToken */; + return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* MinusEqualsToken */; + return pos += 2, token = 64 /* MinusEqualsToken */; } pos++; - return token = 39 /* MinusToken */; + return token = 40 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -8019,10 +8424,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* SlashEqualsToken */; + return pos += 2, token = 67 /* SlashEqualsToken */; } pos++; - return token = 42 /* SlashToken */; + return token = 43 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -8080,7 +8485,7 @@ var ts; return token; case 58 /* colon */: pos++; - return token = 57 /* ColonToken */; + return token = 58 /* ColonToken */; case 59 /* semicolon */: pos++; return token = 26 /* SemicolonToken */; @@ -8096,20 +8501,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 46 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 31 /* LessThanEqualsToken */; + return pos += 2, token = 32 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 29 /* LessThanSlashToken */; + return pos += 2, token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8122,15 +8527,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 33 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 37 /* EqualsGreaterThanToken */; + return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8142,10 +8547,18 @@ var ts; } } pos++; - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 56 /* QuestionToken */; + if (text.charCodeAt(pos) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28 /* QuestionDotToken */; + } + if (text.charCodeAt(pos) === 63 /* question */) { + pos++; + return token = 60 /* QuestionQuestionToken */; + } + return token = 57 /* QuestionToken */; case 91 /* openBracket */: pos++; return token = 22 /* OpenBracketToken */; @@ -8154,10 +8567,10 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* CaretEqualsToken */; + return pos += 2, token = 74 /* CaretEqualsToken */; } pos++; - return token = 51 /* CaretToken */; + return token = 52 /* CaretToken */; case 123 /* openBrace */: pos++; return token = 18 /* OpenBraceToken */; @@ -8172,26 +8585,34 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 55 /* BarBarToken */; + return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* BarEqualsToken */; + return pos += 2, token = 73 /* BarEqualsToken */; } pos++; - return token = 50 /* BarToken */; + return token = 51 /* BarToken */; case 125 /* closeBrace */: pos++; return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 53 /* TildeToken */; + return token = 54 /* TildeToken */; case 64 /* at */: pos++; - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 92 /* backslash */: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -8200,9 +8621,9 @@ var ts; return token = 0 /* Unknown */; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { tokenValue += scanIdentifierParts(); @@ -8210,44 +8631,44 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1 /* PrecedingLineBreak */; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0 /* Unknown */; } } } function reScanGreaterToken() { - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 47 /* GreaterThanGreaterThanToken */; + return token = 48 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 32 /* GreaterThanEqualsToken */; + return token = 33 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 42 /* SlashToken */ || token === 65 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -8309,12 +8730,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46 /* LessThanLessThanToken */) { + if (token === 47 /* LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57 /* QuestionToken */; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -8324,10 +8750,10 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 29 /* LessThanSlashToken */; + return token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; @@ -8336,7 +8762,7 @@ var ts; // First non-whitespace character on this line. var firstNonWhitespace = 0; // These initial values are special because the first line is: - // firstNonWhitespace = 0 to indicate that we want leading whitspace, + // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { @@ -8370,17 +8796,22 @@ var ts; // they allow dashes function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; + // An identifier or keyword has already been parsed - check for a `-` and then append it and everything after it to the token + // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token + // Any caller should be expecting this behavior and should only read the pos or token value after calling it. while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45 /* minus */) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -8398,12 +8829,12 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9 /* tab */: case 11 /* verticalTab */: @@ -8414,13 +8845,13 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 123 /* openBrace */: return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: @@ -8430,23 +8861,44 @@ var ts; case 93 /* closeBracket */: return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 62 /* greaterThan */: - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 44 /* comma */: return token = 27 /* CommaToken */; case 46 /* dot */: return token = 24 /* DotToken */; case 96 /* backtick */: - return token = 59 /* BacktickToken */; - } - if (isIdentifierStart(ch, 99 /* Latest */)) { - while (isIdentifierPart(text.charCodeAt(pos), 99 /* Latest */) && pos < end) { + return token = 61 /* BacktickToken */; + case 92 /* backslash */: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0 /* Unknown */; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -8522,13 +8974,40 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; } } ts.createScanner = createScanner; + /* @internal */ + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt + var size = str.length; + // Account for out-of-bounds indices: + if (i < 0 || i >= size) { + return undefined; // String.codePointAt returns `undefined` for OOB indexes + } + // Get the first code unit + var first = str.charCodeAt(i); + // check if it’s the start of a surrogate pair + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { // high surrogate and there is a next code unit + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + /* @internal */ + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -8608,6 +9087,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str += " "; }, @@ -8695,7 +9176,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -8783,28 +9264,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144 /* HasAggregatedChildData */)) { + if (!(node.flags & 524288 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 262144 /* HasAggregatedChildData */; + node.flags |= 524288 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 288 /* SourceFile */) { node = node.parent; } return node; @@ -8812,11 +9293,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return true; } return false; @@ -8901,7 +9382,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -8984,7 +9465,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 === 313 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 317 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9003,7 +9484,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9049,6 +9530,8 @@ var ts; ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } + // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text + // had to include a backslash: `not \${a} substitution`. 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. @@ -9061,15 +9544,21 @@ var ts; return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } case 14 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings - return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings - return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 17 /* TemplateTail */: - return "}" + escapeText(node.text, 96 /* backtick */) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + switch (node.kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + return "`" + rawText + "`"; + case 15 /* TemplateHead */: + return "`" + rawText + "${"; + case 16 /* TemplateMiddle */: + return "}" + rawText + "${"; + case 17 /* TemplateTail */: + return "}" + rawText + "`"; + } + break; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 13 /* RegularExpressionLiteral */: @@ -9095,7 +9584,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 241 /* VariableDeclaration */ && node.parent.kind === 278 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9127,16 +9616,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 248 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 288 /* SourceFile */ || + node.kind === 248 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -9148,9 +9637,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 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9164,24 +9653,61 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /** + * Returns whether the source file will be treated as if it were in strict mode at runtime. + */ + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + // We can only verify strict mode for JS/TS files + switch (node.scriptKind) { + case 1 /* JS */: + case 3 /* TS */: + case 2 /* JSX */: + case 4 /* TSX */: + break; + default: + return false; + } + // Strict mode does not matter for declaration files. + if (node.isDeclarationFile) { + return false; + } + // If `alwaysStrict` is set, then treat the file as strict. + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + // Starting with a "use strict" directive indicates the file is strict. + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + // ECMAScript Modules are always strict. + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + // Other modules are strict unless otherwise specified. + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 278 /* CatchClause */: + case 248 /* ModuleDeclaration */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 219 /* Block */: + case 222 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9191,9 +9717,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 299 /* JSDocSignature */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 303 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9203,25 +9729,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9231,8 +9757,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9241,15 +9767,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 224 /* VariableStatement */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -9279,13 +9805,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -9296,11 +9822,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9345,7 +9871,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 222 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9359,7 +9885,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* 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 @@ -9368,25 +9894,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 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9394,6 +9920,7 @@ var ts; // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9423,7 +9950,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -9435,19 +9962,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 101 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 95 /* ImportKeyword */; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 95 /* ImportKeyword */ + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 225 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9456,11 +9989,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 155 /* Parameter */ || + node.kind === 154 /* TypeParameter */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 201 /* ArrowFunction */ || + node.kind === 199 /* 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 '/**/' @@ -9476,48 +10009,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= node.kind && node.kind <= 187 /* LastTypeNode */) { return true; } switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: return true; - case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + case 109 /* VoidKeyword */: + return node.parent.kind !== 204 /* VoidExpression */; + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 154 /* TypeParameter */: + return node.parent.kind === 185 /* MappedType */ || node.parent.kind === 180 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 73 /* Identifier */: + case 75 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 193 /* 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 === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */ || node.kind === 193 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: - case 101 /* ThisKeyword */: { + case 152 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 103 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 171 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 187 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9526,40 +10059,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 (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= parent.kind && parent.kind <= 187 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return node === parent.constraint; - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9584,23 +10117,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 250 /* CaseBlock */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9610,26 +10143,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* 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 === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* 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); @@ -9652,10 +10185,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 173 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 168 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9665,12 +10198,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 172 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return node.properties; } } @@ -9678,14 +10211,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 282 /* EnumMember */: + case 155 /* Parameter */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 241 /* VariableDeclaration */: return true; } } @@ -9697,8 +10230,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 242 /* VariableDeclarationList */ + && node.parent.parent.kind === 224 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9709,13 +10242,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return true; } return false; @@ -9726,7 +10259,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 237 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9734,17 +10267,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 222 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 160 /* MethodDeclaration */ && node.parent.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 160 /* MethodDeclaration */ && + (node.parent.kind === 192 /* ObjectLiteralExpression */ || + node.parent.kind === 213 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9757,7 +10290,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9798,14 +10331,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 288 /* 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 150 /* ComputedPropertyName */: + case 153 /* 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 @@ -9820,9 +10353,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* 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; @@ -9833,26 +10366,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 248 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 247 /* EnumDeclaration */: + case 288 /* SourceFile */: return node; } } @@ -9862,9 +10395,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return container; } } @@ -9886,27 +10419,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* 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; @@ -9922,21 +10455,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 200 /* FunctionExpression */ || func.kind === 201 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 199 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 195 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 /* SuperKeyword */ + return node.kind === 101 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -9945,8 +10478,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 99 /* SuperKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 101 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -9954,20 +10487,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 101 /* ThisKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 103 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: return node; } return undefined; @@ -9975,10 +10508,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9987,25 +10520,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 244 /* ClassDeclaration */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* 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 === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 244 /* ClassDeclaration */; + case 155 /* 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 === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 161 /* Constructor */ + || parent.kind === 160 /* MethodDeclaration */ + || parent.kind === 163 /* SetAccessor */) + && grandparent.kind === 244 /* ClassDeclaration */; } return false; } @@ -10021,10 +10554,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10033,9 +10566,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 266 /* JsxOpeningElement */ || + parent.kind === 265 /* JsxSelfClosingElement */ || + parent.kind === 267 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10043,57 +10576,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 216 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 212 /* SpreadElement */: + case 210 /* TemplateExpression */: + case 214 /* OmittedExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 211 /* YieldExpression */: + case 205 /* AwaitExpression */: + case 218 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 152 /* QualifiedName */: + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); - case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node); + case 75 /* Identifier */: + if (node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -10103,49 +10636,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 190 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 225 /* ExpressionStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 234 /* ReturnStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 238 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 229 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 156 /* Decorator */: + case 274 /* JsxExpression */: + case 273 /* JsxSpreadAttribute */: + case 281 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10153,7 +10686,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10162,7 +10695,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 263 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10174,15 +10707,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 131072 /* JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 4194304 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10190,15 +10723,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 /* StringKeyword */ || node.typeArguments[0].kind === 136 /* NumberKeyword */); + (node.typeArguments[0].kind === 142 /* StringKeyword */ || node.typeArguments[0].kind === 139 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + if (callExpression.kind !== 195 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 75 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -10229,21 +10762,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - 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 === 60 /* EqualsToken */ && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 /* EqualsToken */ && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -10253,13 +10790,14 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(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 === 55 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -10273,14 +10811,20 @@ var ts; } 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); }); + 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 === 60 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -10306,11 +10850,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 200 /* FunctionExpression */ || e.kind === 201 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 200 /* FunctionExpression */ || + initializer.kind === 213 /* ClassExpression */ || + initializer.kind === 201 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10327,14 +10871,16 @@ 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 === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && 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 === 60 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -10342,8 +10888,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 === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -10362,19 +10908,20 @@ var ts; * my.app = self.my.app || class { } */ function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 /* ThisKeyword */ || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -10389,10 +10936,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { @@ -10407,55 +10957,116 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0]); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */) || + isEntityNameExpression(node.expression) || + isBindableStaticElementAccessExpression(node.expression, /*excludeThisKeyword*/ true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */ || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0 /* None */; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8 /* ObjectDefinePropertyExports */; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9 /* ObjectDefinePrototypeProperty */; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 60 /* EqualsToken */ || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left)) { return 0 /* None */; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } return 6 /* Prototype */; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); } + /** + * Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions + * throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand) + */ + /* @internal */ + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; + } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; + } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101 /* ThisKeyword */) { + if (lhs.expression.kind === 103 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") { // exports.name = expr OR module.exports.name = expr return 1 /* ExportsProperty */; } @@ -10478,7 +11089,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 225 /* ExpressionStatement */ && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10487,7 +11099,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10496,14 +11108,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 186 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10513,12 +11125,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 252 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 263 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 187 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10527,11 +11139,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10539,19 +11151,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 253 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 155 /* Parameter */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 280 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10565,7 +11177,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 /* JSDocTypedefTag */ || node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 315 /* JSDocTypedefTag */ || node.kind === 308 /* JSDocCallbackTag */ || node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10575,7 +11187,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 /* EqualsToken */ + node.expression.operatorToken.kind === 62 /* EqualsToken */ ? node.expression.right : undefined; } @@ -10584,18 +11196,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 /* BarBarToken */ + (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return node.initializer; } } @@ -10606,7 +11218,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 248 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10621,11 +11233,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 154 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10636,12 +11248,12 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 279 /* PropertyAssignment */ || + parent.kind === 258 /* ExportAssignment */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 225 /* ExpressionStatement */ && node.kind === 193 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10652,7 +11264,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10675,7 +11287,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10700,7 +11312,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10710,7 +11322,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 === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10723,31 +11335,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 62 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 191 /* ArrayLiteralExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10774,22 +11386,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 222 /* Block */: + case 224 /* VariableStatement */: + case 235 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return true; } return false; @@ -10806,33 +11418,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 181 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 199 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* 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 !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 202 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10854,11 +11466,12 @@ var ts; var parent = name.parent; switch (name.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -10881,8 +11494,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10890,32 +11503,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 193 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 152 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 171 /* TypeQuery */ || parent.kind === 168 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 190 /* BindingElement */: + case 257 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 261 /* ExportSpecifier */: + case 271 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10931,22 +11544,39 @@ var ts; // export = // export default // module.exports = + // {} + // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); + return node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 251 /* NamespaceExportDeclaration */ || + node.kind === 254 /* ImportClause */ && !!node.name || + node.kind === 255 /* NamespaceImport */ || + node.kind === 257 /* ImportSpecifier */ || + node.kind === 261 /* ExportSpecifier */ || + node.kind === 258 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 280 /* ShorthandPropertyAssignment */ || + node.kind === 279 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 279 /* PropertyAssignment */ ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -10960,24 +11590,24 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 112 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -11004,22 +11634,31 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 76 /* FirstKeyword */ <= token && token <= 151 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 121 /* FirstContextualKeyword */ <= token && token <= 151 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 112 /* FirstFutureReservedWord */ <= token && token <= 120 /* LastFutureReservedWord */; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -11043,14 +11682,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11064,10 +11703,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11080,7 +11719,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 /* PlusToken */ || node.operator === 39 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -11100,10 +11739,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 /* ComputedPropertyName */ || name.kind === 194 /* ElementAccessExpression */)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; /** @@ -11117,12 +11759,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11138,7 +11780,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -11149,11 +11791,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 75 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -11168,7 +11810,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 75 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -11177,11 +11819,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 155 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 190 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11189,15 +11831,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 161 /* Constructor */ + || kind === 200 /* FunctionExpression */ + || kind === 243 /* FunctionDeclaration */ + || kind === 201 /* ArrowFunction */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 248 /* ModuleDeclaration */ + || kind === 288 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11216,38 +11858,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operator) { - case 41 /* AsteriskAsteriskToken */: - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 42 /* AsteriskAsteriskToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 1 /* Right */; } } @@ -11256,15 +11898,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 208 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 206 /* PrefixUnaryExpression */ || expression.kind === 207 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11274,73 +11916,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 197 /* TaggedTemplateExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 19; - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 73 /* Identifier */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 75 /* Identifier */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 210 /* TemplateExpression */: + case 199 /* ParenthesizedExpression */: + case 214 /* OmittedExpression */: return 20; default: return -1; @@ -11349,41 +11991,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: + return 4; + case 56 /* BarBarToken */: return 5; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return 6; - case 50 /* BarToken */: + case 51 /* BarToken */: return 7; - case 51 /* CaretToken */: + case 52 /* CaretToken */: return 8; - case 49 /* AmpersandToken */: + case 50 /* AmpersandToken */: return 9; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return 10; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: return 11; - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 38 /* PlusToken */: - case 39 /* MinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: return 13; - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: return 14; - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -11460,6 +12104,10 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -11467,7 +12115,8 @@ var ts; // There is no reason for this other than that JSON.stringify does not handle it either. var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + // Template strings should be preserved as much as possible + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -11496,22 +12145,23 @@ var ts; } ts.escapeString = escapeString; /** - * Strip off existed single quotes or double quotes from a given string + * Strip off existed surrounding single quotes, double quotes, or backticks from a given string * * @return non-quoted string */ function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 /* singleQuote */ || + charCode === 34 /* doubleQuote */ || + charCode === 96 /* backtick */; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0 /* nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); @@ -11562,6 +12212,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -11573,7 +12224,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -11583,17 +12234,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -11607,6 +12270,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -11626,6 +12290,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -11640,12 +12306,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -11653,7 +12319,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -11709,7 +12375,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -11828,6 +12494,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; /** Get the type annotation for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); @@ -11849,11 +12516,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 75 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101 /* ThisKeyword */; + return id.originalKeywordKind === 103 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -11864,10 +12531,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 163 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11887,10 +12554,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 162 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 163 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11936,7 +12603,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 === 297 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12176,7 +12843,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 73 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 75 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -12184,29 +12851,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117 /* StaticKeyword */: return 32 /* Static */; - case 116 /* PublicKeyword */: return 4 /* Public */; - case 115 /* ProtectedKeyword */: return 16 /* Protected */; - case 114 /* PrivateKeyword */: return 8 /* Private */; - case 119 /* AbstractKeyword */: return 128 /* Abstract */; - case 86 /* ExportKeyword */: return 1 /* Export */; - case 126 /* DeclareKeyword */: return 2 /* Ambient */; - case 78 /* ConstKeyword */: return 2048 /* Const */; - case 81 /* DefaultKeyword */: return 512 /* Default */; - case 122 /* AsyncKeyword */: return 256 /* Async */; - case 134 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 119 /* StaticKeyword */: return 32 /* Static */; + case 118 /* PublicKeyword */: return 4 /* Public */; + case 117 /* ProtectedKeyword */: return 16 /* Protected */; + case 116 /* PrivateKeyword */: return 8 /* Private */; + case 121 /* AbstractKeyword */: return 128 /* Abstract */; + case 88 /* ExportKeyword */: return 1 /* Export */; + case 129 /* DeclareKeyword */: return 2 /* Ambient */; + case 80 /* ConstKeyword */: return 2048 /* Const */; + case 83 /* DefaultKeyword */: return 512 /* Default */; + case 125 /* AsyncKeyword */: return 256 /* Async */; + case 137 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 /* BarBarToken */ - || token === 54 /* AmpersandAmpersandToken */ - || token === 52 /* ExclamationToken */; + return token === 56 /* BarBarToken */ + || token === 55 /* AmpersandAmpersandToken */ + || token === 53 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 /* FirstAssignment */ && token <= 72 /* LastAssignment */; + return token >= 62 /* FirstAssignment */ && token <= 74 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -12219,14 +12886,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 /* EqualsToken */ + ? node.operatorToken.kind === 62 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -12234,8 +12901,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 192 /* ObjectLiteralExpression */ + || kind === 191 /* ArrayLiteralExpression */; } return false; } @@ -12245,9 +12912,15 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function isDottedName(node) { + return node.kind === 75 /* Identifier */ || node.kind === 103 /* ThisKeyword */ || + node.kind === 193 /* PropertyAccessExpression */ && isDottedName(node.expression) || + node.kind === 199 /* ParenthesizedExpression */ && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -12263,21 +12936,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 192 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 191 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12575,8 +13248,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12653,35 +13326,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 208 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 279 /* 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 277 /* ShorthandPropertyAssignment */: + case 280 /* 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 188 /* ArrayLiteralExpression */: + case 191 /* 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 === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12727,8 +13400,8 @@ var ts; /** * Mutates the map with newMap such that keys in map will be same as newMap. */ - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; // Needs update map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); @@ -12742,6 +13415,15 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + /** + * Mutates the map with newMap such that keys in map will be same as newMap. + */ + function mutateMap(map, newMap, options) { + // Needs update + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; // Add new values that are not already present newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { @@ -12751,7 +13433,6 @@ var ts; }); } ts.mutateMap = mutateMap; - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -12836,32 +13517,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) - || kind === 121 /* AnyKeyword */ - || kind === 144 /* UnknownKeyword */ - || kind === 136 /* NumberKeyword */ - || kind === 147 /* BigIntKeyword */ - || kind === 137 /* ObjectKeyword */ - || kind === 124 /* BooleanKeyword */ - || kind === 139 /* StringKeyword */ - || kind === 140 /* SymbolKeyword */ - || kind === 101 /* ThisKeyword */ - || kind === 107 /* VoidKeyword */ - || kind === 142 /* UndefinedKeyword */ - || kind === 97 /* NullKeyword */ - || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + return (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) + || kind === 124 /* AnyKeyword */ + || kind === 147 /* UnknownKeyword */ + || kind === 139 /* NumberKeyword */ + || kind === 150 /* BigIntKeyword */ + || kind === 140 /* ObjectKeyword */ + || kind === 127 /* BooleanKeyword */ + || kind === 142 /* StringKeyword */ + || kind === 143 /* SymbolKeyword */ + || kind === 103 /* ThisKeyword */ + || kind === 109 /* VoidKeyword */ + || kind === 145 /* UndefinedKeyword */ + || kind === 99 /* NullKeyword */ + || kind === 136 /* NeverKeyword */ + || kind === 215 /* ExpressionWithTypeArguments */ + || kind === 293 /* JSDocAllType */ + || kind === 294 /* JSDocUnknownType */ + || kind === 295 /* JSDocNullableType */ + || kind === 296 /* JSDocNonNullableType */ + || kind === 297 /* JSDocOptionalType */ + || kind === 298 /* JSDocFunctionType */ + || kind === 299 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */ || node.kind === 194 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -12874,6 +13555,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -12981,7 +13666,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13098,17 +13783,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 154 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245 /* InterfaceDeclaration */) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 161 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13138,14 +13823,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 241 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 242 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 224 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13209,7 +13894,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13291,27 +13977,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: var expr = hostNode.expression; + if (expr.kind === 208 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + expr = expr.left; + } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13323,6 +14012,17 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + /** @internal */ + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -13335,39 +14035,46 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return declaration; - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: { + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 152 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: case 4 /* ThisProperty */: case 5 /* Property */: case 3 /* PrototypeProperty */: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 309 /* JSDocEnumTag */: + return nameForNamelessJSDocTypedef(declaration); + case 258 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194 /* ElementAccessExpression */: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -13390,8 +14097,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -13569,7 +14276,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 301 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13589,10 +14296,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13637,198 +14343,216 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73 /* Identifier */; + return node.kind === 75 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 152 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 153 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 154 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 155 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 157 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 158 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 159 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 161 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 164 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 165 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 166 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 163 /* SetAccessor */ || node.kind === 162 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 167 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 168 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 169 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 170 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 171 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 172 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 173 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 174 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 177 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 178 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 179 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 180 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 181 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 182 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 183 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 184 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 185 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 186 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 187 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 188 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 189 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 190 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 191 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 194 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 195 /* CallExpression */; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + return isPropertyAccessChain(node) + || isElementAccessChain(node) + || isCallChain(node); + } + ts.isOptionalChain = isOptionalChain; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 196 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 197 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 198 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -13837,376 +14561,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 199 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315 /* PartiallyEmittedExpression */) { + while (node.kind === 319 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 200 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 201 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 202 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 203 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 204 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 205 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 206 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 207 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 208 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 209 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 210 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 211 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 212 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 213 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 214 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 216 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 217 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 218 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 220 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 221 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 222 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 224 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 223 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 225 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 226 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 227 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 228 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 229 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 230 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 231 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 232 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 233 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 233 /* BreakStatement */ || node.kind === 232 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 234 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 235 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 236 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 237 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 238 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 239 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 240 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 241 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 242 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 243 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 244 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 245 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 246 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 247 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 248 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 249 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 250 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 251 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 252 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 253 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 254 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 255 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 256 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 257 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 258 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 259 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 260 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 261 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 262 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 264 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 265 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 266 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 267 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 268 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 269 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 270 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 271 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 272 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 273 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 274 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 275 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 276 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 277 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 278 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 279 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 280 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 281 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 288 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 289 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 290 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 284 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return true; default: return false; @@ -14215,105 +14939,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 283 /* UnparsedPrologue */ || + node.kind === 287 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 292 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 293 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 294 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 295 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 296 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 297 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 298 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 299 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297 /* JSDocComment */; + return node.kind === 301 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302 /* JSDocAuthorTag */; + return node.kind === 306 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301 /* JSDocAugmentsTag */; + return node.kind === 305 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303 /* JSDocClassTag */; + return node.kind === 307 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305 /* JSDocEnumTag */; + return node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308 /* JSDocThisTag */; + return node.kind === 312 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307 /* JSDocReturnTag */; + return node.kind === 311 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309 /* JSDocTypeTag */; + return node.kind === 313 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310 /* JSDocTemplateTag */; + return node.kind === 314 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311 /* JSDocTypedefTag */; + return node.kind === 315 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312 /* JSDocPropertyTag */; + return node.kind === 316 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 /* JSDocPropertyTag */ || node.kind === 306 /* JSDocParameterTag */; + return node.kind === 316 /* JSDocPropertyTag */ || node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298 /* JSDocTypeLiteral */; + return node.kind === 302 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 308 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299 /* JSDocSignature */; + return node.kind === 303 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14324,7 +15048,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 313 /* SyntaxList */; + return n.kind === 317 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14334,7 +15058,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 152 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14343,7 +15067,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 <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 151 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14396,17 +15120,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 81 /* DefaultKeyword */: - case 86 /* ExportKeyword */: - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 117 /* StaticKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 83 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 119 /* StaticKeyword */: return true; } return false; @@ -14419,7 +15143,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 119 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -14428,23 +15152,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ + return kind === 75 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 153 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + return kind === 75 /* Identifier */ + || kind === 188 /* ObjectBindingPattern */ + || kind === 189 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14459,13 +15183,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: return false; @@ -14474,14 +15198,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 170 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14496,29 +15220,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 161 /* Constructor */ + || kind === 158 /* PropertyDeclaration */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 166 /* IndexSignature */ + || kind === 221 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; default: return false; @@ -14528,11 +15252,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 165 /* ConstructSignature */ + || kind === 164 /* CallSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */ + || kind === 166 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14541,12 +15265,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 279 /* PropertyAssignment */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 281 /* SpreadAssignment */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14561,8 +15285,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return true; } return false; @@ -14573,8 +15297,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 189 /* ArrayBindingPattern */ + || kind === 188 /* ObjectBindingPattern */; } return false; } @@ -14582,15 +15306,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 191 /* ArrayLiteralExpression */ + || kind === 192 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 190 /* BindingElement */ + || kind === 214 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14599,9 +15323,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: return true; } return false; @@ -14622,8 +15346,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return true; } return false; @@ -14635,8 +15359,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return true; } return false; @@ -14645,26 +15369,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */ + || kind === 187 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 156 /* Decorator */: return true; default: return false; @@ -14672,12 +15396,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 195 /* CallExpression */ || node.kind === 196 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 210 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14688,34 +15412,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 73 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 197 /* TaggedTemplateExpression */: + case 191 /* ArrayLiteralExpression */: + case 199 /* ParenthesizedExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 75 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 103 /* TrueKeyword */: - case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: - case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 210 /* TemplateExpression */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 105 /* TrueKeyword */: + case 101 /* SuperKeyword */: + case 217 /* NonNullExpression */: + case 218 /* MetaProperty */: + case 95 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -14728,13 +15452,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 198 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14743,11 +15467,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 44 /* PlusPlusToken */ || - expr.operator === 45 /* MinusMinusToken */; + case 206 /* PrefixUnaryExpression */: + return expr.operator === 45 /* PlusPlusToken */ || + expr.operator === 46 /* MinusMinusToken */; default: return false; } @@ -14764,15 +15488,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 316 /* CommaListExpression */: - case 315 /* PartiallyEmittedExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: + case 201 /* ArrowFunction */: + case 208 /* BinaryExpression */: + case 212 /* SpreadElement */: + case 216 /* AsExpression */: + case 214 /* OmittedExpression */: + case 320 /* CommaListExpression */: + case 319 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14780,21 +15504,26 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 198 /* TypeAssertionExpression */ + || kind === 216 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 315 /* PartiallyEmittedExpression */; + return node.kind === 319 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 314 /* NotEmittedStatement */; + return node.kind === 318 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ + function isSyntheticReference(node) { + return node.kind === 323 /* SyntheticReferenceExpression */; + } + ts.isSyntheticReference = isSyntheticReference; + /* @internal */ function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -14802,21 +15531,42 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; /* @internal */ + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + /* @internal */ + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + /* @internal */ + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + /* @internal */ + function isExternalModuleIndicator(result) { + // Exported top-level member indicates moduleness + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; + /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 230 /* ForInStatement */ || node.kind === 231 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14840,113 +15590,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ - || kind === 73 /* Identifier */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */ + || kind === 75 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + return kind === 75 /* Identifier */ + || kind === 248 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 256 /* NamedImports */ + || kind === 255 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 248 /* ModuleDeclaration */ || node.kind === 247 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 311 /* JSDocTypedefTag */ - || kind === 304 /* JSDocCallbackTag */ - || kind === 312 /* JSDocPropertyTag */; + return kind === 201 /* ArrowFunction */ + || kind === 190 /* BindingElement */ + || kind === 244 /* ClassDeclaration */ + || kind === 213 /* ClassExpression */ + || kind === 161 /* Constructor */ + || kind === 247 /* EnumDeclaration */ + || kind === 282 /* EnumMember */ + || kind === 261 /* ExportSpecifier */ + || kind === 243 /* FunctionDeclaration */ + || kind === 200 /* FunctionExpression */ + || kind === 162 /* GetAccessor */ + || kind === 254 /* ImportClause */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 257 /* ImportSpecifier */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 271 /* JsxAttribute */ + || kind === 160 /* MethodDeclaration */ + || kind === 159 /* MethodSignature */ + || kind === 248 /* ModuleDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 255 /* NamespaceImport */ + || kind === 155 /* Parameter */ + || kind === 279 /* PropertyAssignment */ + || kind === 158 /* PropertyDeclaration */ + || kind === 157 /* PropertySignature */ + || kind === 163 /* SetAccessor */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 154 /* TypeParameter */ + || kind === 241 /* VariableDeclaration */ + || kind === 315 /* JSDocTypedefTag */ + || kind === 308 /* JSDocCallbackTag */ + || kind === 316 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 243 /* FunctionDeclaration */ + || kind === 262 /* MissingDeclaration */ + || kind === 244 /* ClassDeclaration */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 247 /* EnumDeclaration */ + || kind === 248 /* ModuleDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 258 /* ExportAssignment */ + || kind === 251 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 314 /* NotEmittedStatement */ - || kind === 318 /* EndOfDeclarationMarker */ - || kind === 317 /* MergeDeclarationMarker */; + return kind === 233 /* BreakStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 227 /* DoStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 223 /* EmptyStatement */ + || kind === 230 /* ForInStatement */ + || kind === 231 /* ForOfStatement */ + || kind === 229 /* ForStatement */ + || kind === 226 /* IfStatement */ + || kind === 237 /* LabeledStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 236 /* SwitchStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 239 /* TryStatement */ + || kind === 224 /* VariableStatement */ + || kind === 228 /* WhileStatement */ + || kind === 235 /* WithStatement */ + || kind === 318 /* NotEmittedStatement */ + || kind === 322 /* EndOfDeclarationMarker */ + || kind === 321 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 310 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 154 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 314 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14973,10 +15723,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 222 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 239 /* TryStatement */ || node.parent.kind === 278 /* CatchClause */) { return false; } } @@ -14986,83 +15736,88 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 263 /* ExternalModuleReference */ + || kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 /* ThisKeyword */ - || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + return kind === 103 /* ThisKeyword */ + || kind === 75 /* Identifier */ + || kind === 193 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 264 /* JsxElement */ + || kind === 274 /* JsxExpression */ + || kind === 265 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 268 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 271 /* JsxAttribute */ + || kind === 273 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 274 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 266 /* JsxOpeningElement */ + || kind === 265 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 275 /* CaseClause */ + || kind === 276 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 312 /* LastJSDocNode */; + return node.kind >= 292 /* FirstJSDocNode */ && node.kind <= 316 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 297 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 /* 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 >= 300 /* FirstJSDocTagNode */ && node.kind <= 312 /* LastJSDocTagNode */; + return node.kind >= 304 /* FirstJSDocTagNode */ && node.kind <= 316 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; + /* @internal */ + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; + } + ts.isOptionalChainRoot = isOptionalChainRoot; /** True if has jsdoc nodes attached to it. */ /* @internal */ // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times @@ -15090,12 +15845,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 271 /* JsxAttribute */ || node.kind === 273 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 168 /* TypeReference */ || node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15131,7 +15886,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 256 /* NamedImports */ || node.kind === 260 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15149,7 +15904,7 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature() { } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15166,6 +15921,7 @@ var ts; this.text = text; this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } + // eslint-disable-next-line prefer-const ts.objectAllocator = { getNodeConstructor: function () { return Node; }, getTokenConstructor: function () { return Node; }, @@ -15612,7 +16368,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } /** * Parse a path into an array containing a root component (at index 0) and zero or more path @@ -15690,6 +16446,37 @@ var ts; return ""; return pathComponents.slice(1).join(ts.directorySeparator); } + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); + } + return result; + } + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); + } + return [getPathFromPathComponents(aParts), getPathFromPathComponents(bParts)]; + } + // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. + // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); + } })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -15712,7 +16499,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -15793,7 +16580,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -16232,14 +17019,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; ts.supportedJSAndJsonExtensions = [".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json" /* Json */]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json" /* Json */]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -16253,7 +17040,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json" /* Json */]); + return __spreadArrays(supportedExtensions, [".json" /* Json */]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -16565,14 +17352,17 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { + function skipTypeChecking(sourceFile, options, host) { // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a // '/// ' directive. - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16676,17 +17466,15 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 288 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73 /* Identifier */) { + else if (kind === 75 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -16735,19 +17523,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 <= 148 /* LastToken */) { + if (!node || node.kind <= 151 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16755,9 +17543,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -16765,7 +17553,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16773,51 +17561,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 157 /* 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 276 /* PropertyAssignment */: + case 279 /* 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 238 /* VariableDeclaration */: + case 241 /* 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 187 /* BindingElement */: + case 190 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -16829,345 +17617,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || + case 167 /* TypePredicate */: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 174 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 180 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 187 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 181 /* ParenthesizedType */: + case 183 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 185 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 156 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* 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 242 /* InterfaceDeclaration */: + case 245 /* 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 243 /* TypeAliasDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 292 /* JSDocTypeExpression */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 297 /* JSDocOptionalType */: + case 299 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297 /* JSDocComment */: + case 301 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302 /* JSDocAuthorTag */: + case 306 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 292 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocSignature */: + case 303 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 300 /* JSDocTag */: - case 303 /* JSDocClassTag */: + case 304 /* JSDocTag */: + case 307 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17176,12 +17969,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100 /* JSON */) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -17219,7 +18014,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -17248,14 +18043,12 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; + var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17265,6 +18058,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; // Flags that dictate what parsing context we're in. For example: // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is // that some tokens that would be considered identifiers may be considered keywords. @@ -17385,18 +18179,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(225 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 39 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -17405,7 +18199,7 @@ var ts; break; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -17421,6 +18215,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17446,10 +18243,10 @@ var ts; switch (scriptKind) { case 1 /* JS */: case 2 /* JSX */: - contextFlags = 65536 /* JavaScriptFile */; + contextFlags = 131072 /* JavaScriptFile */; break; case 6 /* JSON */: - contextFlags = 65536 /* JavaScriptFile */ | 16777216 /* JsonFile */; + contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */; break; default: contextFlags = 0 /* None */; @@ -17472,11 +18269,12 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304 /* Ambient */; + contextFlags |= 8388608 /* Ambient */; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -17541,7 +18339,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(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(288 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17562,16 +18360,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048 /* DisallowInContext */); + setContextFlag(val, 4096 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 4096 /* YieldContext */); + setContextFlag(val, 8192 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 8192 /* DecoratorContext */); + setContextFlag(val, 16384 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 16384 /* AwaitContext */); + setContextFlag(val, 32768 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -17612,40 +18410,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(2048 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(4096 /* YieldContext */, func); + return doInsideOfContext(8192 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384 /* AwaitContext */, func); + return doInsideOfContext(32768 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); + return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096 /* YieldContext */); + return inContext(8192 /* YieldContext */); } function inDisallowInContext() { - return inContext(2048 /* DisallowInContext */); + return inContext(4096 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(8192 /* DecoratorContext */); + return inContext(16384 /* DecoratorContext */); } function inAwaitContext() { - return inContext(16384 /* AwaitContext */); + return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -17681,9 +18479,17 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + // if the keyword had an escape + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + // issue a parse error for the escape + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -17752,20 +18558,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 73 /* Identifier */) { + if (token() === 75 /* 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() === 118 /* YieldKeyword */ && inYieldContext()) { + if (token() === 120 /* 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() === 123 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 126 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 109 /* LastReservedWord */; + return token() > 111 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -17853,7 +18659,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 73 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 75 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -17883,7 +18689,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768 /* ThisNodeHasError */; + node.flags |= 65536 /* ThisNodeHasError */; } return node; } @@ -17895,7 +18701,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73 /* Identifier */) { + if (kind === 75 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -17916,18 +18722,18 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73 /* Identifier */); + var node = createNode(75 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 73 /* Identifier */) { + if (token() !== 75 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(73 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -17958,7 +18764,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(153 /* 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 @@ -17979,20 +18785,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 85 /* EnumKeyword */; - case 86 /* ExportKeyword */: + return nextToken() === 87 /* EnumKeyword */; + case 88 /* ExportKeyword */: nextToken(); - if (token() === 81 /* DefaultKeyword */) { + if (token() === 83 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 /* AsteriskToken */ && token() !== 120 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); - case 81 /* DefaultKeyword */: + return token() !== 41 /* AsteriskToken */ && token() !== 122 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 83 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 117 /* StaticKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + case 119 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -18005,16 +18811,16 @@ var ts; function canFollowModifier() { return token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */ - || token() === 40 /* AsteriskToken */ + || token() === 41 /* AsteriskToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 /* ClassKeyword */ || token() === 91 /* FunctionKeyword */ || - token() === 111 /* InterfaceKeyword */ || - (token() === 119 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 /* ClassKeyword */ || token() === 93 /* FunctionKeyword */ || + token() === 113 /* InterfaceKeyword */ || + (token() === 121 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -18034,7 +18840,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -18050,7 +18856,7 @@ var ts; case 12 /* ObjectLiteralMembers */: switch (token()) { case 22 /* OpenBracketToken */: - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; @@ -18120,7 +18926,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 87 /* ExtendsKeyword */ || next === 110 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 89 /* ExtendsKeyword */ || next === 112 /* ImplementsKeyword */; } return true; } @@ -18137,8 +18943,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 /* ImplementsKeyword */ || - token() === 87 /* ExtendsKeyword */) { + if (token() === 112 /* ImplementsKeyword */ || + token() === 89 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -18168,14 +18974,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -18194,9 +19000,9 @@ var ts; case 22 /* HeritageClauses */: return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; + return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -18216,7 +19022,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() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -18291,7 +19097,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 12679168 /* ContextFlags */; + var nodeContextFlags = node.flags & 25358336 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -18392,20 +19198,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 161 /* Constructor */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 221 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 160 /* 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 === 73 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 125 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 75 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 128 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -18414,8 +19220,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: return true; } } @@ -18424,58 +19230,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 224 /* VariableStatement */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 225 /* ExpressionStatement */: + case 238 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 236 /* SwitchStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 223 /* EmptyStatement */: + case 239 /* TryStatement */: + case 237 /* LabeledStatement */: + case 227 /* DoStatement */: + case 240 /* DebuggerStatement */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 157 /* PropertySignature */: + case 164 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 241 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18496,7 +19302,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 155 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18563,7 +19369,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18601,6 +19407,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18621,7 +19430,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24 /* DotToken */)) { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -18632,7 +19441,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(152 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18663,13 +19472,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(210 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18681,7 +19490,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(220 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -18710,6 +19519,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -18731,24 +19550,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 169 /* FunctionType */: + case 170 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -18756,20 +19575,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(167 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(182 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(293 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(297 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18777,7 +19596,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(296 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18798,63 +19617,80 @@ var ts; if (token() === 27 /* CommaToken */ || token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || - token() === 30 /* GreaterThanToken */ || - token() === 60 /* EqualsToken */ || - token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + token() === 31 /* GreaterThanToken */ || + token() === 62 /* EqualsToken */ || + token() === 51 /* BarToken */) { + var result = createNode(294 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(295 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(298 /* JSDocFunctionType */); nextToken(); - fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(58 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { + var parameter = createNode(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */ || token() === 98 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(134 /* ModuleKeyword */); + if (moduleSpecifier) { + var moduleTag = createNode(300 /* JSDocNamepathType */, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + case 27 /* CommaToken */: + case 5 /* WhitespaceTrivia */: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(299 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + if (token() === 62 /* EqualsToken */) { + return createPostfixType(297 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); - parseExpected(105 /* TypeOfKeyword */); + var node = createNode(171 /* TypeQuery */); + parseExpected(107 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(87 /* ExtendsKeyword */)) { + if (parseOptional(89 /* 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 @@ -18873,18 +19709,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60 /* EqualsToken */)) { + if (parseOptional(62 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (token() === 29 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(57 /* ColonToken */)) { + if (parseOptional(58 /* ColonToken */)) { return parseType(); } return undefined; @@ -18893,12 +19729,12 @@ var ts; return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 /* AtToken */ || + token() === 59 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */) { + var node = createNodeWithJSDoc(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); @@ -18920,7 +19756,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.questionToken = parseOptionalToken(57 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -18942,16 +19778,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(57 /* ColonToken */)) { + else if (parseOptional(58 /* ColonToken */)) { return true; } - else if (isType && token() === 37 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); nextToken(); return true; } @@ -18998,10 +19834,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { - parseExpected(96 /* NewKeyword */); + if (kind === 165 /* ConstructSignature */) { + parseExpected(98 /* NewKeyword */); } - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -19045,21 +19881,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* 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() !== 56 /* QuestionToken */) { + if (token() !== 57 /* 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() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 166 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19067,17 +19903,17 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + node.kind = 159 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 157 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* 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. @@ -19089,7 +19925,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return true; } var idToken = false; @@ -19111,20 +19947,20 @@ var ts; // the start of a member declaration if (idToken) { return token() === 20 /* OpenParenToken */ || - token() === 28 /* LessThanToken */ || - token() === 56 /* QuestionToken */ || - token() === 57 /* ColonToken */ || + token() === 29 /* LessThanToken */ || + token() === 57 /* QuestionToken */ || + token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + return parseSignatureMember(164 /* CallSignature */); } - if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + if (token() === 98 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19135,7 +19971,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; } function nextTokenIsDot() { return nextToken() === 24 /* DotToken */; @@ -19143,14 +19979,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20 /* OpenParenToken */: - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(172 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19167,37 +20003,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { - return nextToken() === 134 /* ReadonlyKeyword */; + if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + return nextToken() === 137 /* ReadonlyKeyword */; } - if (token() === 134 /* ReadonlyKeyword */) { + if (token() === 137 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 96 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(94 /* InKeyword */); + parseExpected(96 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(185 /* MappedType */); parseExpected(18 /* OpenBraceToken */); - if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 137 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { - parseExpectedToken(134 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { + parseExpectedToken(137 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); parseExpected(23 /* CloseBracketToken */); - if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56 /* QuestionToken */) { - parseExpectedToken(56 /* QuestionToken */); + if (node.questionToken.kind !== 57 /* QuestionToken */) { + parseExpectedToken(57 /* QuestionToken */); } } node.type = parseTypeAnnotation(); @@ -19208,23 +20044,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(176 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 4194304 /* JSDoc */) && type.kind === 295 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 175 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(174 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(181 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19232,9 +20068,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(98 /* NewKeyword */) ? 170 /* ConstructorType */ : 169 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(38 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -19242,14 +20078,14 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(186 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 39 /* MinusToken */; + unaryMinusExpression = createNode(206 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 40 /* MinusToken */; nextToken(); } - var expression = token() === 103 /* TrueKeyword */ || token() === 88 /* FalseKeyword */ + var expression = token() === 105 /* TrueKeyword */ || token() === 90 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -19262,23 +20098,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93 /* ImportKeyword */; + return token() === 95 /* ImportKeyword */; } function parseImportType() { - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); - if (parseOptional(105 /* TypeOfKeyword */)) { + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; + var node = createNode(187 /* ImportType */); + if (parseOptional(107 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); node.argument = parseType(); parseExpected(21 /* CloseParenToken */); if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } @@ -19288,50 +20124,54 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 140 /* SymbolKeyword */: - case 124 /* BooleanKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 143 /* SymbolKeyword */: + case 127 /* BooleanKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 63 /* AsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 56 /* QuestionToken */: + case 60 /* QuestionQuestionToken */: + // If there is '??', consider that is prefix '?' in JSDoc type. + scanner.reScanQuestionToken(); + // falls through + case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseLiteralTypeNode(); - case 39 /* MinusToken */: + case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 107 /* VoidKeyword */: - case 97 /* NullKeyword */: + case 109 /* VoidKeyword */: + case 99 /* NullKeyword */: return parseTokenNode(); - case 101 /* ThisKeyword */: { + case 103 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -19339,51 +20179,54 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportType(); + case 123 /* AssertsKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 134 /* ReadonlyKeyword */: - case 140 /* SymbolKeyword */: - case 143 /* UniqueKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 105 /* TypeOfKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 137 /* ReadonlyKeyword */: + case 143 /* SymbolKeyword */: + case 146 /* UniqueKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 107 /* TypeOfKeyword */: + case 136 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: - case 28 /* LessThanToken */: - case 50 /* BarToken */: - case 49 /* AmpersandToken */: - case 96 /* NewKeyword */: + case 29 /* LessThanToken */: + case 51 /* BarToken */: + case 50 /* AmpersandToken */: + case 98 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 137 /* ObjectKeyword */: - case 40 /* AsteriskToken */: - case 56 /* QuestionToken */: - case 52 /* ExclamationToken */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 140 /* ObjectKeyword */: + case 41 /* AsteriskToken */: + case 57 /* QuestionToken */: + case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 128 /* InferKeyword */: - case 93 /* ImportKeyword */: + case 131 /* InferKeyword */: + case 95 /* ImportKeyword */: + case 123 /* AssertsKeyword */: return true; - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return !inStartOfParameter; - case 39 /* MinusToken */: + case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -19401,27 +20244,27 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + case 53 /* ExclamationToken */: + type = createPostfixType(296 /* JSDocNonNullableType */, type); break; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type - if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { + if (!(contextFlags & 4194304 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(295 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(184 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(173 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19440,16 +20283,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(183 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); - parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var node = createNode(180 /* InferType */); + parseExpected(131 /* InferKeyword */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19457,11 +20300,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130 /* KeyOfKeyword */: - case 143 /* UniqueKeyword */: - case 134 /* ReadonlyKeyword */: + case 133 /* KeyOfKeyword */: + case 146 /* UniqueKeyword */: + case 137 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 128 /* InferKeyword */: + case 131 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -19482,13 +20325,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(178 /* IntersectionType */, parseTypeOperatorOrHigher, 50 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(177 /* UnionType */, parseIntersectionTypeOrHigher, 51 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { return true; } return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -19498,7 +20341,7 @@ var ts; // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 101 /* ThisKeyword */) { + if (isIdentifier() || token() === 103 /* ThisKeyword */) { nextToken(); return true; } @@ -19520,8 +20363,8 @@ 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() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 56 /* QuestionToken */ || token() === 60 /* EqualsToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 57 /* QuestionToken */ || token() === 62 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -19530,7 +20373,7 @@ var ts; } if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -19542,7 +20385,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(167 /* TypePredicate */, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19553,45 +20397,52 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167 /* TypePredicate */); + node.assertsModifier = parseExpectedToken(123 /* AssertsKeyword */); + node.parameterName = token() === 103 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132 /* IsKeyword */) ? parseType() : undefined; + return finishNode(node); + } function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 98 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89 /* ExtendsKeyword */)) { + var node = createNode(179 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(56 /* QuestionToken */); + parseExpected(57 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -19600,14 +20451,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 96 /* NewKeyword */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 73 /* Identifier */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 98 /* NewKeyword */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 75 /* Identifier */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -19618,18 +20469,18 @@ var ts; return true; } switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 28 /* LessThanToken */: - case 123 /* AwaitKeyword */: - case 118 /* YieldKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 29 /* LessThanToken */: + case 126 /* AwaitKeyword */: + case 120 /* 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. @@ -19648,9 +20499,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && - token() !== 58 /* AtToken */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && + token() !== 59 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -19673,7 +20524,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -19718,7 +20569,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 === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -19734,7 +20585,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118 /* YieldKeyword */) { + if (token() === 120 /* 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()) { @@ -19763,15 +20614,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(211 /* 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() === 40 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19782,20 +20633,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(201 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(201 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(155 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -19820,8 +20671,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(37 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -19831,10 +20682,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() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 122 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 125 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* 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. @@ -19844,12 +20695,12 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { return 0 /* False */; } } @@ -19863,8 +20714,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 37 /* EqualsGreaterThanToken */: - case 57 /* ColonToken */: + case 38 /* EqualsGreaterThanToken */: + case 58 /* ColonToken */: case 18 /* OpenBraceToken */: return 1 /* True */; default: @@ -19888,30 +20739,30 @@ var ts; // 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 !== 122 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 /* 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 !== 101 /* ThisKeyword */) { + if (!isIdentifier() && second !== 103 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 57 /* ColonToken */: + case 58 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 60 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -19920,7 +20771,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 28 /* LessThanToken */); + ts.Debug.assert(first === 29 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -19930,11 +20781,11 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87 /* ExtendsKeyword */) { + if (third === 89 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 60 /* EqualsToken */: - case 30 /* GreaterThanToken */: + case 62 /* EqualsToken */: + case 31 /* GreaterThanToken */: return false; default: return true; @@ -19955,11 +20806,19 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -19972,23 +20831,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() === 122 /* AsyncKeyword */) { + if (token() === 125 /* 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() === 37 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(201 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -19998,7 +20857,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -20011,7 +20870,7 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -20022,8 +20881,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -20048,20 +20907,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(56 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* 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(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(209 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57 /* ColonToken */); + node.colonToken = parseExpectedToken(58 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + : createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -20069,7 +20928,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 96 /* InKeyword */ || t === 151 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20098,16 +20957,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() === 41 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 /* InKeyword */ && inDisallowInContext()) { + if (token() === 96 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -20128,51 +20987,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94 /* InKeyword */) { + if (inDisallowInContext() && token() === 96 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(208 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(216 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(202 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(203 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(204 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123 /* AwaitKeyword */) { + if (token() === 126 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -20182,7 +21041,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(205 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20206,7 +21065,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 /* AsteriskAsteriskToken */ ? + return token() === 42 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -20223,10 +21082,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41 /* AsteriskAsteriskToken */) { + if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 198 /* 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 { @@ -20251,23 +21110,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 82 /* DeleteKeyword */: + case 84 /* DeleteKeyword */: return parseDeleteExpression(); - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return parseVoidExpression(); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 123 /* AwaitKeyword */: + case 126 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -20290,16 +21149,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 123 /* AwaitKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 126 /* AwaitKeyword */: return false; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -20322,21 +21181,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20377,14 +21236,14 @@ 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() === 93 /* ImportKeyword */) { + if (token() === 95 /* ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { @@ -20392,21 +21251,22 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); - node.keywordToken = 93 /* ImportKeyword */; + var node = createNode(218 /* MetaProperty */, fullStart); + node.keywordToken = 95 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; + sourceFile.flags |= 2097152 /* PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 /* 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. + // CallExpression or OptionalExpression. As such, we need to consume the rest + // of it here to be complete. return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { @@ -20458,11 +21318,11 @@ var ts; // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -20474,7 +21334,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(193 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20483,8 +21343,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 266 /* JsxOpeningElement */) { + var node = createNode(264 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20493,15 +21353,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 269 /* JsxOpeningFragment */) { + var node = createNode(268 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 265 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20512,11 +21372,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 28 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(208 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20546,7 +21406,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29 /* LessThanSlashToken */: + case 30 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; case 11 /* JsxText */: @@ -20554,7 +21414,7 @@ var ts; return parseJsxText(); case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -20575,16 +21435,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(272 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28 /* LessThanToken */); - if (token() === 30 /* GreaterThanToken */) { + parseExpected(29 /* LessThanToken */); + if (token() === 31 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(269 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20592,23 +21452,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30 /* GreaterThanToken */) { + if (token() === 31 /* 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(263 /* JsxOpeningElement */, fullStart); + node = createNode(266 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(42 /* SlashToken */); + parseExpected(43 /* SlashToken */); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(265 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20622,10 +21482,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() === 101 /* ThisKeyword */ ? + var expression = token() === 103 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20633,7 +21493,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(274 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -20659,9 +21519,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(271 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -20674,7 +21534,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(273 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -20682,78 +21542,110 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(267 /* JsxClosingElement */); + parseExpected(30 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(270 /* JsxClosingFragment */); + parseExpected(30 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); - parseExpected(28 /* LessThanToken */); + var node = createNode(198 /* TypeAssertionExpression */); + parseExpected(29 /* LessThanToken */); node.type = parseType(); - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 /* OpenBracketToken */ + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 /* QuestionDotToken */ + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + propertyAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23 /* CloseBracketToken */); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + indexedAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24 /* DotToken */); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(217 /* 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(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - if (token() === 23 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23 /* CloseBracketToken */); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, /*typeArguments*/ undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, /*typeArguments*/ undefined); continue; } return expression; @@ -20762,48 +21654,70 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32 /* OptionalChain */) { + tagExpression.flags |= 32 /* OptionalChain */; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); + var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); // handle 'foo<()' - if (token() === 28 /* LessThanToken */ || token() === 46 /* LessThanLessThanToken */) { + if (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the // stack. var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(195 /* CallExpression */, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + // We failed to parse anything, so report a missing identifier here. + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32 /* OptionalChain */; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20 /* OpenParenToken */); @@ -20812,12 +21726,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* LessThanToken */) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(30 /* GreaterThanToken */)) { + if (!parseExpected(31 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -20834,21 +21748,23 @@ var ts; 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. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] - case 57 /* ColonToken */: // foo: + case 58 /* 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 57 /* QuestionToken */: // foo? + case 34 /* EqualsEqualsToken */: // foo == + case 36 /* EqualsEqualsEqualsToken */: // foo === + case 35 /* ExclamationEqualsToken */: // foo != + case 37 /* ExclamationEqualsEqualsToken */: // foo !== + case 55 /* AmpersandAmpersandToken */: // foo && + case 56 /* BarBarToken */: // foo || + case 60 /* QuestionQuestionToken */: // foo ?? + case 52 /* CaretToken */: // foo ^ + case 50 /* AmpersandToken */: // foo & + case 51 /* 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 @@ -20860,6 +21776,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -20872,11 +21789,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -20884,7 +21801,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 122 /* AsyncKeyword */: + case 125 /* 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. @@ -20892,14 +21809,14 @@ var ts; break; } return parseFunctionExpression(); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassExpression(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionExpression(); - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -20910,28 +21827,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(199 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(212 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(214 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(191 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -20943,25 +21860,25 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 281 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(53 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -20969,24 +21886,24 @@ 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() !== 57 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(60 /* EqualsToken */); + node.kind = 280 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(62 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276 /* PropertyAssignment */; - parseExpected(57 /* ColonToken */); + node.kind = 279 /* PropertyAssignment */; + parseExpected(58 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(192 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21005,10 +21922,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(200 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -21016,7 +21933,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -21028,26 +21945,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96 /* NewKeyword */); + parseExpected(98 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); - node_2.keywordToken = 96 /* NewKeyword */; + var node_2 = createNode(218 /* MetaProperty */, fullStart); + node_2.keywordToken = 98 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, /*optionalChain*/ undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(196 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21057,7 +21974,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(222 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21090,25 +22007,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(223 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); - parseExpected(92 /* IfKeyword */); + var node = createNode(226 /* IfStatement */); + parseExpected(94 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); - parseExpected(83 /* DoKeyword */); + var node = createNode(227 /* DoStatement */); + parseExpected(85 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(108 /* WhileKeyword */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21120,8 +22037,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); - parseExpected(108 /* WhileKeyword */); + var node = createNode(228 /* WhileStatement */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21130,12 +22047,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90 /* ForKeyword */); - var awaitToken = parseOptionalToken(123 /* AwaitKeyword */); + parseExpected(92 /* ForKeyword */); + var awaitToken = parseOptionalToken(126 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 106 /* VarKeyword */ || token() === 112 /* LetKeyword */ || token() === 78 /* ConstKeyword */) { + if (token() === 108 /* VarKeyword */ || token() === 114 /* LetKeyword */ || token() === 80 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -21143,23 +22060,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(151 /* OfKeyword */) : parseOptional(151 /* OfKeyword */)) { + var forOfStatement = createNode(231 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + else if (parseOptional(96 /* InKeyword */)) { + var forInStatement = createNode(230 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(229 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21177,7 +22094,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 233 /* BreakStatement */ ? 76 /* BreakKeyword */ : 81 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21185,8 +22102,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); - parseExpected(98 /* ReturnKeyword */); + var node = createNode(234 /* ReturnStatement */); + parseExpected(100 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -21194,39 +22111,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); - parseExpected(109 /* WithKeyword */); + var node = createNode(235 /* WithStatement */); + parseExpected(111 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); + node.statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); - parseExpected(75 /* CaseKeyword */); + var node = createNode(275 /* CaseClause */); + parseExpected(77 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); - parseExpected(81 /* DefaultKeyword */); - parseExpected(57 /* ColonToken */); + var node = createNode(276 /* DefaultClause */); + parseExpected(83 /* DefaultKeyword */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 77 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); - parseExpected(100 /* SwitchKeyword */); + var node = createNode(236 /* SwitchStatement */); + parseExpected(102 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(250 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21241,29 +22158,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); - parseExpected(102 /* ThrowKeyword */); + var node = createNode(238 /* ThrowStatement */); + parseExpected(104 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); - parseExpected(104 /* TryKeyword */); + var node = createNode(239 /* TryStatement */); + parseExpected(106 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 78 /* 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() === 89 /* FinallyKeyword */) { - parseExpected(89 /* FinallyKeyword */); + if (!node.catchClause || token() === 91 /* FinallyKeyword */) { + parseExpected(91 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); - parseExpected(76 /* CatchKeyword */); + var result = createNode(278 /* CatchClause */); + parseExpected(78 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21 /* CloseParenToken */); @@ -21276,8 +22193,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); - parseExpected(80 /* DebuggerKeyword */); + var node = createNode(240 /* DebuggerStatement */); + parseExpected(82 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -21287,13 +22204,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + if (expression.kind === 75 /* Identifier */ && parseOptional(58 /* ColonToken */)) { + node.kind = 237 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 225 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21305,11 +22222,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 79 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 93 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -21318,12 +22235,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* 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 @@ -21346,41 +22263,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146 /* GlobalKeyword */: + case 149 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 73 /* Identifier */ || token() === 86 /* ExportKeyword */; - case 93 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 75 /* Identifier */ || token() === 88 /* ExportKeyword */; + case 95 /* ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); - if (token() === 60 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || token() === 81 /* DefaultKeyword */ || - token() === 120 /* AsKeyword */) { + if (token() === 62 /* EqualsToken */ || token() === 41 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 83 /* DefaultKeyword */ || + token() === 122 /* AsKeyword */) { return true; } continue; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: nextToken(); continue; default: @@ -21393,50 +22310,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 92 /* IfKeyword */: - case 83 /* DoKeyword */: - case 108 /* WhileKeyword */: - case 90 /* ForKeyword */: - case 79 /* ContinueKeyword */: - case 74 /* BreakKeyword */: - case 98 /* ReturnKeyword */: - case 109 /* WithKeyword */: - case 100 /* SwitchKeyword */: - case 102 /* ThrowKeyword */: - case 104 /* TryKeyword */: - case 80 /* DebuggerKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 94 /* IfKeyword */: + case 85 /* DoKeyword */: + case 110 /* WhileKeyword */: + case 92 /* ForKeyword */: + case 81 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 100 /* ReturnKeyword */: + case 111 /* WithKeyword */: + case 102 /* SwitchKeyword */: + case 104 /* ThrowKeyword */: + case 106 /* TryKeyword */: + case 82 /* 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 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78 /* ConstKeyword */: - case 86 /* ExportKeyword */: + case 80 /* ConstKeyword */: + case 88 /* ExportKeyword */: return isStartOfDeclaration(); - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 111 /* InterfaceKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 141 /* TypeKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 113 /* InterfaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 144 /* TypeKeyword */: + case 149 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 119 /* StaticKeyword */: + case 137 /* 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); @@ -21459,63 +22377,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); - case 112 /* LetKeyword */: + case 108 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); + case 114 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); } break; - case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); - case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); - case 92 /* IfKeyword */: + case 93 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(243 /* FunctionDeclaration */)); + case 79 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(244 /* ClassDeclaration */)); + case 94 /* IfKeyword */: return parseIfStatement(); - case 83 /* DoKeyword */: + case 85 /* DoKeyword */: return parseDoStatement(); - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return parseWhileStatement(); - case 90 /* ForKeyword */: + case 92 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); - case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); - case 98 /* ReturnKeyword */: + case 81 /* ContinueKeyword */: + return parseBreakOrContinueStatement(232 /* ContinueStatement */); + case 76 /* BreakKeyword */: + return parseBreakOrContinueStatement(233 /* BreakStatement */); + case 100 /* ReturnKeyword */: return parseReturnStatement(); - case 109 /* WithKeyword */: + case 111 /* WithKeyword */: return parseWithStatement(); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return parseSwitchStatement(); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return parseThrowStatement(); - case 104 /* TryKeyword */: + case 106 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return parseTryStatement(); - case 80 /* DebuggerKeyword */: + case 82 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 58 /* AtToken */: + case 59 /* AtToken */: return parseDeclaration(); - case 122 /* AsyncKeyword */: - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 85 /* EnumKeyword */: - case 86 /* ExportKeyword */: - case 93 /* ImportKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 119 /* AbstractKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 87 /* EnumKeyword */: + case 88 /* ExportKeyword */: + case 95 /* ImportKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 121 /* AbstractKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: + case 149 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -21524,52 +22443,71 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126 /* DeclareKeyword */; + return modifier.kind === 129 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304 /* Ambient */; + m.flags |= 8388608 /* Ambient */; } - return doInsideOfContext(4194304 /* Ambient */, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: return parseVariableStatement(node); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassDeclaration(node); - case 111 /* InterfaceKeyword */: + case 113 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 141 /* TypeKeyword */: + case 144 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 85 /* EnumKeyword */: + case 87 /* EnumKeyword */: return parseEnumDeclaration(node); - case 146 /* GlobalKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 149 /* GlobalKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); switch (token()) { - case 81 /* DefaultKeyword */: - case 60 /* EqualsToken */: + case 83 /* DefaultKeyword */: + case 62 /* EqualsToken */: return parseExportAssignment(node); - case 120 /* AsKeyword */: + case 122 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -21578,7 +22516,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(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21601,24 +22539,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(214 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -21626,14 +22564,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(188 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(189 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -21655,10 +22593,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(241 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 /* Identifier */ && - token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 /* Identifier */ && + token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -21668,14 +22606,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(242 /* VariableDeclarationList */); switch (token()) { - case 106 /* VarKeyword */: + case 108 /* VarKeyword */: break; - case 112 /* LetKeyword */: + case 114 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -21691,7 +22629,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() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -21706,25 +22644,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 224 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + node.kind = 243 /* FunctionDeclaration */; + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* 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(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125 /* ConstructorKeyword */) { - return parseExpected(125 /* ConstructorKeyword */); + if (token() === 128 /* ConstructorKeyword */) { + return parseExpected(128 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -21736,25 +22674,25 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; - fillSignature(57 /* ColonToken */, 0 /* None */, node); + node.kind = 161 /* Constructor */; + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 160 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; - if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 158 /* PropertyDeclaration */; + if (!node.questionToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -21769,17 +22707,17 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. node.initializer = ts.hasModifier(node, 32 /* Static */) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseInitializer); + : doOutsideOfContext(8192 /* YieldContext */ | 4096 /* DisallowInContext */, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* 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(56 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -21787,13 +22725,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57 /* ColonToken */, 0 /* None */, node); + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58 /* AtToken */) { + if (token() === 59 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -21810,7 +22748,7 @@ var ts; } nextToken(); } - if (token() === 40 /* AsteriskToken */) { + if (token() === 41 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -21826,18 +22764,18 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 138 /* SetKeyword */ || idToken === 127 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 141 /* SetKeyword */ || idToken === 130 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { case 20 /* OpenParenToken */: // Method declaration - case 28 /* LessThanToken */: // Generic Method declaration - case 52 /* ExclamationToken */: // Non-null assertion on property name - case 57 /* ColonToken */: // Type Annotation for declaration - case 60 /* EqualsToken */: // Initializer for declaration - case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 29 /* LessThanToken */: // Generic Method declaration + case 53 /* ExclamationToken */: // Non-null assertion on property name + case 58 /* ColonToken */: // Type Annotation for declaration + case 62 /* EqualsToken */: // Initializer for declaration + case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -21855,10 +22793,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58 /* AtToken */)) { + if (!parseOptional(59 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(156 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -21878,7 +22816,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 80 /* 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)) { @@ -21897,7 +22835,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -21908,20 +22846,20 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(221 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 128 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -21935,27 +22873,37 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 40 /* AsteriskToken */ || + token() === 41 /* AsteriskToken */ || token() === 22 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608 /* Ambient */; + } + return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75 /* 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 */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 213 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 244 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77 /* ClassKeyword */); + parseExpected(79 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -21981,7 +22929,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -21993,33 +22941,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + ts.Debug.assert(tok === 89 /* ExtendsKeyword */ || tok === 112 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(277 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 29 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; - parseExpected(111 /* InterfaceKeyword */); + node.kind = 245 /* InterfaceDeclaration */; + parseExpected(113 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22027,11 +22974,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; - parseExpected(141 /* TypeKeyword */); + node.kind = 246 /* TypeAliasDeclaration */; + parseExpected(144 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -22041,14 +22988,14 @@ 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(279 /* EnumMember */); + var node = createNodeWithJSDoc(282 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; - parseExpected(85 /* EnumKeyword */); + node.kind = 247 /* EnumDeclaration */; + parseExpected(87 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -22060,7 +23007,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(249 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22071,7 +23018,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 248 /* 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 */; @@ -22083,11 +23030,11 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; - if (token() === 146 /* GlobalKeyword */) { + node.kind = 248 /* ModuleDeclaration */; + if (token() === 149 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 512 /* GlobalAugmentation */; + node.flags |= 1024 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(); @@ -22103,15 +23050,15 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146 /* GlobalKeyword */) { + if (token() === 149 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132 /* NamespaceKeyword */)) { + else if (parseOptional(135 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(131 /* ModuleKeyword */); + parseExpected(134 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } @@ -22119,52 +23066,52 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 /* RequireKeyword */ && + return token() === 138 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 42 /* SlashToken */; + return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; - parseExpected(120 /* AsKeyword */); - parseExpected(132 /* NamespaceKeyword */); + node.kind = 251 /* NamespaceExportDeclaration */; + parseExpected(122 /* AsKeyword */); + parseExpected(135 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 /* CommaToken */ && token() !== 145 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 148 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 253 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 40 /* AsteriskToken */ || // import * + token() === 41 /* AsteriskToken */ || // import * token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145 /* FromKeyword */); + parseExpected(148 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 252 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -22176,7 +23123,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(254 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22186,7 +23133,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(256 /* NamedImports */); } return finishNode(importClause); } @@ -22196,8 +23143,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); - parseExpected(135 /* RequireKeyword */); + var node = createNode(263 /* ExternalModuleReference */); + parseExpected(138 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -22219,9 +23166,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); - parseExpected(40 /* AsteriskToken */); - parseExpected(120 /* AsKeyword */); + var namespaceImport = createNode(255 /* NamespaceImport */); + parseExpected(41 /* AsteriskToken */); + parseExpected(122 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -22234,14 +23181,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 256 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(261 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(257 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22255,9 +23202,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(120 /* AsKeyword */); + parseExpected(122 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -22266,24 +23213,24 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 257 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; - if (parseOptional(40 /* AsteriskToken */)) { - parseExpected(145 /* FromKeyword */); + node.kind = 259 /* ExportDeclaration */; + if (parseOptional(41 /* AsteriskToken */)) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(260 /* 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() === 145 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(145 /* FromKeyword */); + if (token() === 148 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -22291,12 +23238,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; - if (parseOptional(60 /* EqualsToken */)) { + node.kind = 258 /* ExportAssignment */; + if (parseOptional(62 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(81 /* DefaultKeyword */); + parseExpected(83 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -22311,15 +23258,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */ + || node.kind === 253 /* ImportDeclaration */ + || node.kind === 258 /* ExportAssignment */ + || node.kind === 259 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -22327,7 +23272,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -22378,9 +23323,9 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(292 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); + result.type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -22390,8 +23335,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = parseJSDocCommentWorker(start, length); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22402,11 +23347,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536 /* JavaScriptFile */) { + if (contextFlags & 131072 /* JavaScriptFile */) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -22471,7 +23416,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -22490,7 +23435,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 40 /* AsteriskToken */: + case 41 /* 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 @@ -22541,7 +23486,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297 /* JSDocComment */, start); + var result = createNode(301 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22577,14 +23522,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { indentText += scanner.getTokenText(); if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40 /* AsteriskToken */) { + else if (token() === 41 /* AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -22592,7 +23537,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -22676,7 +23621,7 @@ var ts; } indent = 0; break; - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 3 /* SavingBackticks */) { comments.push(scanner.getTokenText()); break; @@ -22701,7 +23646,7 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -22709,7 +23654,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59 /* BacktickToken */: + case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { state = 2 /* SavingComments */; } @@ -22718,7 +23663,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -22741,7 +23686,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300 /* JSDocTag */, start); + var result = createNode(304 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22769,15 +23714,15 @@ var ts; skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(59 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(60 /* EqualsToken */)) { + if (parseOptionalToken(62 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -22786,9 +23731,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -22804,8 +23749,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(312 /* JSDocPropertyTag */, start) : - createNode(306 /* JSDocParameterTag */, start); + createNode(316 /* JSDocPropertyTag */, start) : + createNode(310 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22822,20 +23767,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) { + if (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -22847,7 +23792,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307 /* JSDocReturnTag */, start); + var result = createNode(311 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -22856,13 +23801,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309 /* JSDocTypeTag */, start); + var result = createNode(313 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302 /* JSDocAuthorTag */, start); + var result = createNode(306 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -22884,20 +23829,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 5 /* WhitespaceTrivia */: case 24 /* DotToken */: - case 58 /* AtToken */: + case 59 /* AtToken */: comments.push(scanner.getTokenText()); break; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (!seenLessThan || seenGreaterThan) { return; } @@ -22916,14 +23861,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301 /* JSDocAugmentsTag */, start); + var result = createNode(305 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -22935,7 +23880,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(193 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -22943,19 +23888,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303 /* JSDocClassTag */, start); + var tag = createNode(307 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308 /* JSDocThisTag */, start); + var tag = createNode(312 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305 /* JSDocEnumTag */, start); + var tag = createNode(309 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22964,7 +23909,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311 /* JSDocTypedefTag */, start); + var typedefTag = createNode(315 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22978,9 +23923,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start); } - if (child.kind === 309 /* JSDocTypeTag */) { + if (child.kind === 313 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -22993,7 +23938,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23012,7 +23957,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(248 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23026,22 +23971,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304 /* JSDocCallbackTag */, start); + var callbackTag = createNode(308 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299 /* JSDocSignature */, start); + var jsdocSignature = createNode(303 /* 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(58 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 307 /* JSDocReturnTag */) { + if (tag && tag.kind === 311 /* JSDocReturnTag */) { return tag; } } @@ -23083,10 +24028,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) && + if (child && (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23099,13 +24044,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -23114,7 +24059,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -23150,13 +24095,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(154 /* 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(27 /* CommaToken */)); - var result = createNode(310 /* JSDocTemplateTag */, start); + var result = createNode(314 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23189,18 +24134,21 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73 /* Identifier */, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + var result = createNode(75 /* Identifier */, pos); + if (token() !== 75 /* Identifier */) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -23321,7 +24269,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return true; } return false; @@ -23887,10 +24835,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73 /* Identifier */) { + if (lhs.kind === 75 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101 /* ThisKeyword */) { + if (lhs.kind === 103 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -24040,12 +24988,21 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -24055,7 +25012,7 @@ var ts; }, ]; /* @internal */ - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -24157,7 +25114,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -24194,6 +25152,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -24202,6 +25161,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -24209,6 +25169,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -24227,6 +25188,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -24254,6 +25216,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -24263,6 +25226,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -24279,6 +25243,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -24298,7 +25263,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, // Strict Type Checks { @@ -24432,7 +25398,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { // this option can only be specified in tsconfig.json @@ -24447,7 +25414,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -24471,7 +25439,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -24568,6 +25537,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -24617,14 +25587,20 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + transpileOptionValue: true }, { name: "stripInternal", @@ -24640,6 +25616,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -24660,6 +25642,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -24675,7 +25658,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -24733,6 +25717,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -24762,7 +25753,11 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + /* @internal */ + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -24826,7 +25821,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; /* @internal */ @@ -25326,7 +26322,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 !== 276 /* PropertyAssignment */) { + if (element.kind !== 279 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25382,15 +26378,15 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97 /* NullKeyword */: + case 99 /* 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 + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25408,13 +26404,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 206 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25431,7 +26427,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25482,13 +26478,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), 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 config = __assign(__assign({ compilerOptions: __assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? 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 }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -25713,8 +26709,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -25880,7 +26875,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -26569,8 +27564,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -26829,7 +27825,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27013,6 +28009,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -27023,6 +28020,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -27232,7 +28232,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); @@ -27268,7 +28268,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; @@ -27289,7 +28289,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -27769,35 +28769,67 @@ var ts; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1 /* Instantiated */; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0 /* NonInstantiated */; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; - // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case 259 /* ExportDeclaration */: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0 /* NonInstantiated */; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1 /* Instantiated */) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. + case 249 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0 /* NonInstantiated */: // child is non-instantiated - continue searching @@ -27816,9 +28848,9 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: - return getModuleInstanceState(node); - case 73 /* Identifier */: + case 248 /* ModuleDeclaration */: + return getModuleInstanceState(node, visited); + case 75 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -27827,6 +28859,36 @@ var ts; } return 1 /* Instantiated */; } + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1 /* Instantiated */) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + } var ContainerFlags; (function (ContainerFlags) { // The current node is not a container, and no container manipulation should happen before @@ -27855,7 +28917,9 @@ var ts; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -27889,7 +28953,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -27957,7 +29021,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -27968,7 +29032,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { setValueDeclaration(symbol, node); } } @@ -27984,7 +29048,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 === 255 /* ExportAssignment */) { + if (node.kind === 258 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -27993,7 +29057,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28005,39 +29069,42 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: + case 169 /* FunctionType */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 155 /* 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 === 295 /* 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 === 298 /* 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; @@ -28137,7 +29204,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 === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 258 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28155,7 +29222,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0 /* None */, name); } } @@ -28172,7 +29239,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 261 /* ExportSpecifier */ || (node.kind === 252 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28196,11 +29263,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { + if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 67220415 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -28239,7 +29306,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 !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28267,12 +29334,12 @@ var ts; if (!isIIFE) { currentFlow = { flags: 2 /* Start */ }; if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { - currentFlow.container = node; + currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -28280,19 +29347,20 @@ var ts; flowNodeCreated = ts.identity; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~1408 /* ReachabilityAndEmitFlags */; + node.flags &= ~2816 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 128 /* HasImplicitReturn */; + node.flags |= 256 /* HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 256 /* HasExplicitReturn */; + node.flags |= 512 /* HasExplicitReturn */; + node.endFlowNode = currentFlow; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28309,7 +29377,7 @@ var ts; else if (containerFlags & 64 /* IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 /* ContainsThis */ : node.flags & ~64 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; } else { bindChildren(node); @@ -28336,8 +29404,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28369,79 +29437,93 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 /* FirstStatement */ && node.kind <= 240 /* LastStatement */ && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 225 /* ExpressionStatement */: + bindExpressionStatement(node); + break; + case 237 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + bindAccessExpressionFlow(node); + break; + case 195 /* CallExpression */: bindCallExpressionFlow(node); break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; + case 307 /* JSDocClassTag */: + bindJSDocClassTag(node); + break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 288 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28452,29 +29534,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: - return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 203 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || + return expr.kind === 75 /* Identifier */ || expr.kind === 103 /* ThisKeyword */ || expr.kind === 101 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && + ts.isElementAccessExpression(expr) && + ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { @@ -28486,7 +29568,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 193 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28500,17 +29582,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableReference(expr.left); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -28519,11 +29601,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -28532,20 +29614,14 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4 /* BranchLabel */, - antecedents: undefined - }; + return { flags: 4 /* BranchLabel */, antecedents: undefined }; } function createLoopLabel() { - return { - flags: 8 /* LoopLabel */, - antecedents: undefined - }; + return { flags: 8 /* LoopLabel */, antecedents: undefined }; } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; + flow.flags |= flow.flags & 1024 /* Referenced */ ? 2048 /* Shared */ : 1024 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -28560,31 +29636,36 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 103 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 88 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { - return unreachableFlow; + if (expression.kind === 105 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 90 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (!ts.isOptionalChainRoot(expression.parent)) { + return unreachableFlow; + } } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16 /* Assignment */, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -28599,47 +29680,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 229 /* ForStatement */: + case 209 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 206 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 55 /* BarBarToken */); + return node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* BarBarToken */ || + node.operatorToken.kind === 60 /* QuestionQuestionToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && - node.parent.operator === 52 /* ExclamationToken */) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); } @@ -28667,7 +29753,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 237 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -28699,15 +29785,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 231 /* ForOfStatement */) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 242 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -28729,7 +29815,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 234 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -28749,7 +29835,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -28841,7 +29927,7 @@ var ts; // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. - var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = { flags: 4096 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -28859,7 +29945,7 @@ var ts; } } if (!(currentFlow.flags & 1 /* Unreachable */)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096 /* AfterFinally */, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192 /* AfterFinally */, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -28877,9 +29963,10 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276 /* 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). + // case clauses have unreachable end points (e.g. they all return). Note, we no longer need + // this property in control flow analysis, it's there only for backwards compatibility. node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -28933,6 +30020,17 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + // A top level call expression with a dotted function name and at least one argument + // is potentially an assertion and is therefore included in the control flow. + if (node.expression.kind === 195 /* CallExpression */) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -28944,14 +30042,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 227 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -28962,10 +30060,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 191 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 212 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -28973,16 +30071,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 279 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 280 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 281 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -28990,7 +30088,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -29001,7 +30099,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52 /* ExclamationToken */) { + if (node.operator === 53 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -29011,20 +30109,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -29038,7 +30136,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 62 /* EqualsToken */ && node.left.kind === 194 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29049,7 +30147,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 193 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29088,27 +30186,102 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 309 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - // If the target of the call expression is a function expression or arrow function we have - // 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 === 196 /* ParenthesizedExpression */) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193 /* PropertyAccessExpression */: + bind(node.name); + break; + case 194 /* ElementAccessExpression */: + bind(node.argumentExpression); + break; + case 195 /* CallExpression */: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + // For an optional chain, we emulate the behavior of a logical expression: + // + // a?.b -> a && a.b + // a?.b.c -> a && a.b.c + // a?.b?.c -> a && a.b && a.b.c + // a?.[x = 1] -> a && a[x = 1] + // + // To do this we descend through the chain until we reach the root of a chain (the expression with a `?.`) + // and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest + // of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost + // chain node. We then treat the entire node as the right side of the expression. + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + // If the target of the call expression is a function expression or arrow function we have + // an immediately invoked function expression (IIFE). Initialize the flowNode property to + // the current control flow (which includes evaluation of the IIFE arguments). + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 /* FunctionExpression */ || expr.kind === 201 /* ArrowFunction */) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29117,54 +30290,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 272 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 298 /* JSDocFunctionType */: + case 169 /* FunctionType */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 170 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 278 /* CatchClause */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 250 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 222 /* 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 @@ -29197,45 +30370,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 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 192 /* ObjectLiteralExpression */: + case 245 /* InterfaceDeclaration */: + case 272 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 299 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 303 /* JSDocSignature */: + case 166 /* IndexSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 298 /* JSDocFunctionType */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 246 /* TypeAliasDeclaration */: + case 185 /* 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 @@ -29262,11 +30435,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 4194304 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 32 /* ExportContext */; + if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* ExportContext */; } else { - node.flags &= ~32 /* ExportContext */; + node.flags &= ~64 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -29336,7 +30509,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 === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 281 /* SpreadAssignment */ || prop.name.kind !== 75 /* Identifier */) { continue; } var identifier = prop.name; @@ -29348,7 +30521,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 === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 279 /* PropertyAssignment */ || prop.kind === 280 /* ShorthandPropertyAssignment */ || prop.kind === 160 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29380,10 +30553,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29414,9 +30587,37 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + container = file; + break; + case 4 /* ThisProperty */: + container = declName.parent.expression; + break; + case 3 /* PrototypeProperty */: + container = declName.parent.expression.name; + break; + case 5 /* Property */: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0 /* None */: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75 /* Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -29432,10 +30633,11 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 112 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 120 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */)) { + !(node.flags & 8388608 /* Ambient */) && + !(node.flags & 4194304 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29469,7 +30671,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 73 /* Identifier */) { + if (inStrictMode && node.expression.kind === 75 /* 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); @@ -29480,7 +30682,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73 /* Identifier */) { + if (name && name.kind === 75 /* 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 @@ -29521,8 +30723,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 288 /* SourceFile */ && + blockScopeContainer.kind !== 248 /* 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. @@ -29548,7 +30750,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -29583,7 +30785,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -29617,7 +30819,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 > 148 /* LastToken */) { + if (node.kind > 151 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -29657,8 +30859,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -29679,7 +30881,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 73 /* Identifier */: + case 75 /* 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. @@ -29688,31 +30890,32 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); break; } // falls through - case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + case 103 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -29740,76 +30943,76 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 182 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 282 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* 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 240 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); + case 243 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 162 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); + case 163 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: + case 170 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 185 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -29828,64 +31031,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); + case 246 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + case 247 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 288 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 222 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 306 /* JSDocParameterTag */: - if (node.parent.kind === 299 /* JSDocSignature */) { + case 310 /* JSDocParameterTag */: + if (node.parent.kind === 303 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 298 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 302 /* JSDocTypeLiteral */) { break; } // falls through - case 312 /* JSDocPropertyTag */: + case 316 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -29993,8 +31197,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); } @@ -30004,7 +31207,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 /* Property */ | 1048576 /* ExportValue */ | 32 /* Class */ : 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, lhs, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); } } function bindModuleExportsAssignment(node) { @@ -30029,13 +31232,13 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 === 60 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } @@ -30043,38 +31246,59 @@ var ts; // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } break; default: ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4 /* Property */, "__computed" /* Computed */); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101 /* ThisKeyword */) { + if (node.expression.kind === 103 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30087,8 +31311,7 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.left.expression, node.left, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -30107,32 +31330,38 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 288 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { // This can be an alias for the 'exports' or 'module.exports' names, e.g. // var util = module.exports; // util.property = function ... bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -30141,10 +31370,10 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; @@ -30160,6 +31389,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30170,17 +31402,47 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var includes = 0 /* None */; + var excludes = 0 /* None */; + // Method-like + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192 /* Method */; + excludes = 103359 /* MethodExcludes */; + } + // Maybe accessor-like + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this + // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) + includes |= 65536 /* SetAccessor */ | 4 /* Property */; + excludes |= 78783 /* SetAccessorExcludes */; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 /* GetAccessor */ | 4 /* Property */; + excludes |= 46015 /* GetAccessorExcludes */; + } + } + if (includes === 0 /* None */) { + includes = 4 /* Property */; + excludes = 0 /* PropertyExcludes */; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 /* SourceFile */ + : propertyAccess.parent.parent.kind === 288 /* SourceFile */; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30209,7 +31471,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 === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -30226,7 +31488,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -30238,7 +31500,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -30249,8 +31511,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); + if (node.kind === 244 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; @@ -30283,19 +31545,16 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 /* RegularEnum */ : 0 /* None */); - var enumExcludes = (isEnum ? 68008191 /* RegularEnumExcludes */ : 0 /* None */); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */ | enumFlags, 67220415 /* BlockScopedVariableExcludes */ | enumExcludes); + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -30307,18 +31566,18 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */ | enumFlags, 67220414 /* FunctionScopedVariableExcludes */ | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 306 /* JSDocParameterTag */ && container.kind !== 299 /* JSDocSignature */) { + if (node.kind === 310 /* JSDocParameterTag */ && container.kind !== 303 /* JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { + if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); @@ -30327,34 +31586,34 @@ var ts; bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -30365,8 +31624,8 @@ var ts; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -30386,26 +31645,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 180 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } // reachability checks @@ -30420,11 +31679,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 223 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 248 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30438,7 +31697,7 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 8388608 /* Ambient */) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -30468,12 +31727,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30485,7 +31744,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -30522,58 +31781,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 155 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 161 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -30584,6 +31843,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } if (node.typeArguments) { transformFlags |= 1 /* AssertTypeScript */; } @@ -30595,7 +31857,7 @@ var ts; transformFlags |= 2048 /* ContainsLexicalThis */; } } - if (expression.kind === 93 /* ImportKeyword */) { + if (expression.kind === 95 /* ImportKeyword */) { transformFlags |= 524288 /* ContainsDynamicImport */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -30618,17 +31880,20 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* QuestionQuestionToken */) { + transformFlags |= 4 /* AssertESNext */; + } + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 192 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 191 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ - || operatorTokenKind === 64 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 42 /* AsteriskAsteriskToken */ + || operatorTokenKind === 66 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 64 /* AssertES2016 */; } @@ -30671,8 +31936,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 === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 216 /* AsExpression */ + || expressionKind === 198 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -30712,11 +31977,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87 /* ExtendsKeyword */: + case 89 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; - case 110 /* ImplementsKeyword */: + case 112 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; @@ -30907,9 +32172,12 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -30919,9 +32187,12 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If an ElementAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31009,43 +32280,43 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { - case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 125 /* AsyncKeyword */: + case 205 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; break; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 217 /* NonNullExpression */: + case 137 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 267 /* JsxClosingElement */: + case 268 /* JsxFragment */: + case 269 /* JsxOpeningFragment */: + case 270 /* JsxClosingFragment */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 274 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31053,11 +32324,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: - case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 280 /* ShorthandPropertyAssignment */: + case 119 /* StaticKeyword */: + case 218 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31074,103 +32345,103 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; break; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 167 /* TypePredicate */: + case 168 /* TypeReference */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 171 /* TypeQuery */: + case 172 /* TypeLiteral */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 180 /* InferType */: + case 181 /* ParenthesizedType */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: + case 251 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 153 /* 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. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; excludeFlags = 536870912 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31183,26 +32454,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31220,67 +32491,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 191 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 155 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 161 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 139 /* StringKeyword */: - case 137 /* ObjectKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 142 /* StringKeyword */: + case 140 /* ObjectKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 278 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: - case 99 /* SuperKeyword */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: + case 199 /* ParenthesizedExpression */: + case 101 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31299,7 +32570,7 @@ var ts; /** @internal */ var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -31372,7 +32643,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -31455,7 +32726,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 === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 171 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -31506,6 +32777,180 @@ var ts; WideningKind[WideningKind["Normal"] = 0] = "Normal"; WideningKind[WideningKind["GeneratorYield"] = 1] = "GeneratorYield"; })(WideningKind || (WideningKind = {})); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + 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"] = 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 */, + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ + }); + var typeofNEFacts = ts.createMapFromTemplate({ + 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 TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; + TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; + TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; + CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; + CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; + })(CheckMode || (CheckMode = {})); + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + ContextFlags[ContextFlags["NoConstraints"] = 2] = "NoConstraints"; + })(ContextFlags || (ContextFlags = {})); + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; + })(AccessFlags || (AccessFlags = {})); + var CallbackCheck; + (function (CallbackCheck) { + CallbackCheck[CallbackCheck["None"] = 0] = "None"; + CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; + CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; + })(CallbackCheck || (CallbackCheck = {})); + var MappedTypeModifiers; + (function (MappedTypeModifiers) { + MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; + })(MappedTypeModifiers || (MappedTypeModifiers = {})); + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var MembersOrExportsResolutionKind; + (function (MembersOrExportsResolutionKind) { + MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; + MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; + })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); + var UnusedKind; + (function (UnusedKind) { + UnusedKind[UnusedKind["Local"] = 0] = "Local"; + UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; + })(UnusedKind || (UnusedKind = {})); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); + var DeclarationMeaning; + (function (DeclarationMeaning) { + DeclarationMeaning[DeclarationMeaning["GetAccessor"] = 1] = "GetAccessor"; + DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; + DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; + })(DeclarationMeaning || (DeclarationMeaning = {})); + var DeclarationSpaces; + (function (DeclarationSpaces) { + DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; + DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; + DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; + DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; + })(DeclarationSpaces || (DeclarationSpaces = {})); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -31553,11 +32998,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -31591,6 +33034,9 @@ var ts; var requireSymbol = createSymbol(4 /* Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; + // This object is reused for `checkOptionalExpression` return values to avoid frequent GC due to nursery object allocations. + // This object represents a pool-size of 1. + var pooledOptionalTypeResult = { isOptional: false, type: undefined }; // for public members that accept a Node or one of its subtypes, we must guard against // synthetic nodes created during transformations by calling `getParseTreeNode`. // for most of these, we perform the guard only on `checker` to avoid any possible @@ -31639,8 +33085,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -31757,7 +33206,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -31773,6 +33222,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -31791,6 +33243,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -31819,7 +33272,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -31831,7 +33284,7 @@ var ts; // Ensure file is type checked checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { addUnusedDiagnostics(); } @@ -31843,7 +33296,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -31883,6 +33336,7 @@ var ts; var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 262144 /* ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); var nullType = createIntrinsicType(65536 /* Null */, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 262144 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); @@ -31912,6 +33366,7 @@ var ts; var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 1048576 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -31935,7 +33390,7 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); + var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 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); @@ -32032,6 +33487,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -32044,113 +33502,18 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - // Suggestion diagnostics must have a file. Keyed by source file name. - var suggestionDiagnostics = ts.createMultiMap(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - 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"] = 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 */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ - }); - var typeofNEFacts = ts.createMapFromTemplate({ - 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 suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -32168,71 +33531,8 @@ var ts; var comparableRelation = ts.createMap(); var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; - TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; - TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); - var CheckMode; - (function (CheckMode) { - CheckMode[CheckMode["Normal"] = 0] = "Normal"; - CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; - CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; - CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; - CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; - CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; - })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - })(AccessFlags || (AccessFlags = {})); - var CallbackCheck; - (function (CallbackCheck) { - CallbackCheck[CallbackCheck["None"] = 0] = "None"; - CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; - CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; - })(CallbackCheck || (CallbackCheck = {})); - var MappedTypeModifiers; - (function (MappedTypeModifiers) { - MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; - })(MappedTypeModifiers || (MappedTypeModifiers = {})); - var ExpandingFlags; - (function (ExpandingFlags) { - ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; - ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; - ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; - ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; - })(ExpandingFlags || (ExpandingFlags = {})); - var MembersOrExportsResolutionKind; - (function (MembersOrExportsResolutionKind) { - MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; - MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; - })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); - var UnusedKind; - (function (UnusedKind) { - UnusedKind[UnusedKind["Local"] = 0] = "Local"; - UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; - })(UnusedKind || (UnusedKind = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -32244,7 +33544,7 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; @@ -32297,11 +33597,11 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32323,35 +33623,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= 67220415 /* BlockScopedVariableExcludes */; + result |= 111551 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= 67220414 /* FunctionScopedVariableExcludes */; + result |= 111550 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) result |= 0 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= 68008959 /* EnumMemberExcludes */; + result |= 900095 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= 67219887 /* FunctionExcludes */; + result |= 110991 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 68008383 /* ClassExcludes */; + result |= 899503 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 67897736 /* InterfaceExcludes */; + result |= 788872 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 68008191 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 68008831 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 110735 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) - result |= 67212223 /* MethodExcludes */; + result |= 103359 /* MethodExcludes */; if (flags & 32768 /* GetAccessor */) - result |= 67154879 /* GetAccessorExcludes */; + result |= 46015 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) - result |= 67187647 /* SetAccessorExcludes */; + result |= 78783 /* SetAccessorExcludes */; if (flags & 262144 /* TypeParameter */) - result |= 67635688 /* TypeParameterExcludes */; + result |= 526824 /* TypeParameterExcludes */; if (flags & 524288 /* TypeAlias */) - result |= 67897832 /* TypeAliasExcludes */; + result |= 788968 /* TypeAliasExcludes */; if (flags & 2097152 /* Alias */) result |= 2097152 /* AliasExcludes */; return result; @@ -32386,7 +33686,11 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* Assignment */) { - ts.Debug.assert(source !== target); + if (source === target) { + // This can happen when an export assigned namespace exports something also erroneously exported at the top level + // See `declarationFileNoCrashOnExtraExportModifier` for an example + return target; + } if (!(target.flags & 33554432 /* Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -32515,7 +33819,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -32525,7 +33829,7 @@ var ts; // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); if (mainModule_1.flags & 1920 /* Namespace */) { - // If we’re merging an augmentation to a pattern ambient module, we want to + // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you // all the exports both from the pattern and from the augmentation, but @@ -32574,7 +33878,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32604,8 +33908,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -32618,7 +33922,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304 /* Ambient */) { + declaration.flags & 8388608 /* Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -32632,17 +33936,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 190 /* 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, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 190 /* 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, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 241 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -32665,22 +33969,22 @@ 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 === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 /* ExportSpecifier */ || (usage.parent.kind === 258 /* 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 === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 258 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 224 /* VariableStatement */: + case 229 /* ForStatement */: + case 231 /* 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)) { @@ -32701,16 +34005,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 158 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 160 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -32731,14 +34035,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 201 /* ArrowFunction */: + case 158 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 222 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return true; default: return false; @@ -32784,12 +34088,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 !== 297 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 301 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 155 /* Parameter */ || + lastLocation.kind === 154 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -32806,13 +34110,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 === 152 /* Parameter */ || + lastLocation.kind === 155 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 179 /* 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; @@ -32827,14 +34131,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + case 248 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -32858,7 +34162,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 261 /* ExportSpecifier */)) { break; } } @@ -32872,12 +34176,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -32887,20 +34191,20 @@ var ts; if (!ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -32915,7 +34219,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 213 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -32923,11 +34227,11 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 89 /* ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -32943,34 +34247,34 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -32983,7 +34287,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -32992,7 +34296,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 === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 155 /* Parameter */) { location = location.parent; } // @@ -33007,24 +34311,25 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244 /* ClassDeclaration */)) { location = location.parent; } break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 155 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 155 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33044,7 +34349,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 288 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33110,21 +34415,21 @@ var ts; // we want to check for block-scoped if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 67220415 /* Value */) === 67220415 /* Value */))) { + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415 /* Value */) === 67220415 /* Value */) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -33140,10 +34445,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 201 /* ArrowFunction */ && location.kind !== 200 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -33156,12 +34461,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33173,7 +34478,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 === 151 /* TypeParameter */) { + if (decl.kind === 154 /* 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 @@ -33228,10 +34533,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33241,9 +34546,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -33262,8 +34567,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 /* Type */ & 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1920 /* Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -33272,12 +34577,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later @@ -33301,15 +34606,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */ & ~67897832 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 /* Type */ & ~1024 /* NamespaceModule */ & ~67220415 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~67897832 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -33319,11 +34624,15 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); + if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + // constructor functions aren't block scoped + return; + } // 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 === 244 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { @@ -33355,13 +34664,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33371,7 +34680,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33436,7 +34745,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -33448,7 +34762,7 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -33472,7 +34786,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -33502,9 +34816,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -33539,7 +34854,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default" /* Default */)) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -33559,34 +34879,56 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; } - var aliasLike = resolveEntityName(expression, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 261 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); + case 258 /* ExportAssignment */: + case 208 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280 /* ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 279 /* PropertyAssignment */: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193 /* PropertyAccessExpression */: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -33596,7 +34938,7 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); @@ -33630,7 +34972,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -33646,17 +34988,15 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 258 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); + // We defer checking of the reference of an `import =` until the import itself is referenced, + // This way a chain of imports can be elided if ultimately the final input is only used in a type + // position. + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // import foo = + checkExpressionCached(node.moduleReference); + } } } } @@ -33668,18 +35008,18 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 73 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 75 /* Identifier */ || entityName.parent.kind === 152 /* 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 === 249 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 252 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -33692,9 +35032,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); @@ -33702,9 +35042,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 152 /* QualifiedName */ || name.kind === 193 /* PropertyAccessExpression */) { + var left = name.kind === 152 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 152 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -33756,7 +35096,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -33795,6 +35135,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -33806,9 +35160,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -33839,7 +35190,7 @@ var ts; if (patternAmbientModules) { var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference); if (pattern) { - // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // If the module reference matched a pattern ambient module ('*.foo') but there's also a // module augmentation by the specific name requested ('a.foo'), we store the merged symbol // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports // from a.foo. @@ -33910,7 +35261,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -33919,9 +35270,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* ValueModule */; if (merged.exports === undefined) { - merged.flags = merged.flags | 512 /* ValueModule */; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -33929,15 +35284,16 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 288 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34011,7 +35367,7 @@ var ts; return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -34148,7 +35504,8 @@ var ts; */ function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + // Type parameters end up in the `members` lists but are not externally visible + if (container && !(symbol.flags & 262144 /* TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { @@ -34157,7 +35514,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -34165,7 +35533,7 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { @@ -34173,33 +35541,42 @@ var ts; // fast path, `symbol` is either already the alias or isn't aliased return symbol; } + // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return + // the container itself as the alias for the symbol + var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + /** + * Checks if two symbols, through aliasing and/or merging, refer to the same thing + */ + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 67220415 /* Value */); + return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34277,31 +35654,61 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + case 248 /* ModuleDeclaration */: + var sym = getSymbolOfNode(location); + // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten + // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred + // to one another anyway) + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + // Type parameters are bound into `members` lists so they can merge across declarations + // This is troublesome, since in all other respects, they behave like locals :cries: + // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol + // lookup logic in terms of `resolveName` would be nice + // 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! + var table_1; + // TODO: Should this filtered table be cached in some way? + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 67220415 /* Value */ ? 67220415 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -34332,12 +35739,12 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { // If symbol is directly available by its name in the symbol table @@ -34354,7 +35761,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, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34390,7 +35797,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, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34405,10 +35812,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: continue; default: return false; @@ -34419,11 +35826,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -34466,7 +35873,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -34525,14 +35932,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -34575,21 +35982,21 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 171 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 153 /* ComputedPropertyName */) { // Typeof value - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 152 /* QualifiedName */ || entityName.kind === 193 /* PropertyAccessExpression */ || + entityName.parent.kind === 252 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 67897832 /* Type */; + meaning = 788968 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -34631,15 +36038,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructorType */ : 169 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 165 /* ConstructSignature */ : 164 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -34662,14 +36069,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -34700,6 +36110,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -34710,7 +36123,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -34738,37 +36152,37 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(144 /* UnknownKeyword */); + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139 /* StringKeyword */); + return ts.createKeywordTypeNode(142 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136 /* NumberKeyword */); + return ts.createKeywordTypeNode(139 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147 /* BigIntKeyword */); + return ts.createKeywordTypeNode(150 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124 /* BooleanKeyword */); + return ts.createKeywordTypeNode(127 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); return enumLiteralName; } if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* Type */); } if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); @@ -34777,7 +36191,7 @@ var ts; if (type.flags & 256 /* NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048 /* BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -34791,38 +36205,38 @@ var ts; if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143 /* UniqueKeyword */, ts.createKeywordTypeNode(140 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(146 /* UniqueKeyword */, ts.createKeywordTypeNode(143 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107 /* VoidKeyword */); + return ts.createKeywordTypeNode(109 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(145 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97 /* NullKeyword */); + return ts.createKeywordTypeNode(99 /* NullKeyword */); } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133 /* NeverKeyword */); + return ts.createKeywordTypeNode(136 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140 /* SymbolKeyword */); + return ts.createKeywordTypeNode(143 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* ObjectKeyword */); + return ts.createKeywordTypeNode(140 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -34836,10 +36250,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { @@ -34847,6 +36267,7 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; @@ -34854,15 +36275,9 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832 /* Type */) + ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); - } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -34870,7 +36285,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 177 /* UnionType */ : 178 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -34934,51 +36349,31 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 /* Type */ : 67220415 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; 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 === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415 /* Value */); + return symbolToTypeNode(symbol, context, 111551 /* Value */); } 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) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 67897832 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* Type */); } else { return createElidedInformationPlaceholder(context); } } 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.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -34991,15 +36386,45 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 288 /* SourceFile */ || declaration.parent.kind === 249 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions 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 + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; + var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + // 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.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -35012,12 +36437,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170 /* ConstructorType */, context); return signatureNode; } } @@ -35030,7 +36455,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2 /* WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -35038,7 +36463,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { @@ -35052,12 +36477,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -35065,6 +36490,8 @@ var ts; else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && + // Use `import` types for refs to other scopes, only anonymize something defined in the same scope + ts.findAncestor(type.symbol.valueDeclaration, function (d) { return d === ts.getSourceFileOfNode(context.enclosingDeclaration); }) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return createAnonymousTypeNode(type); } @@ -35087,7 +36514,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 67897832 /* Type */, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -35100,7 +36527,7 @@ var ts; } var flags = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832 /* Type */, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -35152,11 +36579,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35203,7 +36630,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); @@ -35214,25 +36641,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } - var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); + var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -35243,20 +36674,30 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { // Copy comments to node for declaration emit - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + ts.setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -35297,7 +36738,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 139 /* StringKeyword */ : 136 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 142 /* StringKeyword */ : 139 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -35310,7 +36751,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -35321,7 +36762,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 === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35329,23 +36770,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 /* Identifier */ ? + var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? + ts.createToken(123 /* AssertsKeyword */) : + undefined; + var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 121 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 124 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(124 /* 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); @@ -35365,9 +36809,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35377,15 +36821,14 @@ var ts; 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) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 152 /* 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) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(57 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -35395,29 +36838,32 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 190 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; // get symbol of the first identifier of the entityName - var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var firstIdentifier = getFirstIdentifier(accessExpression); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; @@ -35450,6 +36896,13 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent + // No need to lookup an alias for the symbol in itself + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -35530,7 +36983,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 288 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35566,7 +37019,7 @@ var ts; // using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -35575,7 +37028,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 67220415 /* Value */; + var isTypeOf = meaning === 111551 /* Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -35622,16 +37075,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216 /* InInitialEntityName */; } - var parent = chain[index - 1]; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { @@ -35654,7 +37123,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); } function typeParameterToName(type, context) { if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { @@ -35663,7 +37132,10 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ true); + var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 75 /* Identifier */)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -35709,9 +37181,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -35720,6 +37189,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -35747,12 +37219,1072 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + // See getNameForSymbolFromNameType for a stringy equivalent + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384 /* StringOrNumberLiteral */) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192 /* UniqueESSymbol */) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + // Make type parameters created within this context not consume the name outside this context + // The symbol serializer ends up creating many sibling scopes that all need "separate" contexts when + // it comes to naming things - within a normal `typeToTypeNode` call, the node builder only ever descends + // through the type tree, so the only cases where we could have used distinct sibling scopes was when there + // were multiple generic overloads with similar generated type parameter names + // The effect: + // When we write out + // export const x: (x: T) => T + // export const y: (x: T) => T + // we write it out like that, rather than as + // export const x: (x: T) => T + // export const y: (x: T_1) => T_1 + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159 /* MethodSignature */, /*useAcessors*/ false); + // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of + // declaration mapping + // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration + // emit codepaths which want to apply more specific contexts (so we can still refer to the root real declaration + // we're trying to emit from later on) + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.mapMap(symbolTable, function (_symbol, name) { return [ts.unescapeLeadingUnderscores(name), true]; }), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false); + if (accessibleResult.accessibility === 0 /* Accessible */) { + // Lookup the root symbol of the chain of refs we'll use to access it and serialize it + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4 /* Property */)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export=" /* ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + symbolTable = ts.createSymbolTable(); + // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) + symbolTable.set("export=" /* ExportEquals */, exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75 /* Identifier */; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from + // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1 /* Export */); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(/*alias*/ undefined, id); })), + /*moduleSpecifier*/ undefined)])); + } + // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + // Pass 2: Combine all `export {}` declarations + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), + /*moduleSpecifier*/ undefined)]); + } + // Pass 2b: Also combine all `export {} from "..."` declarations as needed + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + // remove group members from statements and then merge group members and add back to statements + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + // Pass 3: Move all `export {}`'s to `export` modifiers where possible + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + // all clauses removed, filter the export declaration + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + // some items filtered, others not - update the export declaration + // (mutating because why not, we're building a whole new tree here anyway) + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + // Not a cleanup, but as a final step: If there is a mix of `export` and non-`export` declarations, but no `export =` or `export {}` add a `export {};` so + // declaration privacy is respected. + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1 /* Export */) & ~2 /* Ambient */; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + // deferredPrivates will be filled up by visiting the symbol table + // And will continue to iterate as elements are added while visited `deferredPrivates` + // (As that's how a map iterator is defined to work) + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + // cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but + // still skip reserializing it if we encounter the merged product later on + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; // Already printed + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + // Only actually serialize symbols within the correct enclosing declaration, otherwise do nothing with the out-of-context symbol + var skipMembershipCheck = !isPrivate; // We only call this on exported symbols when we know they're in the correct scope + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias + // or a merge of some number of those. + // An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping + // each symbol in only one of the representations + // Also, synthesizing a default export of some kind + // If it's an alias: emit `export default ref` + // If it's a property: emit `export default _default` with a `_default` prop + // If it's a class/interface/function: emit a class/interface/function with a `default` modifier + // These forms can merge, eg (`export default 12; export default interface A {}`) + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default" /* Default */; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( + context.encounteredError = true; + // TODO: Issue error via symbol tracker? + return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); + if (symbol.flags & 16 /* Function */) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288 /* TypeAlias */) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + // Need to skip over export= symbols below - json source files get a single `Property` flagged + // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. + if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) + && symbol.escapedName !== "export=" /* ExportEquals */ + && !(symbol.flags & 4194304 /* Prototype */) + && !(symbol.flags & 32 /* Class */)) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384 /* Enum */) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 4 /* Property */) { + // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, + // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property + // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if (symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */)) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64 /* Interface */) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152 /* Alias */) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608 /* ExportStar */) { + // synthesize export * from "moduleReference" + // Straightforward - only one thing to do - make an export declaration + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*exportClause*/ undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + } + } + function includePrivateSymbol(symbol) { + ts.Debug.assertDefined(deferredPrivates); + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` + // Note: This _mutates_ `node` without using `updateNode` - the assumption being that all nodes should be manufactured fresh by the node builder + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0 /* None */; + if (additionalModifierFlags & 1 /* Export */ && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private + newModifierFlags |= 1 /* Export */; + } + if (addingDeclare && !(newModifierFlags & 1 /* Export */) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope + newModifierFlags |= 2 /* Ambient */; + } + if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* Default */; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; // Reset computed flags cache + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608 /* InTypeAlias */; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 164 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 165 /* ConstructSignature */); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather + // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, + // so we don't even have placeholders to fill in. + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, /*suppressNewPrivateContext*/ false); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + ts.forEach(mergedMembers, includePrivateSymbol); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + return ts.createExportSpecifier(name === localName ? undefined : localName, name); + })))]); + addResult(ts.createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ + // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` + var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined + : isConstVariable(symbol) ? 2 /* Const */ + : 1 /* Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a seperate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0 /* None */); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0 /* Call */); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + // Each overload becomes a separate function declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, 243 /* FunctionDeclaration */, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + // Module symbol emit will take care of module-y members, provided it has exports + if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + // handle remote props first - we need to make an `import` declaration that points at the module containing each remote + // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) + // Example: + // import Foo_1 = require("./exporter"); + // export namespace ns { + // import Foo = Foo_1.Foo; + // export { Foo }; + // export const c: number; + // } + // This is needed because in JS, statements like `const x = require("./f")` support both type and value lookup, even if they're + // normally just value lookup (so it functions kinda like an alias even when it's not an alias) + // _Usually_, we'll simply print the top-level as an alias instead of a `var` in such situations, however is is theoretically + // possible to encounter a situation where a type has members from both the current file and other files - in those situations, + // emit akin to the above would be needed. + // Add a namespace + var fakespace = ts.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16 /* Namespace */); + fakespace.flags ^= 8 /* Synthesized */; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + // TODO: implement handling for the localVsRemoteMap.get("remote") - should be difficult to trigger (see comment above), as only interesting cross-file js merges should make this possible + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, /*propertyAsAlias*/ true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8 /* Synthesized */; // reset synthesized + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); // namespaces can never be default exported + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); + // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics + var staticMembers = symbol.flags & (16 /* Function */ | 512 /* ValueModule */) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var constructors = serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 161 /* Constructor */); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + // A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration + // `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + // synthesize an alias, eg `export { symbolName as Name }` + // need to mark the alias `symbol` points + // at as something we need to serialize as a private declaration as well + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" /* ExportEquals */ && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match + verbatimTargetName = "default" /* Default */; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first + switch (node.kind) { + case 252 /* ImportEqualsDeclaration */: + // Could be a local `import localName = ns.member` or + // an external `import localName = require("whatever")` + var isLocalImport = !(target.flags & 512 /* ValueModule */); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0 /* None */); + break; + case 251 /* NamespaceExportDeclaration */: + // export as namespace foo + // TODO: Not part of a file's local or export symbol tables + // Is bound into file.symbol.globalExports instead, which we don't currently traverse + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + break; + case 254 /* ImportClause */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(ts.createIdentifier(localName), /*namedBindings*/ undefined), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0 /* None */); + break; + case 255 /* NamespaceImport */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + break; + case 257 /* ImportSpecifier */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0 /* None */); + break; + case 261 /* ExportSpecifier */: + // does not use localName because the symbol name in this case refers to the name in the exports table, + // which we must exactly preserve + var specifier = node.parent.parent.moduleSpecifier; + // targetName is only used when the target is local, as otherwise the target is an alias that points at + // another file + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258 /* ExportAssignment */: + serializeMaybeAliasAssignment(symbol); + break; + case 208 /* BinaryExpression */: + // Could be best encoded as though an export specifier or as though an export assignment + // If name is default or export=, do an export assignment + // Otherwise do an export specifier + if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + case 193 /* PropertyAccessExpression */: + // A PAE alias is _always_ going to exist as an append to a top-level export, where our top level + // handling should always be sufficient to encode the export action itself + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304 /* Prototype */) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export=" /* ExportEquals */; + var isDefault = name === "default" /* Default */; + var isExportAssignment = isExportEquals || isDefault; + // synthesize export = ref + // ref should refer to either be a locally scoped symbol which we need to emit, or + // a reference to another namespace/module which we may need to emit an `import` statement for + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + // serialize what the alias points to, preserve the declaration's initializer + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + if (target) { + // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it + // eg, `namespace A { export class B {} }; exports = A.B;` + // Technically, this is all that's required in the case where the assignment is an entity name expression + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + // We disable the context's symbol traker for the duration of this name serialization + // as, by virtue of being here, the name is required to print something, and we don't want to + // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue + // a visibility error here (as they're not visible within any scope), but we want to hoist them + // into the containing scope anyway, so we want to skip the visibility checks. + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + } + else { + if (first_1 === expr) { + // serialize as `export {target as name}` + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + // serialize as `import _Ref = t.arg.et; export { _Ref as name }` + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + // serialize as an anonymous property declaration + var varName = getUnusedName(name, symbol); + // We have to use `getWidenedType` here since the object within a json file is unwidened within the file + // (Unwidened types can only exist in expression contexts and should never be serialized) + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); + } + else { + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2 /* Const */)); + addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + // Only object types which are not constructable, or indexable, whose members all come from the + // context source file, and whose property names are all valid identifiers and not late-bound, _and_ + // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + !getIndexInfoOfType(typeToSerialize, 0 /* String */) && + !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols + // need to be merged namespace members + return []; + } + if (p.flags & 4194304 /* Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 /* Static */ : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 /* Accessor */ && useAccessors) { + var result = []; + if (p.flags & 65536 /* SetAccessor */) { + result.push(ts.setTextRange(ts.createSetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "arg", + /*questionToken*/ undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], + /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768 /* GetAccessor */) { + result.push(ts.setTextRange(ts.createGetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + // This is an else/if as accessors and properties can't merge in TS, but might in JS + // If this happens, we assume the accessor takes priority, as it imposes more constraints + else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { + return ts.setTextRange(createProperty( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | staticFlag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), + // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 + // interface members can't have initializers, however class members _can_ + /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0 /* Call */); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + // Each overload becomes a separate method declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; // TODO: Clone + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216 /* Optional */) { + decl.questionToken = ts.createToken(57 /* QuestionToken */); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 /* UniqueESSymbol */ && + type.symbol === symbol) { + context.flags |= 1048576 /* AllowUniqueESSymbolType */; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124 /* AnyKeyword */); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99 /* NullKeyword */)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, "x", + /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144 /* TypeParameter */) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1 /* Construct */) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // No base type, every constructor is empty - elide the extraneous `constructor()` + } + if (baseType) { + // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations + var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; // Every signature was identical - elide constructor list as it is inherited + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + // Each overload becomes a separate constructor declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0 /* String */, 1 /* Number */]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2 /* Const */)); + addResult(statement, 0 /* None */); + return ts.createExpressionWithTypeArguments(/*typeArgs*/ undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + // We don't use `isValueSymbolAccessible` below. since that considers alternative containers (like modules) + // which we can't write out in a syntactically valid way as an expression + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (input === "default" /* Default */) { + input = "_default"; + } + else if (input === "export=" /* ExportEquals */) { + input = "_exports"; + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + var flags = context.flags; + context.flags |= 16777216 /* InInitialEntityName */; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = ts.isIdentifierText(nameCandidate, languageVersion) && !ts.isStringANonContextualKeyword(nameCandidate) ? nameCandidate : getUnusedName("_default", symbol); + } + // The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createToken(123 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); @@ -35797,8 +38329,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 !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181 /* ParenthesizedType */; }); + if (node.kind === 246 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -35806,11 +38338,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 249 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 288 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35848,9 +38380,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -35863,17 +38395,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 241 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -35890,27 +38425,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 241 /* 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 247 /* EnumDeclaration */: + case 252 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -35918,53 +38454,54 @@ 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 !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 252 /* ImportEqualsDeclaration */ && parent.kind !== 288 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* 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 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 161 /* Constructor */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 155 /* Parameter */: + case 249 /* ModuleBlock */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 168 /* TypeReference */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 181 /* 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 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 288 /* SourceFile */: + case 251 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return false; default: return false; @@ -35973,14 +38510,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 258 /* ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 261 /* ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -35998,8 +38538,10 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); - if (importSymbol) { + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -36062,8 +38604,10 @@ var ts; } return ts.Debug.assertNever(propertyName); } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. + /** + * Pop an entry from the type resolution stack and return its associated result value. The result value will + * be true if no circularities were detected, or false if a circularity was found. + */ function popTypeResolution() { resolutionTargets.pop(); resolutionPropertyNames.pop(); @@ -36072,12 +38616,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 241 /* VariableDeclaration */: + case 242 /* VariableDeclarationList */: + case 257 /* ImportSpecifier */: + case 256 /* NamedImports */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: return false; default: return true; @@ -36110,7 +38654,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36162,7 +38706,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(194 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36177,23 +38721,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 190 /* BindingElement */ && parent.kind === 188 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 279 /* PropertyAssignment */ || node.kind === 280 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36211,11 +38755,11 @@ var ts; 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)) { + if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 188 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36283,30 +38827,30 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 /* NullKeyword */ || expr.kind === 73 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 /* NullKeyword */ || expr.kind === 75 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 191 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 155 /* Parameter */ && + (node.parent.kind === 200 /* FunctionExpression */ || node.parent.kind === 201 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration 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 === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230 /* 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 === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231 /* 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, @@ -36325,8 +38869,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { + declaration.kind === 241 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -36339,11 +38883,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 155 /* 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 === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 163 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36410,12 +38954,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4 /* ThisProperty */) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -36433,6 +38979,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { @@ -36458,9 +39007,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -36553,9 +39102,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 === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 /* Constructor */ || + thisContainer.kind === 243 /* FunctionDeclaration */ || + (thisContainer.kind === 200 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -36630,7 +39179,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -36653,7 +39202,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -36692,7 +39241,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 155 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -36754,16 +39303,20 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 258 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -36804,6 +39357,9 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } @@ -36818,7 +39374,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -36845,59 +39401,65 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 163 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return errorType; - } - var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { // If there are no specified types, try to infer it from the body of the get accessor if it exists. if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } // Otherwise, fall back to 'any'. else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* 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)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -36905,19 +39467,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -36929,8 +39482,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 208 /* BinaryExpression */ || + (declaration.kind === 193 /* PropertyAccessExpression */ || declaration.kind === 194 /* ElementAccessExpression */) && + declaration.parent.kind === 208 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -36969,7 +39523,7 @@ var ts; // type symbol, call getDeclaredTypeOfSymbol. // This check is important because without it, a call to getTypeOfSymbol could end // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 67220415 /* Value */ + links.type = targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -36997,7 +39551,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -37078,39 +39632,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 185 /* MappedType */: + case 179 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 185 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 179 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */ || node.kind === 245 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37118,7 +39683,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, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37127,9 +39692,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || + node.kind === 213 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37148,19 +39714,19 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37253,24 +39819,18 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37308,14 +39868,21 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } - // A valid base type is `any`, any non-generic object type or intersection of non-generic - // object types. + // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { + if (type.flags & 262144 /* TypeParameter */) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } + // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? + // There's no reason a `T` should be allowed while a `Readonly` should not. return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } @@ -37323,7 +39890,7 @@ var ts; 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 === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37359,8 +39926,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { - if (declaration.flags & 64 /* ContainsThis */) { + if (declaration.kind === 245 /* InterfaceDeclaration */) { + if (declaration.flags & 128 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -37368,7 +39935,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832 /* Type */, /*ignoreErrors*/ true); + var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -37381,9 +39948,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37399,7 +39972,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -37415,9 +39988,10 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243 /* TypeAliasDeclaration */; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("Type alias symbol with no valid declaration found"); + } var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -37433,17 +40007,17 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 208 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37451,18 +40025,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304 /* Ambient */); + return !(member.flags & 8388608 /* Ambient */); } switch (expr.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 39 /* MinusToken */ && + case 206 /* PrefixUnaryExpression */: + return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37476,10 +40051,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -37503,7 +40078,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -37575,23 +40150,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: + case 186 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -37617,7 +40192,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -37633,14 +40208,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -37695,9 +40270,12 @@ var ts; * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 /* _ */ && @@ -37750,7 +40328,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -37791,7 +40369,8 @@ var ts; // In the event we attempt to resolve the late-bound name of this member recursively, // fall back to the early-bound name of this member. links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -37807,9 +40386,9 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); } lateSymbol.nameType = type; @@ -37850,6 +40429,21 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + || assignmentKind === 4 /* ThisProperty */ + || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; @@ -37860,7 +40454,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 /* LateBindingContainer */ + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) : symbol.members || emptySymbols; } @@ -37890,7 +40484,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4 /* Reference */) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -37953,9 +40547,9 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { var sig = new Signature(checker); @@ -37986,13 +40580,18 @@ var ts; result.mapper = undefined; return result; } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.isOptionalCall = true; + return result; + } function getExpandedParameters(sig) { if (sig.hasRestParameter) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -38012,7 +40611,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38056,8 +40655,9 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true); + // Allow matching non-generic signatures to have excess parameters and different return types. + // Prefer matching this types if possible. + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -38081,7 +40681,7 @@ var ts; for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true)) { + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -38090,7 +40690,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -38108,7 +40708,7 @@ var ts; // signatures from the type, whose ordering would be non-obvious) var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -38120,8 +40720,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -38134,8 +40734,8 @@ var ts; } // A signature `this` type might be a read or a write position... It's very possible that it should be invariant // and we should refuse to merge signatures if there are `this` types and they do not match. However, so as to be - // permissive when calling, for now, we'll union the `this` types just like the overlapping-union-signature check does - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2 /* Subtype */); + // permissive when calling, for now, we'll intersect the `this` types just like we do for param types in union signatures. + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -38246,7 +40846,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -38269,19 +40869,19 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } @@ -38289,7 +40889,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38345,14 +40945,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38495,8 +41099,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && - constraintDeclaration.operator === 130 /* KeyOfKeyword */; + return constraintDeclaration.kind === 183 /* TypeOperator */ && + constraintDeclaration.operator === 133 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -38509,7 +41113,7 @@ var ts; else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T', - // the modifiers type is T. Otherwise, the modifiers type is {}. + // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; @@ -38520,8 +41124,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - 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); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -38737,11 +41341,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; 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). @@ -38751,6 +41355,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908 /* DisjointDomains */) { @@ -38763,8 +41370,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -38850,8 +41457,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -39199,10 +41806,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 === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 297 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39236,13 +41843,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; - } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; } - function createThisTypePredicate(type) { - return { kind: 0 /* This */, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } /** * Gets the minimum number of type arguments needed to satisfy all non-optional type @@ -39308,7 +41912,7 @@ var ts; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415 /* Value */, undefined, undefined, /*isUse*/ false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this" /* This */) { @@ -39318,7 +41922,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { + if (type && type.kind === 186 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -39332,16 +41936,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 === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 162 /* GetAccessor */ || declaration.kind === 163 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 161 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -39399,13 +42003,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return node.name.kind === 153 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39448,9 +42052,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -39479,13 +42080,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73 /* Identifier */) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 /* ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -39495,8 +42093,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signature.isOptionalCall) { + type = propagateOptionalTypeMarker(type, /*wasOptional*/ true); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -39521,7 +42121,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 161 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39531,12 +42131,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39626,7 +42226,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 161 /* Constructor */ || kind === 165 /* ConstructSignature */ || kind === 170 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -39640,7 +42240,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 136 /* NumberKeyword */ : 139 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 139 /* NumberKeyword */ : 142 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -39667,21 +42267,20 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 180 /* 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 === 165 /* TypeReference */) { + if (grandParent.kind === 168 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -39706,7 +42305,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 === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -39730,7 +42329,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -39763,8 +42362,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -39779,7 +42378,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -39788,16 +42387,38 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4 /* Reference */, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + return type; + } + function getTypeArguments(type) { + if (!type.resolvedTypeArguments) { + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -39807,13 +42428,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -39821,10 +42442,13 @@ var ts; return errorType; } } + if (node.kind === 168 /* TypeReference */ && isAliasedType(node)) { + return createDeferredTypeReference(type, node, /*mapper*/ undefined); + } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -39845,27 +42469,27 @@ var ts; * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -39876,34 +42500,22 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); } - // JS enums are 'string' or 'number', not an enum type. - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5 /* EnumTagType */)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -39912,55 +42524,31 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 67897832 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value imported from commonjs. + * These should really be aliases, but this special-case code fakes alias resolution + * by producing a type from a value. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); - } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && // Make sure this is a commonjs export by checking that symbol -> type -> symbol doesn't roundtrip. + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } } function getSubstitutionType(typeVariable, substitute) { @@ -39979,7 +42567,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 174 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -39988,9 +42576,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 301 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 179 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40001,7 +42589,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 168 /* TypeReference */ || node.kind === 187 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40038,10 +42626,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40053,7 +42641,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40066,10 +42654,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832 /* Type */; + var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -40102,9 +42699,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return declaration; } } @@ -40124,10 +42721,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { // Don't track references for global symbols anyway, so value if `isReference` is arbitrary @@ -40196,7 +42793,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -40223,15 +42820,55 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 /* ArrayType */ || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176 /* RestType */) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 /* OptionalType */ && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); + } + // Return true when the given node is transitively contained in type constructs that eagerly + // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments + // of type aliases are eagerly resolved. + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181 /* ParenthesizedType */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 184 /* IndexedAccessType */: + case 179 /* ConditionalType */: + case 183 /* TypeOperator */: + return isAliasedType(parent); + case 246 /* TypeAliasDeclaration */: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 /* TupleType */ && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, /*mapper*/ undefined); + } + else { + var elementTypes = node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 137 /* ReadonlyKeyword */; } // We represent tuple types as type references to synthesized generic interface types created by // this function. The types are of the form: @@ -40268,7 +42905,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -40302,27 +42939,13 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* 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; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { // don't slice off rest element index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -40371,8 +42994,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -40401,8 +43024,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -40487,10 +43110,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { continue; } if (first) { @@ -40509,14 +43132,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } // This function assumes the constituent type list is sorted and deduplicated. function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { @@ -40583,8 +43202,8 @@ var ts; // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -40622,6 +43241,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } // If the given list of types contains more than one union of primitive types, replace the // first with a union containing an intersection of those primitive types, then remove the // other unions and return true. Otherwise, do nothing and return false. @@ -40740,6 +43368,12 @@ var ts; // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768 /* Undefined */)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536 /* Null */)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } else { // 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. @@ -40844,20 +43478,22 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130 /* KeyOfKeyword */: + case 133 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 140 /* SymbolKeyword */ + case 146 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 143 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -40893,7 +43529,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -40904,13 +43540,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 103 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -41041,13 +43677,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 184 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 153 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41172,7 +43805,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 !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41384,7 +44017,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 67220415 /* Value */ | 67897832 /* Type */ : 67897832 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41407,14 +44040,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 /* Value */ + var errorMessage = targetMeaning === 111551 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -41423,16 +44056,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + if (meaning === 111551 /* Value */) { + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41456,7 +44089,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -41645,12 +44282,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -41663,89 +44314,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 124 /* AnyKeyword */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return anyType; - case 144 /* UnknownKeyword */: + case 147 /* UnknownKeyword */: return unknownType; - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return stringType; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return numberType; - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return bigintType; - case 124 /* BooleanKeyword */: + case 127 /* BooleanKeyword */: return booleanType; - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return esSymbolType; - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return voidType; - case 142 /* UndefinedKeyword */: + case 145 /* UndefinedKeyword */: return undefinedType; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullType; - case 133 /* NeverKeyword */: + case 136 /* NeverKeyword */: return neverType; - case 137 /* ObjectKeyword */: - return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 140 /* ObjectKeyword */: + return node.flags & 131072 /* JavaScriptFile */ ? anyType : nonPrimitiveType; + case 182 /* ThisType */: + case 103 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: - return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 167 /* TypePredicate */: + return node.assertsModifier ? voidType : booleanType; + case 215 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + return getTypeFromArrayOrTupleTypeNode(node); + case 175 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 181 /* ParenthesizedType */: + case 296 /* JSDocNonNullableType */: + case 292 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 180 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 187 /* 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 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -41834,20 +44485,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1 /* Identifier */, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0 /* This */, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -41901,17 +44539,17 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -41927,7 +44565,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -41940,13 +44578,14 @@ var ts; // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -41954,8 +44593,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 152 /* QualifiedName */ || + node.parent.kind === 168 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -41964,7 +44604,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 /* Block */ || n.kind === 179 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -41973,12 +44613,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 182 /* ThisType */: return !!tp.isThisType; - case 73 /* Identifier */: + case 75 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42032,7 +44672,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -42128,15 +44768,18 @@ var ts; // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32 /* Mapped */) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4 /* Reference */) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -42200,35 +44843,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: - return node.operatorToken.kind === 55 /* BarBarToken */ && + case 208 /* BinaryExpression */: + return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 271 /* 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 271 /* JsxExpression */: { + case 274 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42248,7 +44891,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* 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); @@ -42260,7 +44903,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42363,23 +45006,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 274 /* JsxExpression */: + case 199 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -42551,7 +45194,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -42560,9 +45203,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -42636,7 +45279,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -42704,11 +45347,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 163 /* SetAccessor */: return [3 /*break*/, 2]; + case 162 /* GetAccessor */: return [3 /*break*/, 2]; + case 160 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 280 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 279 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -42743,7 +45386,7 @@ var ts; } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { return compareSignaturesRelated(source, target, 0 /* None */, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -42756,7 +45399,7 @@ var ts; /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -42780,8 +45423,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 /* MethodDeclaration */ && + kind !== 159 /* MethodSignature */ && kind !== 161 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -42814,11 +45457,11 @@ var ts; // with respect to T. var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (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) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -42829,15 +45472,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -42858,6 +45503,9 @@ var ts; // wouldn't be co-variant for T without this rule. result &= callbackCheck === 1 /* Bivariant */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -42870,7 +45518,7 @@ var ts; } return 0 /* False */; } - if (source.kind === 1 /* Identifier */) { + if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -42879,7 +45527,9 @@ var ts; return 0 /* False */; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -42925,12 +45575,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { - return relation === 1 /* Succeeded */; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { + return !!(entry & 1 /* Succeeded */); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -42941,7 +45591,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); } else { enumRelation.set(id, 2 /* Failed */); @@ -43020,7 +45670,7 @@ var ts; if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { - return related === 1 /* Succeeded */; + return !!(related & 1 /* Succeeded */); } } if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { @@ -43052,9 +45702,14 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -43084,7 +45739,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -43097,8 +45752,131 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0 /* False */; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; // Suppress the next relation error + lastSkippedInfo = undefined; // Reset skipped info cache + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + return; + } + // The first error will be the innermost, while the last will be the outermost - so by popping off the end, + // we can build from left to right + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + // Parenthesize a `new` if there is one + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + // If leading, just print back the arg (irrespective of if it's a valid identifier) + if (path.length === 0) { + path = "" + str; + } + // Otherwise write a dotted name if possible + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + // Failing that, check if the name is already a computed name + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + // And finally write out a computed name as a last resort + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + // Don't flatten signature compatability errors at the start of a chain - instead prefer + // to unify (the with no arguments bit is excessive for printback) and print them back + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + // Remove the innermost secondary error as it will duplicate the error already reported by `reportRelationError` on entry + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; // Teporarily override elision to ensure error is reported + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -43111,6 +45889,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 /* TypeParameter */ && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -43129,8 +45909,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43223,7 +46003,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -43233,11 +46013,11 @@ var ts; return 0 /* False */; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = 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, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -43252,23 +46032,23 @@ var ts; return 0 /* False */; } var result = 0 /* False */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); 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 & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { if (target.flags & 1048576 /* Union */) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined, isIntersectionConstituent)) { return 0 /* False */; } } @@ -43276,9 +46056,9 @@ var ts; else if (target.flags & 2097152 /* Intersection */) { isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, /*isIntersectionConstituent*/ false)) { return 0 /* False */; } } @@ -43297,15 +46077,15 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); } if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152 /* Intersection */) { + if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) { // 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 @@ -43315,21 +46095,30 @@ 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 & 1048576 /* Union */)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) { + if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { @@ -43349,6 +46138,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } @@ -43385,7 +46175,7 @@ var ts; // check excess properties against discriminant type only, not the entire union return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -43400,6 +46190,11 @@ var ts; // 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) + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + // Note that extraneous children (as in `extra`) don't pass this check, + // since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute. + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -43428,9 +46223,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -43566,14 +46361,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { return related; } @@ -43593,7 +46388,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -43620,10 +46415,10 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t); } else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 3 /* Bivariant */) { // In the bivariant case we first compare contravariantly without reporting @@ -43632,16 +46427,16 @@ var ts; // which is generally easier to reason about. related = isRelatedTo(t, s, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } if (!related) { @@ -43652,17 +46447,6 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8 /* Unmeasurable */) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16 /* Unreliable */) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -43673,24 +46457,24 @@ var ts; return 0 /* False */; } var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2 /* Failed */) { + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24 /* ReportsMask */; + if (saved & 8 /* ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16 /* ReportsUnreliable */) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; } } if (!maybeKeys) { @@ -43721,14 +46505,26 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 /* True */ || depth === 0) { // If result is definitely true, record all maybe keys as having succeeded for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */); + relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); } maybeCount = maybeStart; } @@ -43736,7 +46532,7 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); + relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -43776,7 +46572,7 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); // 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. @@ -43784,7 +46580,7 @@ var ts; source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43866,7 +46662,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -43877,7 +46673,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43886,25 +46682,25 @@ var ts; if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43913,13 +46709,23 @@ var ts; // 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. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43928,14 +46734,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43949,7 +46755,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43968,7 +46774,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); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43995,8 +46801,8 @@ var ts; // relates to X. Thus, we include intersection types on the source side here. 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, /*excludedProperties*/ undefined); + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; + result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); if (result) { @@ -44010,7 +46816,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; // Use variance error (there is no structural one) and return false } else if (result) { return result; @@ -44031,8 +46837,8 @@ var ts; } } return 0 /* False */; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { @@ -44041,7 +46847,7 @@ var ts; // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially // be assuming identity of the type parameter. originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -44069,7 +46875,7 @@ var ts; // comparison unexpectedly succeeds. This can happen when the structural comparison result // is a Ternary.Maybe for example caused by the recursion depth limiter. originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44145,11 +46951,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) @@ -44157,7 +46963,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -44165,8 +46971,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -44179,15 +46985,15 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, /*isIntersectionConstituent*/ false); if (result) { result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); if (result) { @@ -44222,7 +47028,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { @@ -44262,10 +47068,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -44303,10 +47109,10 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0 /* False */; } @@ -44326,7 +47132,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -44342,12 +47148,12 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) { @@ -44357,8 +47163,8 @@ var ts; 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(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined) @@ -44370,7 +47176,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -44395,8 +47201,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -44410,12 +47217,14 @@ var ts; // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members var properties = target.flags & 1048576 /* Union */ ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304 /* Prototype */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0 /* False */; } @@ -44478,14 +47287,15 @@ var ts; } } var result = -1 /* True */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 /* Instantiated */ && ts.getObjectFlags(target) & 64 /* Instantiated */ && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters // as they are known to always be the same. for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0 /* False */; } @@ -44499,7 +47309,7 @@ var ts; // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -44508,10 +47318,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -44524,11 +47334,23 @@ var ts; } return result; } + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } /** * See signatureAssignableTo, compareSignaturesIdentical */ - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -44594,7 +47416,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -44650,23 +47472,27 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + // undefined=unknown, true=discriminated, false=not discriminated + // The state of each type progresses from left to right. Discriminated types stop at 'true'. + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; // Finding multiple fields which discriminate to the same type is fine - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; } + else { + discriminable[i] = false; + } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(/*searchElement*/ true); + // make sure exactly 1 matches before returning it + return match === -1 || discriminable.indexOf(/*searchElement*/ true, match + 1) !== -1 ? defaultValue : target.types[match]; } /** * A type is 'weak' if it is an object type with at least one optional property @@ -44722,7 +47548,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -44754,7 +47580,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -44780,8 +47606,11 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -44790,7 +47619,7 @@ var ts; function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -44869,6 +47698,9 @@ var ts; // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 // levels, but unequal at some level beyond that. + // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially + // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives + // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`). 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 & 524288 /* Object */) { @@ -44885,8 +47717,30 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608 /* IndexedAccess */) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + /** + * Gets the leftmost object type in a chain of indexed accesses, eg, in A[P][Q], returns A + */ + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608 /* IndexedAccess */) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -44994,20 +47848,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - // If they're both type predicates their return types will both be `boolean`, so no need to compare those. - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : + source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type) : + 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -45046,7 +47902,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, @@ -45054,7 +47910,7 @@ var ts; return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -45138,7 +47994,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -45153,8 +48009,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -45219,6 +48075,41 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, function (t) { return t !== optionalType; }) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function createPooledOptionalTypeResult(isOptional, type) { + pooledOptionalTypeResult.isOptional = isOptional; + pooledOptionalTypeResult.type = type; + return pooledOptionalTypeResult; + } + function checkOptionalExpression(parent, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + var isOptional = false; + var type = checkExpression(expression); + if (ts.isOptionalChain(parent)) { + if (parent.questionDotToken) { + // If we have a questionDotToken then we are an OptionalExpression and should remove `null` and + // `undefined` from the type and add the optionalType to the result, if needed. + isOptional = isNullableType(type); + return createPooledOptionalTypeResult(isOptional, isOptional ? getNonNullableType(type) : type); + } + // If we do not have a questionDotToken, then we are an OptionalChain and we remove the optionalType and + // indicate whether we need to add optionalType back into the result. + var nonOptionalType = removeOptionalTypeMarker(type); + if (nonOptionalType !== type) { + isOptional = true; + type = nonOptionalType; + } + } + type = checkNonNullType(type, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + return createPooledOptionalTypeResult(isOptional, type); + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -45248,8 +48139,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45401,7 +48292,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -45438,7 +48329,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -45468,17 +48359,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 208 /* BinaryExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* 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 152 /* Parameter */: + case 155 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -45488,23 +48379,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -45518,7 +48409,7 @@ var ts; wideningKind === 1 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182 /* MappedType */: + case 185 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -45560,8 +48451,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 /* This */ || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -45630,6 +48520,12 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } @@ -45639,10 +48535,10 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & 32 /* Mapped */ || - type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -45708,10 +48604,10 @@ 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, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), 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.readonly, source.target.associatedNames); @@ -45797,8 +48693,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256 /* MaxValue */; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -45821,50 +48716,57 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - 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) { - for (var _i = 0, _a = source.types; _i < _a.length; _i++) { - var t = _a[_i]; - inferFromTypes(t, t); - } - return; - } - // Find each source constituent type that has an identically matching target constituent - // type, and for each such type infer from the type to itself. When inferring from a - // type to itself we effectively find all type parameter occurrences within that type - // and infer themselves as their type arguments. We have special handling for numeric - // and string literals because the number and string types are not represented as unions - // of all their possible values. - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } - } - // Next, to improve the quality of inferences, reduce the source and target types by - // removing the identically matched constituents. For example, when inferring from - // 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'. - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + // When source and target are the same union or intersection type, just relate each constituent + // type to itself. + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } + return; } - else if (target.flags & 1048576 /* Union */ && !(target.flags & 1024 /* EnumLiteral */) || target.flags & 2097152 /* Intersection */) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); + if (target.flags & 1048576 /* Union */) { + // First, infer between identically matching source and target constituents and remove the + // matching types. + var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + // Next, infer between closely matching source and target constituents and remove + // the matching types. Types closely match when they are instantiations of the same + // object type or instantiations of the same type alias. + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { return; } + target = getUnionType(targets); + if (sources.length === 0) { + // All source constituents have been matched and there is nothing further to infer from. + // However, simply making no inferences is undesirable because it could ultimately mean + // inferring a type parameter constraint. Instead, make a lower priority inference from + // the full source to whatever remains in the target. For example, when inferring from + // string to 'string | T', make a lower priority inference of string for T. + var savePriority = priority; + priority |= 1 /* NakedTypeVariable */; + inferFromTypes(source, target); + priority = savePriority; + return; + } + source = getUnionType(sources); + } + else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + // We reduce intersection types only when they contain naked type parameters. For example, when + // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and + // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the + // string[] on the source side and infer string for T. + // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" + // in such scenarios. + if (!(source.flags & 1048576 /* Union */)) { + // Infer between identically matching source and target constituents and remove the matching types. + var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); + } } else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { target = getActualTypeVariable(target); @@ -45909,7 +48811,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -45931,9 +48833,10 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; @@ -45969,8 +48872,8 @@ var ts; else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -46000,15 +48903,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1 /* Circularity */); + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -46048,31 +48972,34 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; + var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we - // track whether inferences were made from that particular type to some target. - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + // track whether inferences were made from that particular type to some target with + // equal priority (i.e. of equal quality) to what we would infer for a naked type + // parameter. + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - // If the target has a single naked type variable and inference completed (meaning we - // explored the types fully), create a union of the source types from which no inferences - // have been made so far and infer from that union to the naked type variable. - if (typeVariableCount === 1 && inferenceComplete) { + // If the target has a single naked type variable and no inference circularities were + // encountered above (meaning we explored the types fully), create a union of the source + // types from which no inferences have been made so far and infer from that union to the + // naked type variable. + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -46084,8 +49011,8 @@ var ts; // We infer from types that are not naked type variables first so that inferences we // make from nested naked type variables and given slightly higher priority by virtue // of being first in the candidates array. - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -46101,8 +49028,8 @@ var ts; if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1 /* NakedTypeVariable */; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -46176,7 +49103,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1 /* Circularity */; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -46188,6 +49115,11 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + // If source and target are references to the same generic type, infer from type arguments + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } 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 // from S to T and from X to Y. @@ -46217,10 +49149,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -46260,7 +49192,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 === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 160 /* MethodDeclaration */ || kind === 159 /* MethodSignature */ || kind === 161 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46286,46 +49218,12 @@ var ts; } } } - function isMatchableType(type) { - // We exclude non-anonymous object types because some frameworks (e.g. Ember) rely on the ability to - // infer between types that don't witness their type variables. Such types would otherwise be eliminated - // because they appear identical. - return !(type.flags & 524288 /* Object */) || !!(ts.getObjectFlags(type) & 16 /* Anonymous */); - } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */) && target.flags & 1048576 /* Union */) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - /** - * Return a new union or intersection type computed by removing a given set of types - * from a given union or intersection type. - */ - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -46464,7 +49362,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46476,7 +49374,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; @@ -46485,7 +49383,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 === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 /* TypeQuery */ ? true : n.kind === 75 /* Identifier */ || n.kind === 152 /* 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 @@ -46495,16 +49393,16 @@ var ts; // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46515,24 +49413,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73 /* Identifier */: - return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + case 75 /* Identifier */: + return target.kind === 75 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 /* VariableDeclaration */ || target.kind === 190 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 101 /* ThisKeyword */: - return target.kind === 101 /* ThisKeyword */; - case 99 /* SuperKeyword */: - return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 103 /* ThisKeyword */: + return target.kind === 103 /* ThisKeyword */; + case 101 /* SuperKeyword */: + return target.kind === 101 /* SuperKeyword */; + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -46540,8 +49438,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 /* PropertyAccessExpression */ ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -46565,7 +49463,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73 /* Identifier */) { + if (expr.kind === 75 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -46596,7 +49494,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -46624,14 +49522,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 193 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -46673,8 +49571,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -46779,15 +49677,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 208 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 231 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -46804,21 +49702,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -46826,7 +49724,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -46844,37 +49742,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 230 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 231 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 241 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 241 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 190 /* BindingElement */ && node.parent.kind === 208 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -46884,13 +49777,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 199 /* ParenthesizedExpression */ || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -46912,8 +49805,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { - if (clause.expression.kind === 10 /* StringLiteral */) { + if (clause.kind === 275 /* CaseClause */) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -46996,8 +49889,7 @@ var ts; return mapType(typeWithPrimitives, function (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; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47049,8 +49941,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47073,33 +49965,78 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 193 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 195 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 60 /* EqualsToken */ && + parent.parent.kind === 208 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 /* VariableDeclaration */ || declaration.kind === 155 /* Parameter */ || + declaration.kind === 158 /* PropertyDeclaration */ || declaration.kind === 157 /* PropertySignature */) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99 /* SuperKeyword */) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + // We require the dotted function name in an assertion expression to be comprised of identifiers + // that reference function, method, class or value module symbols; or variable, property or + // parameter symbols with declarations that have explicit type annotations. Such references are + // resolvable with no possibility of triggering circularities in control flow analysis. + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216 /* InWithStatement */)) { + switch (node.kind) { + case 75 /* Identifier */: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 103 /* ThisKeyword */: + return getExplicitThisType(node); + case 193 /* PropertyAccessExpression */: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199 /* ParenthesizedExpression */: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + // A call expression parented by an expression statement is a potential assertion. Other call + // expressions are potential type predicate function calls. In order to avoid triggering + // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call + // target expression of an assertion. + var funcType = node.parent.kind === 225 /* ExpressionStatement */ ? getTypeOfDottedName(node.expression, /*diagnostic*/ undefined) : + node.expression.kind !== 101 /* SuperKeyword */ ? checkOptionalExpression(node, node.expression).type : + undefined; + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -47107,6 +50044,68 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 /* PreFinally */ && flow.lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048 /* Shared */) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + } + noCacheCheck = false; + } + if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 4096 /* PreFinally */)) { + flow = flow.antecedent; + } + else if (flags & 512 /* Call */) { + var signature = getEffectsSignature(flow.node); + if (signature && getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 4 /* BranchLabel */) { + // A branching point is reachable if any branch is reachable. + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8 /* LoopLabel */) { + // A loop is reachable if the control flow path that leads to the top is reachable. + flow = flow.antecedents[0]; + } + else if (flags & 128 /* SwitchClause */) { + // The control flow path representing an unmatched value in a switch statement with + // no default clause is unreachable if the switch statement is exhaustive. + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192 /* AfterFinally */) { + // Cache is unreliable once we start locking nodes + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, /*skipCacheCheck*/ false); + flow.locked = false; + return result; + } + else { + return !(flags & 1 /* Unreachable */); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -47118,6 +50117,7 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; @@ -47126,7 +50126,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47148,16 +50148,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192 /* Cached */) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -47169,13 +50160,13 @@ var ts; } } var type = void 0; - if (flags & 4096 /* AfterFinally */) { + if (flags & 8192 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048 /* PreFinally */) { + else if (flags & 4096 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; @@ -47187,14 +50178,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192 /* Cached */; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512 /* Call */) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96 /* Condition */) { @@ -47221,11 +50210,11 @@ var ts; } else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && - reference.kind !== 101 /* ThisKeyword */) { + reference.kind !== 193 /* PropertyAccessExpression */ && + reference.kind !== 194 /* ElementAccessExpression */ && + reference.kind !== 103 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -47237,7 +50226,7 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // Record visited node and the associated type in the cache. sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; @@ -47247,11 +50236,34 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384 /* Cached */) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */ ? + getInitialType(node) : + getAssignedType(node), reference); + // We cache the assigned type when getFlowTypeOfReference was recursively invoked in the + // resolution of the assigned type and we're not within loop analysis. + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384 /* Cached */; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -47260,11 +50272,11 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } @@ -47273,27 +50285,60 @@ var ts; // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } // A matching dotted name might also be an expando property on a function *expression*, // 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 === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 200 /* FunctionExpression */ || init.kind === 201 /* 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 === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 208 /* BinaryExpression */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56 /* BarBarToken */) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, /*assumeTrue*/ true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : + predicate.kind === 3 /* AssertsIdentifier */ ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 195 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47301,7 +50346,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47336,7 +50381,7 @@ var ts; // *only* place a silent never type is ever generated. var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -47354,12 +50399,15 @@ 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 === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { type = declaredType; } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } return createFlowType(type, isIncomplete(flowType)); } function getTypeAtFlowBranchLabel(flow) { @@ -47368,7 +50416,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + if (antecedent.flags & 4096 /* PreFinally */ && antecedent.lock.locked) { // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. @@ -47428,25 +50476,32 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + // The first antecedent of a loop junction is always the non-looping control + // flow path that leads to the top. + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - // If we see a value appear in the cache it is a sign that control flow analysis - // was restarted and completed by checkExpressionCached. We can simply pick up - // the resulting type and bail out. - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + // All but the first antecedent are the looping control flow paths that lead + // back to the loop junction. We track these on the flow loop stack. + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + // If we see a value appear in the cache it is a sign that control flow analysis + // was restarted and completed by checkExpressionCached. We can simply pick up + // the resulting type and bail out. + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control @@ -47520,19 +50575,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -47551,9 +50606,9 @@ var ts; return declaredType; } break; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94 /* InKeyword */: + case 96 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -47568,11 +50623,11 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && (operator === 35 /* EqualsEqualsEqualsToken */) && assumeTrue) { + if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { return valueType; } @@ -47585,7 +50640,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? @@ -47597,7 +50652,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* EqualsEqualsToken */ ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -47610,7 +50665,7 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // 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 @@ -47620,7 +50675,7 @@ var ts; } return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (type.flags & 1 /* Any */ && literal.text === "function") { @@ -47847,22 +50902,24 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { return type; } - if (ts.isIdentifierTypePredicate(predicate)) { + if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { var predicateArgument = callExpression.arguments[predicate.parameterIndex]; - if (predicateArgument) { + if (predicateArgument && predicate.type) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } @@ -47873,7 +50930,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { + if (ts.isAccessExpression(invokedExpression) && predicate.type) { var possibleReference = ts.skipParentheses(invokedExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -47888,27 +50945,44 @@ var ts; // Narrow the given type based on the given expression having the assumed boolean value. The returned type // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { + // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` + if (ts.isOptionalChainRoot(expr.parent) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 195 /* CallExpression */: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: - if (expr.operator === 52 /* ExclamationToken */) { + case 206 /* PrefixUnaryExpression */: + if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; @@ -47916,7 +50990,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 === 73 /* Identifier */) { + if (location.kind === 75 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -47937,9 +51011,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 249 /* ModuleBlock */ || + node.kind === 288 /* SourceFile */ || + node.kind === 158 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -47958,10 +51032,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 === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155 /* Parameter */) { symbol.isAssigned = true; } } @@ -47976,7 +51050,7 @@ 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 === 152 /* Parameter */ && + declaration.kind === 155 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -47984,10 +51058,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 193 /* PropertyAccessExpression */ || + parent.kind === 195 /* CallExpression */ && parent.expression === node || + parent.kind === 194 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 190 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48002,8 +51076,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -48021,7 +51098,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* 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 */)) { @@ -48042,7 +51119,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 === 241 /* ClassDeclaration */ + if (declaration.kind === 244 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48054,14 +51131,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 213 /* 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 !== 285 /* SourceFile */) { + while (container.kind !== 288 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 158 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48110,7 +51187,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 === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 155 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48119,8 +51196,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 === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 /* FunctionExpression */ || + flowContainer.kind === 201 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48128,11 +51205,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 4194304 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261 /* ExportSpecifier */) || + node.parent.kind === 217 /* NonNullExpression */ || + declaration.kind === 241 /* VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -48166,7 +51243,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 278 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48189,7 +51266,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, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48207,8 +51284,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 === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 229 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48226,7 +51303,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 199 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48234,9 +51311,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 206 /* PrefixUnaryExpression */ || current.parent.kind === 207 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -48247,7 +51324,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 158 /* PropertyDeclaration */ || container.kind === 161 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48315,37 +51392,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 161 /* 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 === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* 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 244 /* EnumDeclaration */: + case 247 /* 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 158 /* Constructor */: + case 161 /* 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 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* 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 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48384,10 +51461,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48395,12 +51470,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 200 /* FunctionExpression */ || container.kind === 243 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48429,9 +51502,22 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 200 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48441,16 +51527,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 160 /* MethodDeclaration */ && + container.parent.kind === 192 /* 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 === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && + container.parent.kind === 279 /* PropertyAssignment */ && + container.parent.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48458,7 +51544,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 197 /* FunctionExpression */ && + else if (container.kind === 200 /* 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") && @@ -48483,7 +51569,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 298 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48497,15 +51583,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 /* 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 === 198 /* ArrowFunction */) { + while (container && container.kind === 201 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48518,14 +51604,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153 /* ComputedPropertyName */; }); + if (current && current.kind === 153 /* 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 === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -48533,7 +51619,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 161 /* 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) { @@ -48602,7 +51688,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 === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 160 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -48616,7 +51702,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 192 /* 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; @@ -48637,7 +51723,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 /* 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; @@ -48652,7 +51738,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 === 158 /* Constructor */; + return container.kind === 161 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -48660,21 +51746,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 === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */ || + container.kind === 158 /* PropertyDeclaration */ || + container.kind === 157 /* PropertySignature */ || + container.kind === 161 /* Constructor */; } } } @@ -48682,14 +51768,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 160 /* MethodDeclaration */ || + func.kind === 162 /* GetAccessor */ || + func.kind === 163 /* SetAccessor */) && func.parent.kind === 192 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 200 /* FunctionExpression */ && func.parent.kind === 279 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -48697,7 +51783,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -48724,7 +51810,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 279 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -48738,9 +51824,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 === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 193 /* PropertyAccessExpression */ || target.kind === 194 /* 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)) { @@ -48804,9 +51890,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 155 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -48896,6 +51982,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -48927,7 +52022,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 197 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -48936,7 +52031,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: if (node !== right) { return undefined; } @@ -48945,7 +52040,8 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -48954,7 +52050,7 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -48982,19 +52078,22 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -49016,12 +52115,13 @@ var ts; } if (kind === 2 /* ModuleExports */) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -49065,7 +52165,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49154,32 +52254,35 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 73 /* Identifier */: - case 142 /* UndefinedKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 75 /* Identifier */: + case 145 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 199 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 274 /* 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 === 276 /* 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 === 279 /* 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 === 268 /* 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 === 271 /* 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, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, /*noReductions*/ true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -49246,7 +52349,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49255,58 +52358,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 190 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 201 /* ArrowFunction */: + case 234 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: - if (parent.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (parent.expression.kind === 95 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: + case 196 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 191 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 220 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 210 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 199 /* 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, contextFlags); } - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49461,7 +52564,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 200 /* FunctionExpression */ || node.kind === 201 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49475,14 +52578,12 @@ 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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1 /* Signature */) : - getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* Signature */); if (!type) { return undefined; } @@ -49491,8 +52592,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -49522,8 +52623,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 190 /* BindingElement */ && !!node.initializer) || + (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -49535,7 +52636,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 212 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -49560,12 +52661,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 212 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212 /* 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] = []". @@ -49607,9 +52708,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return isNumericComputedName(name); - case 73 /* Identifier */: + case 75 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -49697,7 +52798,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 188 /* ObjectBindingPattern */ || contextualType.pattern.kind === 192 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -49712,13 +52813,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 === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 279 /* PropertyAssignment */ || + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -49741,8 +52842,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 === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -49767,7 +52868,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 281 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -49793,7 +52894,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 162 /* GetAccessor */ || memberDecl.kind === 163 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -49853,7 +52954,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -49901,7 +53008,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 === 73 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -49946,7 +53053,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 273 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -49969,7 +53076,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 /* 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); @@ -50043,7 +53150,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -50117,7 +53224,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -50141,7 +53248,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -50293,13 +53400,13 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted reactSym.isReferenced = 67108863 /* All */; - // If react symbol is alias, mark it as referenced - if (reactSym.flags & 2097152 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 2097152 /* Alias */) { markAliasSymbolAsReferenced(reactSym); } } @@ -50388,7 +53495,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 152 /* QualifiedName */ ? node.right : node.kind === 187 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* 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)); @@ -50486,12 +53593,11 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); + } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (strictNullChecks && type.flags & 2 /* Unknown */) { @@ -50523,14 +53629,13 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + var _a = checkOptionalExpression(node, left), isOptional = _a.isOptional, leftType = _a.type; var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -50544,6 +53649,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0 /* String */) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -50571,9 +53677,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 103 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -50582,14 +53688,14 @@ var ts; } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return propagateOptionalTypeMarker(getFlowTypeOfAccessExpression(node, prop, propType, right), isOptional); } function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { // 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. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 194 /* ElementAccessExpression */ && node.kind !== 193 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -50599,11 +53705,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 && node.expression.kind === 101 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -50624,7 +53730,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -50634,9 +53740,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && - !(valueDeclaration.flags & 4194304 /* Ambient */) && + else if (valueDeclaration.kind === 244 /* ClassDeclaration */ && + node.parent.kind !== 168 /* TypeReference */ && + !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -50647,22 +53753,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 279 /* PropertyAssignment */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 281 /* SpreadAssignment */: + case 153 /* ComputedPropertyName */: + case 220 /* TemplateSpan */: + case 274 /* JsxExpression */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 266 /* JsxOpeningElement */: + case 215 /* ExpressionWithTypeArguments */: + case 277 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -50702,7 +53808,7 @@ var ts; 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)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -50740,7 +53846,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415 /* Value */); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -50835,16 +53941,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 101 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 152 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 187 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 /* PropertyAccessExpression */ && node.expression.kind === 101 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -50861,13 +53967,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 242 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73 /* Identifier */) { + else if (initializer.kind === 75 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -50884,13 +53990,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73 /* Identifier */) { + if (e.kind === 75 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 230 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -50904,28 +54010,14 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + var _a = checkOptionalExpression(node, node.expression), isOptional = _a.isOptional, exprType = _a.type; var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* 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); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -50934,7 +54026,7 @@ var ts; 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); + return propagateOptionalTypeMarker(checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node), isOptional); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === errorType) { @@ -50980,13 +54072,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 156 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51005,7 +54097,7 @@ var ts; // interface B extends A { (x: 'foo'): string } // const b: B; // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -51013,8 +54105,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -51046,11 +54138,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? createOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 212 /* SpreadElement */ || arg.kind === 219 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51064,9 +54156,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 210 /* 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. @@ -51081,7 +54173,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 156 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51096,7 +54188,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 196 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51189,7 +54281,7 @@ var ts; // 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 !== 153 /* Decorator */) { + if (node.kind !== 156 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51219,7 +54311,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -51232,7 +54324,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51256,7 +54348,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 219 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51331,12 +54423,12 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 196 /* 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. @@ -51346,7 +54438,7 @@ var ts; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -51354,7 +54446,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -51364,7 +54456,7 @@ var ts; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -51374,7 +54466,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -51395,15 +54487,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 193 /* PropertyAccessExpression */ || callee.kind === 194 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(219 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51413,17 +54505,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 156 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51438,7 +54530,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, /*isSpread*/ i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -51453,30 +54545,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* 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 152 /* Parameter */: + case 155 /* 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 === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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 !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 158 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51490,17 +54582,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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 152 /* Parameter */: + case 155 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -51538,8 +54630,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -51608,8 +54700,8 @@ var ts; // Overloads exist var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -51624,22 +54716,22 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 156 /* 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 !== 99 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -51688,7 +54780,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 195 /* 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 @@ -51741,7 +54833,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -51759,7 +54851,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -51893,7 +54985,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { + var _loop_15 = function (i) { var symbols = ts.mapDefined(candidates, function (_a) { var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; return hasRestParameter ? @@ -51904,7 +54996,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); var hasRestParameter = restParameterSymbols.length !== 0; @@ -51982,7 +55074,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -51997,12 +55089,12 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var _b = checkOptionalExpression(node, node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined), isOptional = _b.isOptional, funcType = _b.type; if (funcType === silentNeverType) { return silentNeverSignature; } @@ -52068,7 +55160,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -52131,7 +55223,7 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time @@ -52139,7 +55231,7 @@ var ts; // operation is Any. It is an error to have a Void this type. var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -52224,8 +55316,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var constituent = types_16[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52316,23 +55408,23 @@ var ts; invocationError(node.tag, apparentType, 0 /* Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52369,16 +55461,16 @@ var ts; invocationErrorRecovery(apparentType, 0 /* Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, 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(121 /* AnyKeyword */)); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* 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(124 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -52409,7 +55501,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -52425,16 +55517,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 156 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52485,57 +55577,52 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); - } - return false; - } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 193 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -52550,15 +55637,15 @@ var ts; // returns a function type. We defer checking and return nonInferrableType. return nonInferrableType; } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 196 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 161 /* Constructor */ && + declaration.kind !== 165 /* ConstructSignature */ && + declaration.kind !== 170 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -52578,18 +55665,28 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 /* CallExpression */ && node.parent.kind === 225 /* ExpressionStatement */ && + returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -52606,7 +55703,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -52627,7 +55724,7 @@ var ts; // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -52666,7 +55763,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -52675,19 +55772,20 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 243 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 241 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 4194304 /* Ambient */); + return !!decl && !!(decl.flags & 8388608 /* Ambient */); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 131072 /* MakeTemplateObject */); } @@ -52702,20 +55800,20 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || + op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -52751,10 +55849,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96 /* NewKeyword */) { + if (node.keywordToken === 98 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93 /* ImportKeyword */) { + if (node.keywordToken === 95 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -52765,7 +55863,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 === 158 /* Constructor */) { + else if (container.kind === 161 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -52775,11 +55873,11 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 /* ESNext */ || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -52821,7 +55919,7 @@ var ts; // otherwise would return the type 'undefined'). var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -52853,7 +55951,7 @@ var ts; if (signature.hasRestParameter) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; @@ -52951,7 +56049,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 === 73 /* Identifier */) { + if (element.name.kind === 75 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -52965,8 +56063,8 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73 /* Identifier */) { - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + if (decl.name.kind !== 75 /* Identifier */) { + // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -53020,7 +56118,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 222 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -53092,7 +56190,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -53203,17 +56301,18 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200 /* TypeOfExpression */) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203 /* 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 & 131072 /* Never */); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -53226,13 +56325,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128 /* HasImplicitReturn */)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */ function checkAndAggregateReturnExpressionTypes(func, checkMode) { @@ -53272,11 +56365,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 160 /* MethodDeclaration */: + return func.parent.kind === 192 /* ObjectLiteralExpression */; default: return false; } @@ -53302,10 +56395,10 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 159 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 222 /* Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; if (type && type.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -53335,7 +56428,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -53355,7 +56448,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 200 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53409,7 +56502,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53422,7 +56515,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 222 /* Block */) { checkSourceElement(node.body); } else { @@ -53503,11 +56596,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && - expr.expression.kind === 101 /* ThisKeyword */) { + (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) && + expr.expression.kind === 103 /* 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 === 158 /* Constructor */)) { + if (!(func && func.kind === 161 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -53520,31 +56613,35 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 255 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 75 /* Identifier */ && node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32 /* OptionalChain */) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 193 /* PropertyAccessExpression */ && expr.kind !== 194 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -53566,14 +56663,14 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 16384 /* AwaitContext */)) { + if (!(node.flags & 32768 /* AwaitContext */)) { // use of 'await' in non-async function var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -53586,7 +56683,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) { + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -53596,14 +56697,14 @@ var ts; switch (node.operand.kind) { case 8 /* NumericLiteral */: switch (node.operator) { - case 39 /* MinusToken */: + case 40 /* MinusToken */: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38 /* PlusToken */: + case 39 /* PlusToken */: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9 /* BigIntLiteral */: - if (node.operator === 39 /* MinusToken */) { + if (node.operator === 40 /* MinusToken */) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -53611,32 +56712,32 @@ var ts; } } switch (node.operator) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38 /* PlusToken */) { + if (node.operator === 39 /* 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)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 45 /* PlusPlusToken */: + case 46 /* 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -53650,7 +56751,7 @@ var ts; 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -53671,8 +56772,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -53761,7 +56862,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */ || property.kind === 280 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -53774,9 +56875,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 281 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -53819,8 +56920,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 214 /* OmittedExpression */) { + if (element.kind !== 212 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -53838,7 +56939,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 208 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -53854,7 +56955,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 280 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -53870,24 +56971,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 208 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 192 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 191 /* 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 === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 281 /* 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)) { + var optionalError = target.parent.kind === 281 /* SpreadAssignment */ ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -53903,53 +57007,53 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 145 /* UndefinedKeyword */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 203 /* TypeOfExpression */: + case 217 /* NonNullExpression */: + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 52 /* ExclamationToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 53 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 204 /* VoidExpression */: // Explicit opt-out + case 198 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 216 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -53961,15 +57065,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60 /* QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); + if (operator === 62 /* EqualsToken */ && (left.kind === 192 /* ObjectLiteralExpression */ || left.kind === 191 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103 /* ThisKeyword */); } var leftType; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -53977,28 +57093,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40 /* AsteriskToken */: - case 41 /* AsteriskAsteriskToken */: - case 63 /* AsteriskEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 43 /* PercentToken */: - case 66 /* PercentEqualsToken */: - case 39 /* MinusToken */: - case 62 /* MinusEqualsToken */: - case 46 /* LessThanLessThanToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: + case 41 /* AsteriskToken */: + case 42 /* AsteriskAsteriskToken */: + case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 44 /* PercentToken */: + case 68 /* PercentEqualsToken */: + case 40 /* MinusToken */: + case 64 /* MinusEqualsToken */: + case 47 /* LessThanLessThanToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54025,17 +57141,17 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); } resultType_1 = bigintType; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54043,8 +57159,8 @@ var ts; } return resultType_1; } - case 38 /* PlusToken */: - case 61 /* PlusEqualsToken */: + case 39 /* PlusToken */: + case 63 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54077,24 +57193,24 @@ var ts; } if (!resultType) { // Types that have a reasonably good chance of being a valid operand type. - // If both types have an awaited type of one of these, we’ll assume the user + // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61 /* PlusEqualsToken */) { + if (operator === 63 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -54103,25 +57219,29 @@ var ts; }); } return booleanType; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 60 /* EqualsToken */: + case 60 /* QuestionQuestionToken */: + return getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + leftType; + case 62 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -54148,6 +57268,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54155,7 +57278,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -54165,7 +57288,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 75 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -54180,15 +57303,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - return 55 /* BarBarToken */; - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - return 36 /* ExclamationEqualsEqualsToken */; - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: - return 54 /* AmpersandAmpersandToken */; + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + return 56 /* BarBarToken */; + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + return 37 /* ExclamationEqualsEqualsToken */; + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: + return 55 /* AmpersandAmpersandToken */; default: return undefined; } @@ -54201,7 +57324,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non-compound operation to be assignable to the type of VarExpr. - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); @@ -54235,17 +57358,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; + } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54253,12 +57382,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: typeName = "false"; break; - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -54267,6 +57396,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54285,7 +57425,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -54334,12 +57474,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2 /* Next */, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -54361,7 +57496,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 /* 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; @@ -54400,12 +57535,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 198 /* TypeAssertionExpression */ || node.kind === 216 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54427,10 +57562,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54482,7 +57617,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54493,7 +57628,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54505,8 +57640,8 @@ var ts; var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8 /* SkipGenericFunctions */) { @@ -54636,11 +57771,11 @@ 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 === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + var _a = checkOptionalExpression(expr, expr.expression), isOptional = _a.isOptional, funcType = _a.type; var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -54686,17 +57821,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 261 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 8388608 /* Ambient */)); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304 /* Ambient */) { + if (constEnumDeclaration.flags & 8388608 /* Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -54709,14 +57845,25 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { - case 73 /* Identifier */: + var kind = node.kind; + if (cancellationToken) { + // 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 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 75 /* Identifier */: return checkIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return checkThisExpression(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkSuperExpression(node); - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -54727,82 +57874,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: return trueType; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: - if (node.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (node.expression.kind === 95 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 196 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 219 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -54839,7 +57986,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -54850,10 +57997,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 === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 161 /* Constructor */ || func.kind === 165 /* ConstructSignature */ || func.kind === 170 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -54877,7 +58024,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -54886,9 +58033,11 @@ var ts; error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, - /*headMessage*/ undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, + /*headMessage*/ undefined, leadingError); + } } } else if (parameterName) { @@ -54909,13 +58058,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 201 /* ArrowFunction */: + case 164 /* CallSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 169 /* FunctionType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -54929,11 +58078,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 75 /* 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 === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 189 /* ArrayBindingPattern */ || name.kind === 188 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -54942,13 +58091,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* 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 === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 169 /* FunctionType */ || node.kind === 243 /* FunctionDeclaration */ || node.kind === 170 /* ConstructorType */ || + node.kind === 164 /* CallSignature */ || node.kind === 161 /* Constructor */ || + node.kind === 165 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -54978,10 +58127,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55011,28 +58160,21 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 166 /* IndexSignature */ && node.kind !== 298 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } } function checkClassForDuplicateDeclarations(node) { - var Declaration; - (function (Declaration) { - Declaration[Declaration["Getter"] = 1] = "Getter"; - Declaration[Declaration["Setter"] = 2] = "Setter"; - Declaration[Declaration["Method"] = 4] = "Method"; - Declaration[Declaration["Property"] = 3] = "Property"; - })(Declaration || (Declaration = {})); var instanceNames = ts.createUnderscoreEscapedMap(); var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 161 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* Property */); + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { + addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } } @@ -55043,17 +58185,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: - addName(names, name, memberName, 1 /* Getter */); + case 162 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: - addName(names, name, memberName, 2 /* Setter */); + case 163 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* Property */); + case 158 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: - addName(names, name, memberName, 4 /* Method */); + case 160 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */); break; } } @@ -55062,8 +58204,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4 /* Method */) { - if (meaning !== 4 /* Method */) { + if (prev & 8 /* Method */) { + if (meaning !== 8 /* Method */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -55115,7 +58257,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 157 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55123,7 +58265,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 73 /* Identifier */: + case 75 /* Identifier */: memberName = ts.idText(name); break; default: @@ -55140,7 +58282,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* 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 @@ -55160,7 +58302,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -55168,7 +58310,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -55195,7 +58337,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 === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 160 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55220,7 +58362,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55248,9 +58390,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55275,9 +58417,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { - if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { - if (!(node.flags & 256 /* HasExplicitReturn */)) { + if (node.kind === 162 /* GetAccessor */) { + if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { + if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -55285,13 +58427,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* 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 === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55309,7 +58451,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55357,19 +58499,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { @@ -55405,16 +58544,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 176 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 175 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55435,7 +58574,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 /* 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)); } @@ -55486,7 +58625,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 /* 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); @@ -55497,16 +58636,16 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 4194304 /* Ambient */); + return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && - n.flags & 4194304 /* Ambient */) { + if (n.parent.kind !== 245 /* InterfaceDeclaration */ && + n.parent.kind !== 244 /* ClassDeclaration */ && + n.parent.kind !== 213 /* ClassExpression */ && + n.flags & 8388608 /* 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 flags |= 1 /* Export */; @@ -55596,7 +58735,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 === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* 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 @@ -55631,11 +58770,12 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent.kind === 245 /* InterfaceDeclaration */ || node.parent.kind === 172 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -55646,7 +58786,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if ((node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 243 /* FunctionDeclaration */ || node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */ || node.kind === 161 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -55687,6 +58830,15 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { + // A non-ambient class cannot be an implementation for a non-constructor function/class merge + // TODO: The below just replicates our older error from when classes and functions were + // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" + // might be warranted. :shrug: + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { @@ -55698,8 +58850,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -55708,13 +58860,6 @@ var ts; } } } - var DeclarationSpaces; - (function (DeclarationSpaces) { - DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; - DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; - DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; - DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; - })(DeclarationSpaces || (DeclarationSpaces = {})); function checkExportsOnMergedDeclarations(node) { if (!produceDiagnostics) { return; @@ -55775,40 +58920,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 258 /* 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 */; } 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 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 243 /* FunctionDeclaration */: + case 257 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -55842,7 +58989,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { @@ -55877,9 +59024,6 @@ var ts; */ function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3 /* AnyOrUnknown */)) { - addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -56038,10 +59182,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 75 /* 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 { @@ -56061,7 +59205,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -56080,24 +59224,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 155 /* 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 155 /* PropertyDeclaration */: + case 158 /* 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 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56118,7 +59262,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 75 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56143,29 +59287,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var typeNode = types_18[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* 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); @@ -56211,14 +59355,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* 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 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56227,23 +59371,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 160 /* 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 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 155 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56306,7 +59450,7 @@ var ts; 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 === 149 /* 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 === 152 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56339,9 +59483,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56354,7 +59498,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 === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56370,7 +59514,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -56383,7 +59527,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 159 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56409,7 +59553,7 @@ var ts; } function registerForUnusedIdentifiersCheck(node) { // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`. - if (produceDiagnostics && !(node.flags & 4194304 /* Ambient */)) { + if (produceDiagnostics && !(node.flags & 8388608 /* Ambient */)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -56425,42 +59569,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 288 /* SourceFile */: + case 248 /* ModuleDeclaration */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 180 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56480,11 +59624,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 160 /* MethodDeclaration */: + case 158 /* PropertyDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + if (member.kind === 163 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56493,7 +59637,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 158 /* Constructor */: + case 161 /* 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 */)) { @@ -56501,8 +59645,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 166 /* IndexSignature */: + case 221 /* SemicolonClassElement */: // Can't be private break; default: @@ -56529,7 +59673,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -56564,7 +59708,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304 /* Ambient */) + if (nodeWithLocals.flags & 8388608 /* Ambient */) return; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); @@ -56599,7 +59743,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -56614,7 +59758,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -56632,7 +59776,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 === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 242 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -56653,7 +59797,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -56665,24 +59809,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 254 /* ImportClause */ || node.kind === 257 /* ImportSpecifier */ || node.kind === 255 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 254 /* ImportClause */ ? decl : decl.kind === 255 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 222 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -56699,7 +59843,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -56712,21 +59856,21 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 158 /* PropertyDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 160 /* MethodDeclaration */ || + node.kind === 159 /* MethodSignature */ || + node.kind === 162 /* GetAccessor */ || + node.kind === 163 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // ambient context - no codegen impact return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -56736,7 +59880,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 73 /* Identifier */; + var isDeclaration_1 = node.kind !== 75 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -56751,7 +59895,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 73 /* Identifier */; + var isDeclaration_2 = node.kind !== 75 /* 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); } @@ -56777,7 +59921,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 /* 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)); } @@ -56792,7 +59936,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* 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)); } @@ -56827,7 +59971,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 === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 241 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -56839,17 +59983,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 224 /* 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 === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 222 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 249 /* ModuleBlock */ || + container.kind === 248 /* ModuleDeclaration */ || + container.kind === 288 /* 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 @@ -56879,18 +60023,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 190 /* BindingElement */) { + if (node.parent.kind === 188 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -56904,26 +60048,26 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 /* 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 === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 /* 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)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -56960,7 +60104,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -56986,10 +60130,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -56998,7 +60142,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 158 /* PropertyDeclaration */ || nextDeclaration.kind === 157 /* PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -57008,8 +60152,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 155 /* Parameter */ && right.kind === 241 /* VariableDeclaration */) || + (left.kind === 241 /* VariableDeclaration */ && right.kind === 155 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57046,13 +60190,56 @@ var ts; function checkIfStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 223 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + // While it technically should be invalid for any known-truthy value + // to be tested, we de-scope to functions unrefenced in the block as a + // heuristic to identify the most common bugs. There are too many + // false positives for values sourced from type definitions without + // strictNullChecks otherwise. + var callSignatures = getSignaturesOfType(type, 0 /* Call */); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -57075,12 +60262,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 242 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57114,14 +60301,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* 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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* 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. @@ -57129,7 +60316,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -57153,7 +60340,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* 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); @@ -57167,7 +60354,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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* 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)) { @@ -57175,7 +60362,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved @@ -57528,7 +60715,7 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use @@ -57540,7 +60727,7 @@ var ts; // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -57619,7 +60806,7 @@ var ts; // - `Generator` or `AsyncGenerator` var globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `IterableIterator` and `AsyncIterableIterator` are defined by the // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. @@ -57630,7 +60817,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(/*reportErrors*/ false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -57666,11 +60853,11 @@ var ts; // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` // or `IteratorReturnResult` types, then just grab its type argument. if (isReferenceToType(type, getGlobalIteratorYieldResultType(/*reportErrors*/ false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, /*returnType*/ undefined, /*nextType*/ undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(/*reportErrors*/ false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(/*yieldType*/ undefined, returnType_1, /*nextType*/ undefined); } // Choose any constituents that can produce the requested iteration type. @@ -57734,11 +60921,13 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + // The value of `next(value)` is *not* awaited by async generators + nextType = methodParameterType; } else if (methodName === "return") { + // The value of `return(value)` *is* awaited by async generators + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -57831,12 +61020,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160 /* SetAccessor */) { + if (func.kind === 163 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 161 /* 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); } @@ -57854,7 +61043,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -57862,7 +61051,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384 /* AwaitContext */) { + if (node.flags & 32768 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -57883,7 +61072,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 === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 276 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -57895,7 +61084,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 275 /* 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. @@ -57924,7 +61113,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58031,8 +61220,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 === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 208 /* BinaryExpression */ || + name.kind === 153 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58109,7 +61298,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 168 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58169,11 +61358,10 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - // relax check if later interface augmentation has no constraint - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + // relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with + // a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill) + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } // If the type parameter node has a default and it is not identical to the default // for the type parameter at this position, we report an error. @@ -58210,7 +61398,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassNameCollisionWithObject(node.name); } } @@ -58223,11 +61411,12 @@ var ts; checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } @@ -58265,12 +61454,9 @@ var ts; } 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 - // that the base type is a class or interface type (and not, for example, an anonymous object type). - // (Javascript constructor functions have this property trivially true since their return type is ignored.) + // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -58313,7 +61499,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -58332,7 +61518,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -58358,7 +61544,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 244 /* ClassDeclaration */ || d.kind === 245 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58377,7 +61563,7 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304 /* Prototype */) { @@ -58386,53 +61572,104 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overridden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 210 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + // In order to resolve whether the inherited method was overridden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { + // Searches other base types for a declaration that would satisfy the inherited abstract member. + // (The class may have more than one base type via declaration merging with an interface with the + // same name.) + for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { + var otherBaseType = _b[_a]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } + if (derivedClassDecl.kind === 213 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } - else { - // derived overrides base. - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { - // either base or derived property is private - not override, skip it + } + else { + // derived overrides base. + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + // either base or derived property is private - not override, skip it + continue; + } + var errorMessage = void 0; + var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + if (basePropertyFlags && derivedPropertyFlags) { + // property/accessor is overridden with property/accessor + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 /* InterfaceDeclaration */ + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { + // when the base property is abstract or from an interface, base/derived flags don't need to match + // same when the derived property is from an assignment continue; } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; + if (basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + else if (basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 /* PropertyDeclaration */ && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432 /* Transient */) + && !(baseDeclarationFlags & 128 /* Abstract */) + && !(derivedDeclarationFlags & 128 /* Abstract */) + && !derived.declarations.some(function (d) { return d.flags & 8388608 /* Ambient */; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } } + // correct case + continue; + } + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived)) { + // method is overridden with method -- correct case + continue; } - else if (base.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + else if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -58469,12 +61706,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2 /* Ambient */) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -58489,7 +61729,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -58513,7 +61753,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -58576,7 +61816,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -58608,7 +61848,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304 /* Ambient */) { + else if (member.parent.flags & 8388608 /* Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -58618,66 +61858,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38 /* PlusToken */: return value_2; - case 39 /* MinusToken */: return -value_2; - case 53 /* TildeToken */: return ~value_2; + case 39 /* PlusToken */: return value_2; + case 40 /* MinusToken */: return -value_2; + case 54 /* TildeToken */: return ~value_2; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - 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); + case 51 /* BarToken */: return left | right; + case 50 /* AmpersandToken */: return left & right; + case 48 /* GreaterThanGreaterThanToken */: return left >> right; + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* LessThanLessThanToken */: return left << right; + case 52 /* CaretToken */: return left ^ right; + case 41 /* AsteriskToken */: return left * right; + case 43 /* SlashToken */: return left / right; + case 39 /* PlusToken */: return left + right; + case 40 /* MinusToken */: return left - right; + case 44 /* PercentToken */: return left % right; + case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { return left + right; } break; case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 73 /* Identifier */: + case 75 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* 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 === 190 /* PropertyAccessExpression */) { + if (ex.kind === 193 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -58702,10 +61941,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10 /* StringLiteral */; + return node.kind === 75 /* Identifier */ || + node.kind === 193 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 194 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -58739,7 +61978,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 !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 247 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -58762,9 +62001,9 @@ 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 === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304 /* Ambient */)) { + if ((declaration.kind === 244 /* ClassDeclaration */ || + (declaration.kind === 243 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } } @@ -58787,7 +62026,7 @@ var ts; if (produceDiagnostics) { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304 /* Ambient */; + var inAmbientContext = node.flags & 8388608 /* Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -58826,7 +62065,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, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 244 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -58876,23 +62115,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* 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 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 241 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -58903,12 +62142,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -58929,17 +62168,36 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); + return node; + } + } + function getFirstNonModuleExportsIdentifier(node) { + switch (node.kind) { + case 75 /* Identifier */: + return node; + case 152 /* QualifiedName */: + do { + node = node.left; + } while (node.kind !== 75 /* Identifier */); + return node; + case 193 /* PropertyAccessExpression */: + do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } + node = node.expression; + } while (node.kind !== 75 /* Identifier */); return node; } } @@ -58953,9 +62211,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -58977,27 +62235,29 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - // For external modules symbol represent local symbol for an alias. + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864 /* Assignment */; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + // For external modules symbol represents local symbol for an alias. // This local symbol will merge any other local declarations (excluding other aliases) // and symbol.flags will contains combined representation for all merged declaration. // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). - var excludedMeanings = (symbol.flags & (67220415 /* Value */ | 1048576 /* ExportValue */) ? 67220415 /* Value */ : 0) | - (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | + symbol = getMergedSymbol(symbol.exportSymbol || symbol); + var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | + (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 261 /* 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 === 258 /* ExportSpecifier */ - && !(target.flags & 67220415 /* Value */) - && !(node.flags & 4194304 /* Ambient */)) { + && node.kind === 261 /* ExportSpecifier */ + && !(target.flags & 111551 /* Value */) + && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -59022,7 +62282,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59046,23 +62306,23 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 263 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415 /* Value */) { + if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832 /* Type */) { + if (target.flags & 788968 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608 /* Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -59082,10 +62342,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 /* ModuleBlock */ && + !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59102,7 +62362,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 288 /* SourceFile */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 248 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59116,13 +62376,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -59131,8 +62395,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 === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59145,8 +62409,18 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73 /* Identifier */) { - markExportAsReferenced(node); + if (node.expression.kind === 75 /* Identifier */) { + var id = node.expression; + var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + if (sym) { + markAliasReferenced(sym, id); + // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) + var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // However if it is a value, we need to check it's being used correctly + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); } @@ -59155,10 +62429,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -59184,9 +62458,9 @@ var ts; } } // Checks for export * conflicts - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -59215,14 +62489,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -59244,158 +62510,162 @@ 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 /* FirstStatement */ && kind <= 240 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 181 /* ParenthesizedType */: + case 175 /* OptionalType */: + case 176 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 182 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return checkImportType(node); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 306 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 298 /* JSDocTypeLiteral */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: + case 302 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 292 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 223 /* EmptyStatement */: + case 240 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -59490,23 +62760,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 264 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -59535,7 +62805,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } // Grammar checking @@ -59621,7 +62891,7 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608 /* InWithStatement */) { + if (location.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } @@ -59636,35 +62906,35 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // 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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -59706,17 +62976,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 /* Identifier */ && + return name.kind === 75 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 154 /* TypeParameter */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -59724,16 +62994,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 168 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 193 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 215 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -59761,13 +63031,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 152 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 252 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 258 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -59793,7 +63063,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 187 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -59803,7 +63073,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 193 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -59811,17 +63081,17 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 258 /* 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); + /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } 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, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 252 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -59839,11 +63109,11 @@ 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 === 212 /* ExpressionWithTypeArguments */) { - meaning = 67897832 /* Type */; + if (entityName.parent.kind === 215 /* ExpressionWithTypeArguments */) { + meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415 /* Value */; + meaning |= 111551 /* Value */; } } else { @@ -59855,10 +63125,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306 /* JSDocParameterTag */) { + if (entityName.parent.kind === 310 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 310 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 154 /* TypeParameter */ && entityName.parent.parent.kind === 314 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -59868,19 +63138,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 73 /* Identifier */) { + if (entityName.kind === 75 /* 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); + return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 193 /* PropertyAccessExpression */ || entityName.kind === 152 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 193 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -59890,22 +63160,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 168 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 167 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -59919,12 +63189,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 190 /* BindingElement */ && + grandParent.kind === 188 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -59934,11 +63204,11 @@ var ts; } } switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -59950,14 +63220,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 182 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkExpression(node).symbol; - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 161 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -59968,7 +63238,7 @@ var ts; // 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 === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 /* ImportDeclaration */ || node.parent.kind === 259 /* 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); @@ -59985,22 +63255,22 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81 /* DefaultKeyword */: - case 91 /* FunctionKeyword */: - case 37 /* EqualsGreaterThanToken */: - case 77 /* ClassKeyword */: + case 83 /* DefaultKeyword */: + case 93 /* FunctionKeyword */: + case 38 /* EqualsGreaterThanToken */: + case 79 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 280 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; } @@ -60008,10 +63278,10 @@ var ts; function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -60067,27 +63337,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 192 /* ObjectLiteralExpression */ || expr.kind === 191 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 231 /* 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 === 205 /* BinaryExpression */) { + if (expr.parent.kind === 208 /* 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 === 276 /* PropertyAssignment */) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60126,17 +63396,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } // Return the list of properties of the given type, augmented with properties from Function @@ -60188,7 +63457,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60209,13 +63478,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415 /* Value */); + return s && !!(s.flags & 111551 /* Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -60244,7 +63513,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 288 /* 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. @@ -60264,7 +63533,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -60272,7 +63541,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60281,7 +63550,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -60303,7 +63572,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 === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 222 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60344,26 +63613,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258 /* ExportAssignment */: + return node.expression && node.expression.kind === 75 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60377,7 +63645,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 67220415 /* Value */) && + return !!(target.flags & 111551 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -60391,7 +63659,7 @@ var ts; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && - target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -60445,7 +63713,7 @@ var ts; if (!symbol || !(symbol.flags & 16 /* Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 /* Value */ && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -60464,15 +63732,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 282 /* EnumMember */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 282 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -60499,9 +63767,9 @@ var ts; return ts.TypeReferenceSerializationKind.Unknown; } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 67220415 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 67897832 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -60557,7 +63825,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -60576,7 +63844,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -60584,7 +63852,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -60606,7 +63874,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -60627,7 +63895,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -60708,12 +63976,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 === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 163 /* SetAccessor */ ? 162 /* GetAccessor */ : 163 /* 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 === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -60726,10 +63994,19 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 215 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 277 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -60740,9 +64017,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* Type */ | 1920 /* Namespace */; + if ((node.kind === 75 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 193 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -60792,7 +64069,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -60820,12 +64097,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 /* 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, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 288 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -60958,16 +64235,16 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1 /* FirstEmitHelper */; helper <= 131072 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -61014,14 +64291,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 /* 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 === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* 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); @@ -61038,23 +64315,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 !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (modifier.kind !== 137 /* ReadonlyKeyword */) { + if (node.kind === 157 /* PropertySignature */ || node.kind === 159 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); + case 80 /* ConstKeyword */: + if (node.kind !== 247 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80 /* ConstKeyword */)); } break; - case 116 /* PublicKeyword */: - case 115 /* ProtectedKeyword */: - case 114 /* PrivateKeyword */: + case 118 /* PublicKeyword */: + case 117 /* ProtectedKeyword */: + case 116 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -61068,11 +64345,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* 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 === 114 /* PrivateKeyword */) { + if (modifier.kind === 116 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -61081,7 +64358,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -61091,10 +64368,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61103,18 +64380,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */ && node.kind !== 166 /* IndexSignature */ && node.kind !== 155 /* 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 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -61127,52 +64404,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 === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 83 /* DefaultKeyword */: + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* 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 126 /* DeclareKeyword */: + case 129 /* 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 === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 249 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 119 /* AbstractKeyword */: + case 121 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 244 /* ClassDeclaration */) { + if (node.kind !== 160 /* MethodDeclaration */ && + node.kind !== 158 /* PropertyDeclaration */ && + node.kind !== 162 /* GetAccessor */ && + node.kind !== 163 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 244 /* 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 */) { @@ -61184,14 +64461,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 122 /* AsyncKeyword */: + case 125 /* 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 */) { + else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61199,7 +64476,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61214,13 +64491,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 253 /* ImportDeclaration */ || node.kind === 252 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 /* 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 === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 155 /* 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 */) { @@ -61241,38 +64518,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 248 /* ModuleDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 155 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 125 /* AsyncKeyword */); + case 244 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AbstractKeyword */); + case 245 /* InterfaceDeclaration */: + case 224 /* VariableStatement */: + case 246 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); + case 247 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 80 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -61284,10 +64561,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61316,7 +64593,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -61350,7 +64627,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -61402,7 +64679,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 /* StringKeyword */ && parameter.type.kind !== 136 /* NumberKeyword */) { + if (parameter.type.kind !== 142 /* StringKeyword */ && parameter.type.kind !== 139 /* 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(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -61434,11 +64711,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211 /* OmittedExpression */) { + if (arg.kind === 214 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61468,7 +64751,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 === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -61481,7 +64764,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -61497,14 +64780,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -61515,21 +64798,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 153 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 208 /* 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 === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); - if (node.flags & 4194304 /* Ambient */) { + ts.Debug.assert(node.kind === 243 /* FunctionDeclaration */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 160 /* MethodDeclaration */); + if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -61544,17 +64827,10 @@ var ts; return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var Flags; - (function (Flags) { - Flags[Flags["Property"] = 1] = "Property"; - Flags[Flags["GetAccessor"] = 2] = "GetAccessor"; - Flags[Flags["SetAccessor"] = 4] = "SetAccessor"; - Flags[Flags["GetOrSetAccessor"] = 6] = "GetOrSetAccessor"; - })(Flags || (Flags = {})); var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 281 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -61565,20 +64841,21 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 /* 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); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 125 /* AsyncKeyword */ || prop.kind !== 160 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -61593,24 +64870,25 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 279 /* 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 157 /* MethodDeclaration */: - currentKind = 1 /* Property */; + currentKind = 4 /* PropertyAssignment */; + break; + case 160 /* MethodDeclaration */: + currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: - currentKind = 2 /* GetAccessor */; + case 162 /* GetAccessor */: + currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: - currentKind = 4 /* SetAccessor */; + case 163 /* SetAccessor */: + currentKind = 2 /* SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -61624,11 +64902,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + if ((currentKind & 12 /* PropertyAssignmentOrMethod */) && (existingKind & 12 /* PropertyAssignmentOrMethod */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6 /* GetOrSetAccessor */) && (existingKind & 6 /* GetOrSetAccessor */)) { - if (existingKind !== 6 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { + if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -61646,7 +64924,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 === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 273 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -61656,7 +64934,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 274 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -61670,14 +64948,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + if (forInOrOfStatement.kind === 231 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -61688,7 +64966,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 242 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -61703,20 +64981,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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); @@ -61726,42 +65004,38 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304 /* Ambient */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 8388608 /* Ambient */)) { + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { + if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 /* GetAccessor */ ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 162 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160 /* SetAccessor */) { + if (accessor.kind === 163 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; @@ -61771,23 +65045,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 === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143 /* UniqueKeyword */) { - if (node.type.kind !== 140 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140 /* SymbolKeyword */)); + if (node.operator === 146 /* UniqueKeyword */) { + if (node.type.kind !== 143 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* 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)) { @@ -61797,13 +65071,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 158 /* 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 154 /* PropertySignature */: + case 157 /* 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); } @@ -61812,9 +65086,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); + else if (node.operator === 137 /* ReadonlyKeyword */) { + if (node.type.kind !== 173 /* ArrayType */ && node.type.kind !== 174 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143 /* SymbolKeyword */)); } } } @@ -61827,10 +65101,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 160 /* MethodDeclaration */) { + if (node.parent.kind === 192 /* 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 === 122 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -61853,17 +65127,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* 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 === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 160 /* 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 === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* 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 === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* 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); } } @@ -61874,11 +65148,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 237 /* 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 === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 232 /* 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); @@ -61886,8 +65160,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 236 /* SwitchStatement */: + if (node.kind === 233 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -61902,13 +65176,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* 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 === 230 /* BreakStatement */ + var message = node.kind === 233 /* 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); @@ -61931,13 +65205,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -61950,7 +65224,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 /* TrueKeyword */ || initializer.kind === 88 /* FalseKeyword */ || + initializer.kind === 105 /* TrueKeyword */ || initializer.kind === 90 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -61967,8 +65241,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { - if (node.flags & 4194304 /* Ambient */) { + if (node.parent.parent.kind !== 230 /* ForInStatement */ && node.parent.parent.kind !== 231 /* ForOfStatement */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -61980,11 +65254,11 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -61997,7 +65271,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -62014,8 +65288,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73 /* Identifier */) { - if (name.originalKeywordKind === 112 /* LetKeyword */) { + if (name.kind === 75 /* Identifier */) { + if (name.originalKeywordKind === 114 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -62042,15 +65316,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62068,12 +65342,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96 /* NewKeyword */: + case 98 /* 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 93 /* ImportKeyword */: + case 95 /* 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"); } @@ -62131,7 +65405,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* 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; } @@ -62139,7 +65413,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* 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; } @@ -62147,11 +65421,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { + node.flags & 8388608 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } @@ -62168,13 +65442,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 246 /* TypeAliasDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 259 /* ExportDeclaration */ || + node.kind === 258 /* ExportAssignment */ || + node.kind === 251 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62183,7 +65457,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 === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 224 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62192,17 +65466,13 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304 /* Ambient */) { - // An accessors is already reported about the ambient context - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } + if (node.flags & 8388608 /* Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } // We are either parented by another statement, or some sort of block. @@ -62210,7 +65480,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 === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 222 /* Block */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62232,20 +65502,39 @@ 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, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 186 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 282 /* 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 === 39 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62300,11 +65589,19 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 243 /* FunctionDeclaration */ && declaration.kind !== 160 /* MethodDeclaration */) || + !!declaration.body; + } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62312,21 +65609,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 254 /* ImportClause */: // For default import + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: // For rename import `x as y` return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 257 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62336,7 +65632,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62407,6 +65702,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62454,7 +65750,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73 /* Identifier */); + var node = createSynthesizedNode(75 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -62535,23 +65831,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(99 /* SuperKeyword */); + return createSynthesizedNode(101 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101 /* ThisKeyword */); + return createSynthesizedNode(103 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97 /* NullKeyword */); + return createSynthesizedNode(99 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103 /* TrueKeyword */); + return createSynthesizedNode(105 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88 /* FalseKeyword */); + return createSynthesizedNode(90 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -62562,44 +65858,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(86 /* ExportKeyword */)); + result.push(createModifier(88 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(126 /* DeclareKeyword */)); + result.push(createModifier(129 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(81 /* DefaultKeyword */)); + result.push(createModifier(83 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(78 /* ConstKeyword */)); + result.push(createModifier(80 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(116 /* PublicKeyword */)); + result.push(createModifier(118 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(114 /* PrivateKeyword */)); + result.push(createModifier(116 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(115 /* ProtectedKeyword */)); + result.push(createModifier(117 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(119 /* AbstractKeyword */)); + result.push(createModifier(121 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(117 /* StaticKeyword */)); + result.push(createModifier(119 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(134 /* ReadonlyKeyword */)); + result.push(createModifier(137 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(122 /* AsyncKeyword */)); + result.push(createModifier(125 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(152 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -62618,7 +65914,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(153 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -62631,7 +65927,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(154 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -62647,7 +65943,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(155 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -62671,7 +65967,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(156 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -62684,7 +65980,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(157 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -62704,12 +66000,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(158 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -62719,8 +66015,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -62728,7 +66024,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(159 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -62745,7 +66041,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(160 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -62758,6 +66054,38 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), + /*typeArguments*/ undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + /* @internal */ + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + /* @internal */ + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -62773,7 +66101,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(161 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -62793,7 +66121,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(162 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62816,7 +66144,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(163 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62837,7 +66165,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -62845,7 +66173,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -62853,7 +66181,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(166 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -62893,21 +66221,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167 /* TypePredicate */); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(168 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -62921,7 +66259,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(169 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -62929,7 +66267,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(170 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -62937,7 +66275,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(171 /* TypeQuery */); node.exprName = exprName; return node; } @@ -62949,7 +66287,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(172 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -62961,7 +66299,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(173 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -62973,7 +66311,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(174 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -62985,7 +66323,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(175 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -62997,7 +66335,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(176 /* RestType */); node.type = type; return node; } @@ -63009,7 +66347,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(177 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63017,7 +66355,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(178 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63036,7 +66374,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(179 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63054,7 +66392,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(180 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63066,7 +66404,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(187 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63084,7 +66422,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(181 /* ParenthesizedType */); node.type = type; return node; } @@ -63096,12 +66434,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(182 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; + var node = createSynthesizedNode(183 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -63111,7 +66449,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(184 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63125,7 +66463,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(185 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63143,7 +66481,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(186 /* LiteralType */); node.literal = literal; return node; } @@ -63156,7 +66494,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(188 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63168,7 +66506,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(189 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63180,7 +66518,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(190 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63199,7 +66537,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(191 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63213,7 +66551,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(192 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63227,7 +66565,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63235,6 +66573,7 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessChain using updatePropertyAccess. Use updatePropertyAccessChain instead."); // Because we are updating existed propertyAccess we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -63243,22 +66582,62 @@ var ts; : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072 /* NoIndentation */); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(194 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessChain using updateElementAccess. Use updateElementAccessChain instead."); return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194 /* ElementAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(195 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63266,6 +66645,7 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update a CallChain using updateCall. Use updateCallChain instead."); return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -63273,8 +66653,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195 /* CallExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(196 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63290,7 +66690,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(197 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63313,7 +66713,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(198 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63327,7 +66727,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(199 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63339,7 +66739,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(200 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63363,12 +66763,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(201 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -63385,7 +66785,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(202 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63397,7 +66797,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(203 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63409,7 +66809,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(204 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63421,7 +66821,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(205 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63433,7 +66833,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(206 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63446,7 +66846,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(207 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63459,7 +66859,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(208 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63476,11 +66876,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(209 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(58 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -63496,7 +66896,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(210 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -63509,34 +66909,93 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15 /* TemplateHead */); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + } + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15 /* TemplateHead */: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16 /* TemplateMiddle */: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17 /* TemplateTail */: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23 /* CloseBracketToken */) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15 /* TemplateHead */, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16 /* TemplateMiddle */); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16 /* TemplateMiddle */, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17 /* TemplateTail */); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17 /* TemplateTail */, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14 /* NoSubstitutionTemplateLiteral */, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -63548,7 +67007,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(212 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -63560,7 +67019,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(213 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63581,11 +67040,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(214 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(215 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -63599,7 +67058,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(216 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -63613,7 +67072,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(217 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63625,7 +67084,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(218 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -63639,7 +67098,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(220 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -63653,12 +67112,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(221 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(222 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -63672,7 +67131,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(224 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -63687,11 +67146,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(223 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(225 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -63707,7 +67166,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(226 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -63723,7 +67182,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(227 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -63737,7 +67196,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(228 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63751,7 +67210,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(229 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -63769,7 +67228,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(230 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -63785,7 +67244,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(231 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -63803,7 +67262,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(232 /* ContinueStatement */); node.label = asName(label); return node; } @@ -63815,7 +67274,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(233 /* BreakStatement */); node.label = asName(label); return node; } @@ -63827,7 +67286,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(234 /* ReturnStatement */); node.expression = expression; return node; } @@ -63839,7 +67298,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(235 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63853,7 +67312,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(236 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -63867,7 +67326,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(237 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -63881,7 +67340,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(238 /* ThrowStatement */); node.expression = expression; return node; } @@ -63893,7 +67352,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(239 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -63909,11 +67368,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(240 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(241 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -63930,7 +67389,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(242 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -63943,7 +67402,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(243 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63969,7 +67428,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(244 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63991,7 +67450,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(245 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64013,7 +67472,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(246 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64033,7 +67492,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(247 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64052,8 +67511,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); + var node = createSynthesizedNode(248 /* ModuleDeclaration */); + node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -64071,7 +67530,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(249 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64083,7 +67542,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(250 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64095,7 +67554,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(251 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64107,7 +67566,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(252 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64125,7 +67584,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(253 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64143,7 +67602,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(254 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64157,7 +67616,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(255 /* NamespaceImport */); node.name = name; return node; } @@ -64169,7 +67628,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(256 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64181,7 +67640,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(257 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64195,11 +67654,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(258 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -64212,7 +67671,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(259 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64229,8 +67688,13 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + /* @internal */ + function createEmptyExports() { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(260 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64242,7 +67706,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(261 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64257,7 +67721,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(263 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64271,14 +67735,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(292 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(313 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64286,7 +67750,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(311 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64294,14 +67758,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(312 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(310 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64311,7 +67775,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297 /* JSDocComment */); + var node = createSynthesizedNode(301 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64325,7 +67789,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(264 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64341,7 +67805,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(265 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64357,7 +67821,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(266 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64373,7 +67837,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(267 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64385,7 +67849,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(268 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64407,11 +67871,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(269 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(270 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64423,7 +67887,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(271 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -64437,7 +67901,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(272 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -64449,7 +67913,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(273 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -64461,7 +67925,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(274 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -64475,7 +67939,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(275 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -64489,7 +67953,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(276 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -64501,7 +67965,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(277 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -64514,7 +67978,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(278 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -64529,7 +67993,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(279 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -64544,7 +68008,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(280 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -64558,7 +68022,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(281 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64571,7 +68035,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(282 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -64592,7 +68056,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(288 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -64676,7 +68140,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314 /* NotEmittedStatement */); + var node = createSynthesizedNode(318 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -64688,7 +68152,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(322 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64700,7 +68164,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(321 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64715,7 +68179,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(315 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(319 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -64731,7 +68195,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316 /* CommaListExpression */) { + if (node.kind === 320 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -64741,7 +68205,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316 /* CommaListExpression */); + var node = createSynthesizedNode(320 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -64752,9 +68216,25 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + /* @internal */ + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323 /* SyntheticReferenceExpression */); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + /* @internal */ + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(289 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -64785,7 +68265,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(290 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -64867,8 +68347,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal" /* Internal */: - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } // falls through case "text" /* Text */: (texts || (texts = [])).push(createUnparsedNode(section, node)); @@ -64917,10 +68400,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 283 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 284 /* UnparsedPrepend */; + case "internal" /* Internal */: return 286 /* UnparsedInternalText */; + case "text" /* Text */: return 285 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -64938,14 +68421,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(287 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(291 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -64991,8 +68474,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65035,43 +68518,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28 /* LessThanToken */, right); + return createBinary(left, 29 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60 /* EqualsToken */, right); + return createBinary(left, 62 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 36 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 37 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38 /* PlusToken */, right); + return createBinary(left, 39 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39 /* MinusToken */, right); + return createBinary(left, 40 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44 /* PlusPlusToken */); + return createPostfix(operand, 45 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54 /* AmpersandAmpersandToken */, right); + return createBinary(left, 55 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55 /* BarBarToken */, right); + return createBinary(left, 56 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60 /* QuestionQuestionToken */, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52 /* ExclamationToken */, operand); + return createPrefix(53 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -65091,7 +68578,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -65135,7 +68625,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 === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65200,7 +68690,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -65486,9 +68975,9 @@ var ts; ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -65589,29 +69078,34 @@ var ts; } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; // Helpers - function getHelperName(name) { + /** + * Gets an identifier for the name of an *unscoped* emit helper. + */ + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); @@ -65619,24 +69113,26 @@ var ts; ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; @@ -65658,7 +69154,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); @@ -65669,7 +69165,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -65681,20 +69177,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cacheIdentifiers; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -65709,7 +69205,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99 /* SuperKeyword */) { + else if (callee.kind === 101 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -65721,7 +69217,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 193 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65734,7 +69230,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65791,14 +69287,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66076,8 +69572,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -66105,9 +69601,9 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } @@ -66124,7 +69620,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 === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 199 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66158,10 +69654,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(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 /* ArrowFunction */ && binaryOperatorPrecedence > 3) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66173,7 +69669,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 211 /* YieldExpression */) { return false; } return true; @@ -66210,7 +69706,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 38 /* PlusToken */) { + if (binaryOperator === 39 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -66245,10 +69741,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 === 40 /* AsteriskToken */ - || binaryOperator === 50 /* BarToken */ - || binaryOperator === 49 /* AmpersandToken */ - || binaryOperator === 51 /* CaretToken */; + return binaryOperator === 41 /* AsteriskToken */ + || binaryOperator === 51 /* BarToken */ + || binaryOperator === 50 /* AmpersandToken */ + || binaryOperator === 52 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -66261,22 +69757,20 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(209 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -66311,8 +69805,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: needsParens = true; } } @@ -66328,9 +69822,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66353,7 +69847,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66391,7 +69885,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66402,29 +69896,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 200 /* FunctionExpression */ || kind === 201 /* 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 === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 192 /* ObjectLiteralExpression */ || leftmostExpressionKind === 200 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 179 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -66432,9 +69926,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 171 /* TypeQuery */: + case 183 /* TypeOperator */: + case 180 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -66460,28 +69954,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 315 /* PartiallyEmittedExpression */: + case 216 /* AsExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 217 /* NonNullExpression */: + case 319 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -66490,15 +69984,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 192 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 316 /* CommaListExpression */; + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 320 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -66511,13 +70005,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 217 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -66542,7 +70036,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 217 /* NonNullExpression */) { node = node.expression; } return node; @@ -66550,11 +70044,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 315 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -66572,7 +70066,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -66597,6 +70091,60 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + // use named imports + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + // Alias the imports if the names are used somewhere in the file. + // NOTE: We don't need to care about global import collisions as this is a module. + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + // use a namespace import + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -66611,8 +70159,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -66637,10 +70185,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 253 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 259 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -66759,7 +70307,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -66771,11 +70319,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -66807,12 +70355,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 155 /* Parameter */: + case 190 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 212 /* SpreadElement */: + case 281 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -66824,7 +70372,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 190 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -66836,7 +70384,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -66848,7 +70396,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -66871,13 +70419,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -66917,11 +70465,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67044,11 +70592,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -67082,278 +70628,287 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */) || kind === 182 /* ThisType */) { return node; } switch (kind) { // Names - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 155 /* 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 153 /* Decorator */: + case 156 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 157 /* 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 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 159 /* 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 157 /* MethodDeclaration */: + case 160 /* 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 158 /* Constructor */: + case 161 /* 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 159 /* GetAccessor */: + case 162 /* 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 160 /* SetAccessor */: + case 163 /* 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 161 /* CallSignature */: + case 164 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 166 /* 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 164 /* TypePredicate */: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 167 /* TypePredicate */: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 174 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 176 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 177 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 179 /* 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 177 /* InferType */: + case 180 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 187 /* 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 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 185 /* 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 183 /* LiteralType */: + case 186 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 190 /* 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 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 200 /* 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 198 /* ArrowFunction */: + case 201 /* 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 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 209 /* 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 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 213 /* 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 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 222 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 226 /* 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 224 /* DoStatement */: + case 227 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 229 /* 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 227 /* ForInStatement */: + case 230 /* 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 228 /* ForOfStatement */: + case 231 /* 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 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 243 /* 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 241 /* ClassDeclaration */: + case 244 /* 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 242 /* InterfaceDeclaration */: + case 245 /* 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 243 /* TypeAliasDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 247 /* 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 245 /* ModuleDeclaration */: + case 248 /* 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 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 252 /* 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 250 /* ImportDeclaration */: + case 253 /* 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 251 /* ImportClause */: + case 254 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 259 /* 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 257 /* NamedExports */: + case 260 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -67395,58 +70950,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 167 /* TypePredicate */ && kind <= 186 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 314 /* NotEmittedStatement */: + case 221 /* SemicolonClassElement */: + case 223 /* EmptyStatement */: + case 214 /* OmittedExpression */: + case 240 /* DebuggerStatement */: + case 318 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 155 /* 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 153 /* Decorator */: + case 156 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 157 /* 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 155 /* PropertyDeclaration */: + case 158 /* 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 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67455,12 +71010,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 161 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67468,7 +71023,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67476,50 +71031,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 196 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -67527,123 +71082,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 201 /* 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 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 213 /* 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 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 216 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 222 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 229 /* 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 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67652,7 +71207,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67660,140 +71215,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 247 /* 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 245 /* ModuleDeclaration */: + case 248 /* 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 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* 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 250 /* ImportDeclaration */: + case 253 /* 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 251 /* ImportClause */: + case 254 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 259 /* 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 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -67866,7 +71421,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 !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 215 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -67939,19 +71494,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ 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); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68154,12 +71710,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ 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 @@ -68171,6 +71726,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -68539,7 +72095,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -68581,25 +72137,31 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 252 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -68629,13 +72191,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -68643,7 +72205,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -68663,7 +72225,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -68685,12 +72247,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -68765,7 +72323,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -68795,42 +72353,28 @@ var ts; } ts.helperString = helperString; /** - * Gets all property declarations with initializers on either the static or instance side of a class. + * Gets all the static or all the instance property declarations of a class * * @param node The class node. * @param isStatic A value indicating whether to get properties from the static or instance side of the class. */ - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.getInitializedProperties = getInitializedProperties; + ts.getProperties = getProperties; /** - * Gets a value indicating whether a class element is a static property declaration with an initializer. - * - * @param member The class element node. - */ - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); - } - ts.isStaticInitializedProperty = isStaticInitializedProperty; - /** - * Gets a value indicating whether a class element is an instance property declaration with an initializer. - * - * @param member The class element node. - */ - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); - } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; - /** - * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. + * Is a class element either a static or an instance property declaration with an initializer? * * @param member The class element node. * @param isStatic A value indicating whether the member should be a static or instance member. */ - function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ - && member.initializer !== undefined; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; + } + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -69278,6 +72822,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -69302,7 +72847,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), + return ts.createCall(ts.getUnscopedHelperName("__rest"), /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) @@ -69355,8 +72900,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -69382,14 +72927,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* 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 === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -69440,16 +72985,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 249 /* ModuleBlock */: + case 222 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -69461,7 +73006,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 === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 244 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -69504,10 +73049,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -69528,13 +73073,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -69554,11 +73099,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 259 /* ExportDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 254 /* ImportClause */ || + (node.kind === 252 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 263 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -69582,19 +73127,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -69604,7 +73149,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 86 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 88 /* ExportKeyword */) { return undefined; } return node; @@ -69621,67 +73166,71 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 124 /* BooleanKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 133 /* NeverKeyword */: - case 107 /* VoidKeyword */: - case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 137 /* ReadonlyKeyword */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 172 /* TypeLiteral */: + case 167 /* TypePredicate */: + case 154 /* TypeParameter */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 127 /* BooleanKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 136 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 143 /* SymbolKeyword */: + case 170 /* ConstructorType */: + case 169 /* FunctionType */: + case 171 /* TypeQuery */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 181 /* ParenthesizedType */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 166 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 156 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 158 /* 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 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 245 /* 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 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69691,7 +73240,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69701,35 +73250,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -69739,35 +73288,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -69805,7 +73354,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -69834,7 +73383,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1 /* Export */))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); @@ -70071,7 +73620,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -70177,12 +73726,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70335,7 +73884,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 158 /* 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() @@ -70436,13 +73985,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(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -70458,10 +74007,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 158 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -70471,7 +74020,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -70482,12 +74031,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; } return false; @@ -70504,15 +74053,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -70549,7 +74098,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 162 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -70594,69 +74143,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: - case 124 /* BooleanKeyword */: + case 167 /* TypePredicate */: + case 127 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return ts.createIdentifier("String"); - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: - if (node.operator === 134 /* ReadonlyKeyword */) { + case 183 /* TypeOperator */: + if (node.operator === 137 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 171 /* TypeQuery */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 172 /* TypeLiteral */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 182 /* ThisType */: + case 187 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70667,15 +74216,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* 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); @@ -70755,12 +74304,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73 /* Identifier */) { + if (node.left.kind === 75 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -70776,7 +74325,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* 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); @@ -70784,7 +74333,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -70868,7 +74417,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 110 /* ImplementsKeyword */) { + if (node.token === 112 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -70918,7 +74467,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -71331,12 +74880,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 === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 288 /* 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 === 244 /* EnumDeclaration */) { + if (node.kind === 247 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -71461,7 +75010,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 249 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -71507,13 +75056,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 !== 246 /* ModuleBlock */) { + if (body.kind !== 249 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -71554,7 +75103,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 255 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -71767,7 +75316,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -71775,7 +75324,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(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -71785,17 +75334,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(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(75 /* Identifier */); + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(248 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 248 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 247 /* EnumDeclaration */; } /** * Hook for node emit. @@ -71854,11 +75403,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -71896,9 +75445,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 !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 288 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 248 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 247 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -71920,9 +75469,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } return substitute; @@ -71948,18 +75498,19 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), + return ts.createCall(ts.getUnscopedHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue @@ -71967,13 +75518,14 @@ var ts; } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression @@ -71981,6 +75533,7 @@ var ts; } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -72023,7 +75576,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -72034,11 +75589,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72050,20 +75605,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72073,7 +75628,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -72106,7 +75661,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var statements = [ ts.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -72122,9 +75677,9 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -72142,9 +75697,9 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { @@ -72156,7 +75711,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -72197,8 +75752,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -72211,7 +75766,7 @@ var ts; /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, /*isStatic*/ false); + var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false); // Only generate synthetic constructor when there are property initializers to move. if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); @@ -72243,7 +75798,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -72255,7 +75810,7 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -72272,7 +75827,7 @@ var ts; * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -72309,19 +75864,29 @@ var ts; */ function transformInitializedProperty(property, receiver) { // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72341,7 +75906,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -72425,6 +75990,7 @@ var ts; var hasSuperElementAccess; /** A set of node IDs for generated super accessors (variable statements). */ var substitutedSuperAccessors = []; + var topLevel; // Save the previous transformation hooks. var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; @@ -72436,38 +76002,57 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32 /* ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 243 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -72475,27 +76060,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 222 /* Block */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 235 /* WithStatement */: + case 237 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -72696,7 +76281,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 === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 201 /* 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 @@ -72719,7 +76304,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -72746,7 +76331,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -72787,17 +76372,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -72845,23 +76430,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -72873,19 +76458,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -72945,23 +76530,24 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; - return ts.createCall(ts.getHelperName("__awaiter"), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -72995,9 +76581,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; /** Keeps track of property names accessed on super (`super.x`) within async functions. */ var capturedSuperProperties; /** Whether the async function contains an element access on super (`super[x]`). */ @@ -73009,6 +76597,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -73020,68 +76610,85 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122 /* AsyncKeyword */) { + if (node.kind === 125 /* AsyncKeyword */) { return undefined; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 238 /* VariableDeclaration */: + case 224 /* VariableStatement */: + return visitVariableStatement(node); + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: - return visitConstructorDeclaration(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - return visitGetAccessorDeclaration(node); - case 160 /* SetAccessor */: - return visitSetAccessorDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + return doOutsideOfTopLevel(visitConstructorDeclaration, node); + case 160 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 162 /* GetAccessor */: + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 163 /* SetAccessor */: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 243 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -73114,7 +76721,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 231 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73126,7 +76733,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 === 278 /* SpreadAssignment */) { + if (e.kind === 281 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73135,7 +76742,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 279 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73169,7 +76776,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 192 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -73214,23 +76821,44 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a VariableDeclaration node with a binding pattern. * * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false); + } + function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. if (ts.isBindingPattern(node.name) && node.name.transformFlags & 8192 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */); + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -73445,10 +77073,10 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); @@ -73514,17 +77142,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -73572,23 +77200,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -73600,19 +77228,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73628,65 +77256,69 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), + return ts.createCall(ts.getUnscopedHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), /*typeArguments*/ undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__asyncGenerator"), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } })(ts || (ts = {})); @@ -73706,7 +77338,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -73725,6 +77357,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -73737,10 +77370,143 @@ var ts; return node; } switch (node.kind) { + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + var updated = visitOptionalExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208 /* BinaryExpression */: + if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a.b` -> { expression: `(_a = a).b`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a[b]` -> { expression: `(_a = a)[b]`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193 /* PropertyAccessExpression */: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194 /* ElementAccessExpression */: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193 /* PropertyAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194 /* ElementAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195 /* CallExpression */: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, + /*typeArguments*/ undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createNull()), ts.createToken(55 /* AmpersandAmpersandToken */), ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -73775,13 +77541,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73791,13 +77557,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -73872,7 +77638,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 274 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -73966,7 +77732,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 264 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74272,7 +78038,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74280,9 +78046,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74485,13 +78251,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 234 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 222 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -74504,72 +78270,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 73 /* Identifier */: + case 75 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -74580,28 +78346,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitSpreadElement(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -74692,14 +78458,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 === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 233 /* 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 === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -74710,7 +78476,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -74968,7 +78734,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -75106,11 +78872,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 234 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 226 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75118,7 +78884,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 222 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75273,10 +79039,10 @@ var ts; return false; } // `declarationName` is the name of the local declaration for the parameter. - var declarationName = parameter.name.kind === 73 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var declarationName = parameter.name.kind === 75 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 73 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; @@ -75300,7 +79066,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73 /* Identifier */) { + if (parameter.name.kind !== 75 /* Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); @@ -75316,7 +79082,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 201 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -75337,25 +79103,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 161 /* 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 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 */), 95 /* 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 */), 97 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -75384,20 +79150,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -75423,12 +79189,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), - /*location*/ member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. @@ -75585,7 +79361,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 === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 243 /* FunctionDeclaration */ || node.kind === 200 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -75629,7 +79405,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 201 /* 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 @@ -75697,9 +79473,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 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -75718,9 +79494,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 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -75755,7 +79531,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 60 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -75929,14 +79705,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76124,7 +79900,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 153 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76179,7 +79955,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -76245,11 +80021,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 229 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 231 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 227 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 228 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76274,11 +80050,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 242 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -76429,7 +80205,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -76491,7 +80267,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(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -76529,7 +80305,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -76540,7 +80316,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, 60 /* EqualsToken */, source); + return ts.createBinary(target, 62 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -76553,7 +80329,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -76567,7 +80343,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(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -76588,10 +80364,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -76677,20 +80453,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -76766,7 +80542,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a @@ -76797,7 +80573,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -76850,7 +80626,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 /* SuperKeyword */ || + if (expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -76974,10 +80750,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 4096 /* ContainsRestOrSpread */ || - node.expression.kind === 99 /* SuperKeyword */ || + node.expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -76995,7 +80771,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -77007,10 +80783,10 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -77034,7 +80810,7 @@ var ts; // [output] // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), /*typeArguments*/ undefined, []); } return ts.visitEachChild(node, visitor, context); @@ -77198,13 +80974,16 @@ var ts; // Find original source text, since we need to emit the raw strings of the tagged template. // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + 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 // and LineTerminatorSequences are normalized to for both TV and TRV. @@ -77295,13 +81074,11 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 98 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return ts.createFileLevelUniqueName("_newTarget"); } @@ -77333,7 +81110,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } /** @@ -77343,14 +81120,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableSubstitution(103 /* ThisKeyword */); + context.enableEmitNotification(161 /* Constructor */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(201 /* ArrowFunction */); + context.enableEmitNotification(200 /* FunctionExpression */); + context.enableEmitNotification(243 /* FunctionDeclaration */); } } /** @@ -77391,10 +81168,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 241 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -77407,9 +81184,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -77476,19 +81253,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -77498,7 +81275,7 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), + return ts.createCall(ts.getUnscopedHelperName("__extends"), /*typeArguments*/ undefined, [ name, ts.createFileLevelUniqueName("_super") @@ -77506,7 +81283,7 @@ var ts; } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw @@ -77514,12 +81291,14 @@ var ts; } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -77541,15 +81320,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(266 /* JsxOpeningElement */); + context.enableEmitNotification(267 /* JsxClosingElement */); + context.enableEmitNotification(265 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(279 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -77568,9 +81347,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -77627,7 +81406,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */) { + if (token !== undefined && token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -77902,13 +81681,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -77921,24 +81700,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -77959,21 +81738,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -77986,9 +81765,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78187,23 +81966,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 /* FirstCompoundAssignment */ - && kind <= 72 /* LastCompoundAssignment */; + return kind >= 63 /* FirstCompoundAssignment */ + && kind <= 74 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61 /* PlusEqualsToken */: return 38 /* PlusToken */; - case 62 /* MinusEqualsToken */: return 39 /* MinusToken */; - case 63 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; - case 64 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; - case 65 /* SlashEqualsToken */: return 42 /* SlashToken */; - case 66 /* PercentEqualsToken */: return 43 /* PercentToken */; - case 67 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; - case 68 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; - case 70 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; - case 71 /* BarEqualsToken */: return 50 /* BarToken */; - case 72 /* CaretEqualsToken */: return 51 /* CaretToken */; + case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; + case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; + case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; + case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; + case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; + case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; + case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; + case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; + case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; + case 73 /* BarEqualsToken */: return 51 /* BarToken */; + case 74 /* CaretEqualsToken */: return 52 /* CaretToken */; } } /** @@ -78216,7 +81995,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78228,7 +82007,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -78315,7 +82094,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 === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -78454,13 +82233,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -78469,7 +82248,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -78604,35 +82383,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79062,7 +82841,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 276 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79075,7 +82854,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79248,11 +83027,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -79387,7 +83165,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -80213,7 +83991,7 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), + return ts.createCall(ts.getUnscopedHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } // The __generator helper is used by down-level transformations to emulate the runtime @@ -80277,6 +84055,7 @@ var ts; // For examples of how these are used, see the comments in ./transformers/generators.ts ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -80303,12 +84082,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(288 /* 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. @@ -80406,14 +84185,14 @@ var ts; // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), // Add the module body function argument: // // function (require, exports, module1, module2) ... @@ -80423,10 +84202,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ]))) ]), @@ -80461,11 +84240,11 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) @@ -80493,10 +84272,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), @@ -80636,23 +84415,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 317 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -80679,24 +84458,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -80811,7 +84590,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -80825,7 +84604,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; if (languageVersion >= 2 /* ES2015 */) { @@ -80859,11 +84638,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; } @@ -81174,7 +84953,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81229,10 +85008,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -81414,8 +85193,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -81431,7 +85210,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -81493,12 +85272,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -81519,7 +85298,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -81587,15 +85366,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 === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* 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 === 204 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 207 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -81635,7 +85414,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]); } // emit helper for dynamic import @@ -81647,12 +85426,14 @@ var ts; // emit helper for `import * as Name from "foo"` ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -81669,16 +85450,18 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(218 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. + var contextObjectMap = []; // The context object associated with a source file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -81717,7 +85500,7 @@ var ts; // existing identifiers. exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -81895,7 +85678,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 259 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -81920,7 +85703,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 259 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -81989,28 +85772,28 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; + var group_2 = dependencyGroups_1[_i]; // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82060,15 +85843,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82244,7 +86027,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 === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 288 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -82308,7 +86091,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 === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -82370,10 +86153,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82553,43 +86336,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node); - case 317 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -82836,7 +86619,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 288 /* SourceFile */; } else { return false; @@ -82852,8 +86635,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -82869,12 +86652,13 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -82882,6 +86666,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -82917,7 +86702,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -82951,13 +86736,15 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); + case 218 /* MetaProperty */: + return substituteMetaProperty(node); } return node; } @@ -83042,22 +86829,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 === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* 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 === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 207 /* 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 === 204 /* PostfixUnaryExpression */) { - expression = node.operator === 44 /* PlusPlusToken */ + if (node.kind === 207 /* PostfixUnaryExpression */) { + expression = node.operator === 45 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -83066,6 +86853,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } /** * Gets the exports of a name. * @@ -83078,7 +86871,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83117,24 +86910,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); - context.enableSubstitution(73 /* Identifier */); - var currentSourceFile; + context.enableEmitNotification(288 /* SourceFile */); + context.enableSubstitution(75 /* Identifier */); + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864 /* NeverApplyImportHelper */); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -83146,10 +86935,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83170,9 +86959,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -83189,19 +86978,18 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -83257,7 +87045,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83286,7 +87074,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83312,7 +87100,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -83333,7 +87121,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 === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* 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 : @@ -83342,8 +87130,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 === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 158 /* PropertyDeclaration */ || node.kind === 193 /* PropertyAccessExpression */ || node.kind === 157 /* PropertySignature */ || + (node.kind === 155 /* 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 ? @@ -83352,7 +87140,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 === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 244 /* ClassDeclaration */ || node.kind === 155 /* 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 : @@ -83377,7 +87165,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* 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 */)) { @@ -83416,26 +87204,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* 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 161 /* CallSignature */: + case 164 /* 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 163 /* IndexSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83443,7 +87231,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83457,7 +87245,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 243 /* 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 : @@ -83482,30 +87270,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 161 /* 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 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 165 /* ConstructSignature */: + case 170 /* 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 161 /* CallSignature */: + case 164 /* 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 163 /* IndexSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83513,7 +87301,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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* 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 : @@ -83526,13 +87314,20 @@ 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 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 243 /* FunctionDeclaration */: + case 169 /* 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 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -83541,39 +87336,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 185 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* 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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* 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 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 169 /* FunctionType */: + case 243 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -83588,9 +87383,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 244 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 /* 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; } @@ -83625,11 +87420,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; // No declaration diagnostics for js for now - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -83639,7 +87431,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 155 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -83700,9 +87492,9 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -83785,20 +87577,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -83811,18 +87612,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { 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(126 /* 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 statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : 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 === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -83859,12 +87660,19 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -83906,6 +87714,15 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { + var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, host.getSourceFiles(), + /*preferences*/ undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration + // via a non-relative name, emit a type reference directive to that non-relative name, rather than + // a relative path to the declaration file + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { @@ -83942,11 +87759,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 189 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -83954,20 +87771,20 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 214 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { oldDiag = getSymbolAccessibilityDiagnostic; 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(56 /* 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(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -83992,19 +87809,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 155 /* 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(121 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* 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(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -84012,12 +87829,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 155 /* Parameter */ + || node.kind === 158 /* PropertyDeclaration */ + || node.kind === 157 /* 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)); @@ -84028,26 +87845,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(124 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return false; } return false; @@ -84074,6 +87891,33 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, /*modifierMask*/ undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -84101,7 +87945,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 /* ModuleDeclaration */ && parent.kind !== 187 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84121,7 +87965,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 263 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84148,7 +87992,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 === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 255 /* 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; @@ -84197,11 +88041,11 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -84211,13 +88055,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -84240,6 +88077,11 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + // Setup diagnostic-related flags before first potential `cleanup` call, otherwise + // We'd see a TDZ violation at runtime + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 /* TypeLiteral */ || input.kind === 185 /* MappedType */) && input.parent.kind !== 246 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -84248,76 +88090,77 @@ var ts; return cleanup(ts.createProperty(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* 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 212 /* ExpressionWithTypeArguments */: { + case 215 /* 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 165 /* TypeReference */: { + case 168 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 161 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(161 /* 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 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(159 /* 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 159 /* GetAccessor */: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 162 /* GetAccessor */: { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); } - case 160 /* SetAccessor */: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 163 /* SetAccessor */: { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); } - case 155 /* PropertyDeclaration */: + case 158 /* 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 154 /* PropertySignature */: + case 157 /* 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 156 /* MethodSignature */: { + case 159 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 164 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 166 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -84325,13 +88168,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 151 /* TypeParameter */: { + case 154 /* 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 176 /* ConditionalType */: { + case 179 /* 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); @@ -84343,13 +88186,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 169 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 170 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 187 /* 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)); @@ -84359,13 +88202,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -84378,7 +88221,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 160 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -84388,7 +88231,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 259 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -84397,13 +88240,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 258 /* 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 === 73 /* Identifier */) { + if (input.expression.kind === 75 /* Identifier */) { return input; } else { @@ -84413,7 +88256,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(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -84438,10 +88281,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -84462,14 +88305,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 246 /* 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), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 245 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 243 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -84484,7 +88327,7 @@ var ts; fakespace_1.symbol = props[0].parent; var declarations = ts.mapDefined(props, function (p) { if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { - return undefined; + return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker); @@ -84517,17 +88360,17 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 248 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 249 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304 /* Ambient */) { + if (input.flags & 8388608 /* Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -84536,7 +88379,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -84563,7 +88406,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 244 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -84574,7 +88417,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73 /* Identifier */) { + if (param.name.kind === 75 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -84604,7 +88447,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 !== 97 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); @@ -84614,16 +88457,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(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87 /* ExtendsKeyword */) { + if (clause.token === 89 /* 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 === 97 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -84634,10 +88477,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 247 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -84656,7 +88499,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 248 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -84677,7 +88520,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 214 /* OmittedExpression */) { return; } if (e.name) { @@ -84727,55 +88570,36 @@ var ts; function ensureModifierFlags(node) { 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 === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 288 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask, additions); } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); } - var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3 /* MultiLineCommentTrivia */) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; + return accessorType; } 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 === 87 /* ExtendsKeyword */ && t.expression.kind === 97 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 /* ExtendsKeyword */ && t.expression.kind === 99 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { return true; } return false; @@ -84800,7 +88624,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 162 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -84809,52 +88633,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 224 /* VariableStatement */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 165 /* ConstructSignature */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 241 /* VariableDeclaration */: + case 154 /* TypeParameter */: + case 215 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 179 /* ConditionalType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 187 /* ImportType */: return true; } return false; @@ -84983,7 +88807,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(319 /* Count */); + var enabledSyntaxKindFeatures = new Array(324 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -85190,7 +89014,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement( @@ -85268,15 +89092,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -85286,22 +89110,21 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - /*@internal*/ - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -85324,7 +89147,7 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; @@ -85332,14 +89155,14 @@ var ts; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 289 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -85349,9 +89172,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -85392,11 +89213,13 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : @@ -85407,43 +89230,73 @@ var ts; outputFileName : undefined; } + function createAddOutput() { + var outputs; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } /*@internal*/ function getAllProjectOutputs(configFile, ignoreCase) { - var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) - continue; - if (configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; /*@internal*/ function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { @@ -85457,8 +89310,13 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + continue; + if (ts.getEmitDeclarations(configFile.options)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); @@ -85466,7 +89324,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -85480,7 +89338,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -85576,17 +89434,16 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !declarationFilePath) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; // Setup and perform the transformation to retrieve declarations from the input files - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -85618,7 +89475,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -85626,12 +89483,8 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { - // Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule. - // But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow. - // Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the - // tslint directive can be all be removed. - var sourceFile = declarationTransform.transformed[0]; // tslint:disable-line + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288 /* SourceFile */) { + var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } @@ -85641,7 +89494,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -85653,8 +89506,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -85695,7 +89548,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 288 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -85802,10 +89655,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(288 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -85817,7 +89671,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(225 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -85856,7 +89710,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -85910,6 +89764,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers)); @@ -85962,6 +89817,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -85990,9 +89847,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 288 /* SourceFile */: return printFile(node); + case 289 /* Bundle */: return printBundle(node); + case 290 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86161,8 +90018,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -86174,7 +90030,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86190,6 +90046,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { @@ -86199,21 +90057,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(4 /* Unspecified */, node); + var substitute = pipelineEmit(4 /* Unspecified */, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(2 /* IdentifierName */, node); + return pipelineEmit(2 /* IdentifierName */, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1 /* Expression */, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(1 /* Expression */, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -86228,12 +90097,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 288 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -86247,10 +90116,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -86270,279 +90142,279 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 290 /* UnparsedSource */: + case 284 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 283 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 287 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 156 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 293 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 294 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + case 299 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 222 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 223 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 267 /* JsxClosingElement */: + case 270 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 304 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 299 /* JSDocSignature */: + case 303 /* JSDocSignature */: return emitJSDocSignature(node); - case 298 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 303 /* JSDocClassTag */: - case 300 /* JSDocTag */: + case 307 /* JSDocClassTag */: + case 304 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 297 /* JSDocComment */: + case 301 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -86560,83 +90432,83 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Reserved words - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 103 /* TrueKeyword */: - case 101 /* ThisKeyword */: - case 93 /* ImportKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 105 /* TrueKeyword */: + case 103 /* ThisKeyword */: + case 95 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return emitCommaList(node); } } @@ -86649,8 +90521,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -86664,8 +90539,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -86676,7 +90551,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 289 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -86685,12 +90560,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -86776,7 +90651,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -86809,7 +90684,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -86845,7 +90720,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 298 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -86907,7 +90782,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 162 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -86948,11 +90823,17 @@ var ts; // Types // function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -87084,18 +90965,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); - pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* QuestionToken */) { writePunctuation("?"); } } @@ -87175,66 +91055,57 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, - /*stopAfterLineBreak*/ false, - /*stopAtComments*/ true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { - var dotToken = ts.createToken(24 /* DotToken */); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(96 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(98 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -87274,22 +91145,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(84 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(107 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(126 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -87314,9 +91185,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* 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 */))); + return operand.kind === 206 /* PrefixUnaryExpression */ + && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) + || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -87329,7 +91200,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); @@ -87357,7 +91228,7 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(118 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(120 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -87434,7 +91305,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87442,8 +91313,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + emitTokenWithComment(86 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -87453,14 +91324,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(85 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -87469,14 +91340,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -87488,25 +91359,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -87514,7 +91385,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { emit(node); } else { @@ -87523,12 +91394,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(76 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -87556,12 +91427,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(100 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87569,7 +91440,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87579,17 +91450,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -87598,13 +91469,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(82 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -87629,7 +91500,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -87801,7 +91672,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512 /* GlobalAugmentation */) { + if (~node.flags & 1024 /* GlobalAugmentation */) { writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); writeSpace(); } @@ -87809,7 +91680,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 248 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -87830,17 +91701,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -87849,12 +91720,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -87869,9 +91740,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -87882,42 +91753,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(81 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(83 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -87937,7 +91808,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -88015,7 +91886,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88026,13 +91897,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(75 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(77 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -88044,12 +91915,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -88060,7 +91931,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -88130,7 +92001,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88164,7 +92035,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88183,7 +92054,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -88317,8 +92188,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_20 = types; _d < types_20.length; _d++) { + var directive = types_20[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -88498,7 +92369,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -88536,8 +92407,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmbeddedStatement */, node); } else { emit(node); @@ -88944,6 +92814,9 @@ var ts; return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -88961,7 +92834,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89026,81 +92899,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 237 /* LabeledStatement */: + case 235 /* WithStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89109,12 +92982,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -89172,7 +93045,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { return false; } } @@ -89294,25 +93167,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 258 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -89355,11 +93228,12 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 318 /* 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 */; @@ -89383,7 +93257,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -89413,6 +93287,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -89626,6 +93501,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -89640,7 +93516,7 @@ var ts; 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 !== 314 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -89653,12 +93529,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -90021,6 +93898,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -90376,7 +94256,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -90565,8 +94445,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -90579,6 +94459,8 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + /* @internal */ + ts.inferredTypesContainingFile = "__inferred type names__.ts"; /** * Determines if program structure is upto date or needs to be recreated */ @@ -90653,7 +94535,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -90683,15 +94565,17 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -90727,7 +94611,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).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; @@ -90744,7 +94628,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 @@ -90773,8 +94657,13 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks + // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -90782,20 +94671,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } } } @@ -90808,7 +94713,7 @@ var ts; 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(); - var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -90844,8 +94749,8 @@ var ts; // not part of the new program. if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || // old file wasnt redirect but new file is @@ -90861,12 +94766,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -90903,7 +94809,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -90930,9 +94838,14 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + // source file is allowed to be emitted and its not source of project reference redirect + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -91136,6 +95049,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; @@ -91226,7 +95145,7 @@ var ts; // moduleAugmentations has changed oldProgram.structureIsReused = 1 /* SafeModules */; } - if ((oldSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) { // dynamicImport has changed oldProgram.structureIsReused = 1 /* SafeModules */; } @@ -91263,28 +95182,26 @@ var ts; 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 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) { - oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + 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) { + oldProgram.structureIsReused = 1 /* SafeModules */; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } 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, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutions_1 = 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) { + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -91298,11 +95215,19 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping 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 (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined); + } + } // Set the file as found during node modules search if it was found that way in old progra, if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); @@ -91320,9 +95245,10 @@ var ts; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -91331,7 +95257,7 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -91387,15 +95313,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -91403,7 +95329,7 @@ var ts; // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); } @@ -91427,7 +95353,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -91502,15 +95429,16 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || - sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || + sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -91569,22 +95497,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 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 241 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -91592,41 +95520,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 110 /* ImplementsKeyword */) { + if (heritageClause.token === 112 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -91639,51 +95567,52 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* 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 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 224 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 158 /* 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 !== 117 /* StaticKeyword */) { + if (modifier.kind !== 119 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152 /* Parameter */: + case 155 /* 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 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 197 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -91700,24 +95629,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 126 /* DeclareKeyword */: - case 119 /* AbstractKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 129 /* DeclareKeyword */: + case 121 /* 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 117 /* StaticKeyword */: - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 119 /* StaticKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: } } } @@ -91792,8 +95721,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 /* Identifier */ - ? b.kind === 73 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 75 /* Identifier */ + ? b.kind === 75 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -91823,7 +95752,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -91874,7 +95803,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -91955,24 +95884,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -91995,15 +95918,26 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); + var file_2 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected - if (file_1 && options.forceConsistentCasingInFileNames) { + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -92012,34 +95946,35 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } // See if we need to reprocess the imports due to prior skipped imports - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -92057,14 +95992,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92095,7 +96023,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92118,8 +96046,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92134,8 +96072,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts or any of the non ts files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + // Ignore dts + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -92174,6 +96112,35 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + // Dont know which source file it means so return true? + var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); @@ -92208,9 +96175,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -92226,10 +96201,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -92241,7 +96222,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -92251,8 +96232,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -92260,14 +96240,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -92285,20 +96265,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -92338,14 +96318,22 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152 /* JSDoc */)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -92364,12 +96352,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -92426,9 +96417,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -92463,17 +96451,18 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -92589,8 +96578,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -92655,8 +96644,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -92683,7 +96705,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -92758,7 +96780,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -92817,6 +96839,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; /* @internal */ @@ -92862,9 +96890,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } /* @internal */ /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. @@ -92914,9 +96939,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93162,11 +97187,19 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, + /*emitOnlyDtsFiles*/ true, cancellationToken, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); + var firstDts_1 = emitOutput_1.outputFiles && + programOfThisState.getCompilerOptions().declarationMap ? + emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : + emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + if (firstDts_1) { + ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + latestSignature = computeHash(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -93269,6 +97302,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; /** * For script files that contains only ambient external modules, although they are not actually external module files, * they can only be consumed via importing elements from them. Regular script files cannot consume them. Therefore, @@ -93372,6 +97406,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -93385,8 +97424,7 @@ var ts; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them - // With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -93409,7 +97447,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -93455,7 +97494,7 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -93464,7 +97503,7 @@ var ts; function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -93483,7 +97522,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } /** * Releases program and other related not needed properties @@ -93509,7 +97548,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -93541,7 +97581,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } // Remove the changed file from the change set @@ -93587,13 +97626,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -93612,7 +97656,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -93637,7 +97681,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -93655,14 +97699,39 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } /** * Iterate on referencing modules that export entities from affected file */ function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { + return; + } + if (!isChangedSignagure(state, affectedFile.path)) return; + // Since isolated modules dont change js files, files affected by change in signature is itself + // But we need to cleanup semantic diagnostics and queue dts emit for affected files + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); @@ -93731,7 +97800,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -93741,6 +97810,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -93752,8 +97824,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + /** + * Returns the result with affected file + */ + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -93783,7 +97862,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -93878,7 +97957,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -93976,22 +98055,24 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94004,10 +98085,10 @@ var ts; affected = program; } } - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94063,7 +98144,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94095,7 +98176,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94107,8 +98188,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94144,7 +98231,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true }; return { @@ -94270,15 +98357,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -94443,8 +98542,8 @@ var ts; !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]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && @@ -94524,7 +98623,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -94735,6 +98834,10 @@ var ts; // Mark the file as needing re-evaluation of module resolution instead of using it blindly. resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + // When its a file with inferred types resolution, invalidate type reference directive resolution + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -94920,8 +99023,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -94937,20 +99041,26 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // Returns an import for each symlink and for the realpath. + /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) { var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); if (ambient) return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -94966,7 +99076,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0 /* Relative */) { return relativePath; @@ -95002,38 +99112,12 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. - // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** * Looks for existing imports that use symlinks to this module. @@ -95041,10 +99125,12 @@ var ts; */ function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -95061,7 +99147,31 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + // Sort by paths closest to importing file Name directory + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -95092,16 +99202,18 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -95110,24 +99222,27 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } // Simplify the full file path to something that can be resolved by Node. // If the module could be imported by a directory name, use that directory's name - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) @@ -95322,6 +99437,15 @@ var ts; ? newLine + newLine : newLine; } + /** + * Get locale specific time based on whether we are in test mode + */ + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -95329,7 +99453,7 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -95338,7 +99462,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -95531,7 +99655,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -95545,7 +99669,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -95579,7 +99705,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -95628,7 +99754,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -95721,7 +99847,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -95749,10 +99875,22 @@ 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, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -95978,13 +100116,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -96168,12 +100312,22 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -96329,11 +100483,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -96342,8 +100499,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -96363,12 +100519,35 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + // Clear all to ResolvedConfigFilePaths cache to start fresh + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + // Config file cache + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + // Remove watches for the program no longer in the solution + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -96376,6 +100555,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -96392,7 +100572,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -96447,7 +100627,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -96619,7 +100799,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -96787,6 +100967,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -96843,8 +101025,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97015,10 +101200,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97077,7 +101264,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -97242,16 +101429,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -97394,8 +101587,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -97427,6 +101620,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -97437,7 +101631,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -97445,7 +101639,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -97463,23 +101657,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -97512,13 +101716,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -97540,7 +101747,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -97928,6 +102134,15 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ + var PackageJsonDependencyGroup; + (function (PackageJsonDependencyGroup) { + PackageJsonDependencyGroup[PackageJsonDependencyGroup["Dependencies"] = 1] = "Dependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["DevDependencies"] = 2] = "DevDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["PeerDependencies"] = 4] = "PeerDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["OptionalDependencies"] = 8] = "OptionalDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["All"] = 15] = "All"; + })(PackageJsonDependencyGroup = ts.PackageJsonDependencyGroup || (ts.PackageJsonDependencyGroup = {})); + /* @internal */ ts.emptyOptions = {}; var HighlightSpanKind; (function (HighlightSpanKind) { @@ -97942,6 +102157,12 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = ts.SemicolonPreference || (ts.SemicolonPreference = {})); function getDefaultFormatCodeSettings(newLineCharacter) { return { indentSize: 4, @@ -97963,6 +102184,7 @@ var ts; insertSpaceBeforeFunctionParenthesis: false, placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, + semicolons: SemicolonPreference.Ignore, }; } ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; @@ -98192,37 +102414,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 278 /* CatchClause */: + case 271 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 154 /* TypeParameter */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 172 /* TypeLiteral */: return 2 /* Type */; - case 311 /* JSDocTypedefTag */: + case 315 /* 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 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 282 /* EnumMember */: + case 244 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -98232,26 +102454,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 247 /* EnumDeclaration */: + case 256 /* NamedImports */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 258 /* ExportAssignment */ || node.parent.kind === 263 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -98283,11 +102505,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 152 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 252 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -98299,27 +102521,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 152 /* QualifiedName */) { + while (root.parent && root.parent.kind === 152 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 168 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 193 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 193 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 215 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 277 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 244 /* ClassDeclaration */ && root.parent.parent.token === 112 /* ImplementsKeyword */) || + (decl.kind === 245 /* InterfaceDeclaration */ && root.parent.parent.token === 89 /* ExtendsKeyword */); } return false; } @@ -98328,17 +102550,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return true; - case 184 /* ImportType */: + case 187 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -98365,7 +102587,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 237 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -98381,11 +102603,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 73 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 73 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -98397,40 +102619,40 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 248 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 73 /* Identifier */ && + return node.kind === 75 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 282 /* EnumMember */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 248 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 186 /* LiteralType */: + return node.parent.parent.kind === 184 /* IndexedAccessType */; default: return false; } @@ -98454,17 +102676,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return node; } } @@ -98472,48 +102694,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 245 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 246 /* TypeAliasDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 247 /* EnumDeclaration */: return "enum" /* enumElement */; + case 241 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 162 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 163 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 279 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 166 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 165 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 164 /* CallSignature */: return "call" /* callSignatureElement */; + case 161 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 154 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 282 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 155 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -98540,7 +102767,7 @@ var ts; return "" /* unknown */; } } - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -98556,12 +102783,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 155 /* Parameter */; default: return false; } @@ -98626,42 +102853,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 172 /* TypeLiteral */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 250 /* CaseBlock */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 196 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 195 /* CallExpression */: + case 199 /* ParenthesizedExpression */: + case 181 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 201 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -98671,65 +102898,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 191 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 194 /* ElementAccessExpression */: + case 153 /* ComputedPropertyName */: + case 174 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 110 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 203 /* TypeOfExpression */: + case 202 /* DeleteExpression */: + case 204 /* VoidExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -98861,7 +103088,7 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - return ts.firstDefined(n.getChildren(), function (child) { + return ts.firstDefined(n.getChildren(sourceFile), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -98908,7 +103135,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 288 /* 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. @@ -98974,21 +103201,21 @@ var ts; return true; } //
Hello |
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 267 /* JsxClosingElement */) { return true; } return false; @@ -99010,7 +103237,7 @@ var ts; 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)) { + if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -99037,6 +103264,12 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; + function removeOptionality(type, isOptionalExpression, isOptionalChain) { + return isOptionalExpression ? type.getNonNullableType() : + isOptionalChain ? type.getNonOptionalType() : + type; + } + ts.removeOptionality = removeOptionality; function isPossiblyTypeArgumentPosition(token, sourceFile, checker) { var info = getPossibleTypeArgumentsInfo(token, sourceFile); return info !== undefined && (ts.isPartOfTypeNode(info.called) || @@ -99046,6 +103279,9 @@ var ts; ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; function getPossibleGenericSignatures(called, typeArgumentCount, checker) { var type = checker.getTypeAtLocation(called); + if (ts.isOptionalChain(called.parent)) { + type = removeOptionality(type, !!called.parent.questionDotToken, /*isOptionalChain*/ true); + } var signatures = ts.isNewExpression(called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); return signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= typeArgumentCount; }); } @@ -99062,9 +103298,12 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); + if (token && token.kind === 28 /* QuestionDotToken */) { + token = findPrecedingToken(token.getFullStart(), sourceFile); + } if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { @@ -99072,13 +103311,13 @@ var ts; } remainingLessThanTokens--; break; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: remainingLessThanTokens++; break; case 19 /* CloseBraceToken */: @@ -99106,20 +103345,22 @@ var ts; case 27 /* CommaToken */: nTypeArguments++; break; - case 37 /* EqualsGreaterThanToken */: - case 73 /* Identifier */: + case 38 /* EqualsGreaterThanToken */: + // falls through + case 75 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 105 /* TypeOfKeyword */: - case 87 /* ExtendsKeyword */: - case 130 /* KeyOfKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + // falls through + case 107 /* TypeOfKeyword */: + case 89 /* ExtendsKeyword */: + case 133 /* KeyOfKeyword */: case 24 /* DotToken */: - case 50 /* BarToken */: - case 56 /* QuestionToken */: - case 57 /* ColonToken */: + case 51 /* BarToken */: + case 57 /* QuestionToken */: + case 58 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -99168,16 +103409,16 @@ var ts; result.push("abstract" /* abstractModifier */); if (flags & 1 /* Export */) result.push("export" /* exportedModifier */); - if (node.flags & 4194304 /* Ambient */) + if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 168 /* TypeReference */ || node.kind === 195 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 244 /* ClassDeclaration */ || node.kind === 245 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -99197,7 +103438,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 72 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 74 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -99207,9 +103448,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: return true; } return false; @@ -99222,18 +103463,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 191 /* ArrayLiteralExpression */ || + node.kind === 192 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 208 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 60 /* EqualsToken */) { + node.parent.operatorToken.kind === 62 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 231 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -99241,7 +103482,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 279 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -99285,23 +103526,23 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 121 /* AnyKeyword */, - 147 /* BigIntKeyword */, - 124 /* BooleanKeyword */, - 88 /* FalseKeyword */, - 130 /* KeyOfKeyword */, - 133 /* NeverKeyword */, - 97 /* NullKeyword */, - 136 /* NumberKeyword */, - 137 /* ObjectKeyword */, - 134 /* ReadonlyKeyword */, - 139 /* StringKeyword */, - 140 /* SymbolKeyword */, - 103 /* TrueKeyword */, - 107 /* VoidKeyword */, - 142 /* UndefinedKeyword */, - 143 /* UniqueKeyword */, - 144 /* UnknownKeyword */, + 124 /* AnyKeyword */, + 150 /* BigIntKeyword */, + 127 /* BooleanKeyword */, + 90 /* FalseKeyword */, + 133 /* KeyOfKeyword */, + 136 /* NeverKeyword */, + 99 /* NullKeyword */, + 139 /* NumberKeyword */, + 140 /* ObjectKeyword */, + 137 /* ReadonlyKeyword */, + 142 /* StringKeyword */, + 143 /* SymbolKeyword */, + 105 /* TrueKeyword */, + 109 /* VoidKeyword */, + 145 /* UndefinedKeyword */, + 146 /* UniqueKeyword */, + 147 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -99337,7 +103578,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 153 /* 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); @@ -99413,7 +103654,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 73 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 75 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -99502,7 +103743,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 155 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -99543,6 +103784,8 @@ var ts; getColumn: function () { return 0; }, getLine: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingWhitespace: function () { return false; }, + hasTrailingComment: function () { return false; }, rawWrite: ts.notImplemented, getIndent: function () { return indent; }, increaseIndent: function () { indent++; }, @@ -99964,15 +104207,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 208 /* 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 272 /* CaseClause */: + case 275 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -100000,10 +104243,10 @@ var ts; ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: return true; default: return false; @@ -100014,8 +104257,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: return true; default: return false; @@ -100036,7 +104279,6 @@ var ts; 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, @@ -100054,28 +104296,90 @@ var ts; return typeIsAccessible ? res : undefined; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; - function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; - } - ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; + function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { + return kind === 164 /* CallSignature */ + || kind === 165 /* ConstructSignature */ + || kind === 166 /* IndexSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */; + } + ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; + function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { + return kind === 243 /* FunctionDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; + } + ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; + function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { + return kind === 248 /* ModuleDeclaration */; + } + ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; + function syntaxRequiresTrailingSemicolonOrASI(kind) { + return kind === 224 /* VariableStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 227 /* DoStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 233 /* BreakStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 158 /* PropertyDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 258 /* ExportAssignment */; + } + ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; + ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); + function isASICandidate(node, sourceFile) { + var lastToken = node.getLastToken(sourceFile); + if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + return false; + } + if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { + if (lastToken && lastToken.kind === 27 /* CommaToken */) { + return false; + } + } + else if (syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isModuleBlock(lastChild)) { + return false; + } + } + else if (syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isFunctionBlock(lastChild)) { + return false; + } + } + else if (!syntaxRequiresTrailingSemicolonOrASI(node.kind)) { + return false; + } + // See comment in parser’s `parseDoStatement` + if (node.kind === 227 /* DoStatement */) { + return true; + } + var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); + var nextToken = ts.findNextToken(node, topNode, sourceFile); + if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + return true; + } + var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(nextToken.getStart(sourceFile)).line; + return startLine !== endLine; + } + ts.isASICandidate = isASICandidate; function probablyUsesSemicolons(sourceFile) { var withSemicolon = 0; var withoutSemicolon = 0; var nStatementsToObserve = 5; ts.forEachChild(sourceFile, function visit(node) { - if (syntaxUsuallyHasTrailingSemicolon(node.kind)) { + if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { withSemicolon++; @@ -100098,9 +104402,154 @@ var ts; return withSemicolon / withoutSemicolon > 1 / nStatementsToObserve; } ts.probablyUsesSemicolons = probablyUsesSemicolons; + function tryGetDirectories(host, directoryName) { + return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || []; + } + ts.tryGetDirectories = tryGetDirectories; + function tryReadDirectory(host, path, extensions, exclude, include) { + return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include) || ts.emptyArray; + } + ts.tryReadDirectory = tryReadDirectory; + function tryFileExists(host, path) { + return tryIOAndConsumeErrors(host, host.fileExists, path); + } + ts.tryFileExists = tryFileExists; + function tryDirectoryExists(host, path) { + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; + } + ts.tryDirectoryExists = tryDirectoryExists; + function tryAndIgnoreErrors(cb) { + try { + return cb(); + } + catch (_a) { + return undefined; + } + } + ts.tryAndIgnoreErrors = tryAndIgnoreErrors; + 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); }); + } + ts.tryIOAndConsumeErrors = tryIOAndConsumeErrors; + function findPackageJsons(startDirectory, host, stopDirectory) { + var paths = []; + ts.forEachAncestorDirectory(startDirectory, function (ancestor) { + if (ancestor === stopDirectory) { + return true; + } + var currentConfigPath = ts.combinePaths(ancestor, "package.json"); + if (tryFileExists(host, currentConfigPath)) { + paths.push(currentConfigPath); + } + }); + return paths; + } + ts.findPackageJsons = findPackageJsons; + function findPackageJson(directory, host) { + var packageJson; + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (ancestor === "node_modules") + return true; + packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); + if (packageJson) { + return true; // break out + } + }); + return packageJson; + } + ts.findPackageJson = findPackageJson; + function getPackageJsonsVisibleToFile(fileName, host) { + if (!host.fileExists) { + return []; + } + var packageJsons = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(fileName), function (ancestor) { + var packageJsonFileName = ts.combinePaths(ancestor, "package.json"); + if (host.fileExists(packageJsonFileName)) { + var info = createPackageJsonInfo(packageJsonFileName, host); + if (info) { + packageJsons.push(info); + } + } + }); + return packageJsons; + } + ts.getPackageJsonsVisibleToFile = getPackageJsonsVisibleToFile; + function createPackageJsonInfo(fileName, host) { + if (!host.readFile) { + return undefined; + } + var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]; + var stringContent = host.readFile(fileName); + var content = stringContent && tryParseJson(stringContent); + if (!content) { + return undefined; + } + var info = {}; + for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) { + var key = dependencyKeys_1[_i]; + var dependencies = content[key]; + if (!dependencies) { + continue; + } + var dependencyMap = ts.createMap(); + for (var packageName in dependencies) { + dependencyMap.set(packageName, dependencies[packageName]); + } + info[key] = dependencyMap; + } + var dependencyGroups = [ + [1 /* Dependencies */, info.dependencies], + [2 /* DevDependencies */, info.devDependencies], + [8 /* OptionalDependencies */, info.optionalDependencies], + [4 /* PeerDependencies */, info.peerDependencies], + ]; + return __assign(__assign({}, info), { fileName: fileName, + get: get, + has: function (dependencyName, inGroups) { + return !!get(dependencyName, inGroups); + } }); + function get(dependencyName, inGroups) { + if (inGroups === void 0) { inGroups = 15 /* All */; } + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; + if (deps && (inGroups & group_1)) { + var dep = deps.get(dependencyName); + if (dep !== undefined) { + return dep; + } + } + } + } + } + ts.createPackageJsonInfo = createPackageJsonInfo; + function tryParseJson(text) { + try { + return JSON.parse(text); + } + catch (_a) { + return undefined; + } + } + function consumesNodeCoreModules(sourceFile) { + return ts.some(sourceFile.imports, function (_a) { + var text = _a.text; + return ts.JsTyping.nodeCoreModules.has(text); + }); + } + ts.consumesNodeCoreModules = consumesNodeCoreModules; + function isInsideNodeModules(fileOrDirectory) { + return ts.contains(ts.getPathComponents(fileOrDirectory), "node_modules"); + } + ts.isInsideNodeModules = isInsideNodeModules; })(ts || (ts = {})); var ts; (function (ts) { + /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { @@ -100178,36 +104627,36 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; - case 28 /* LessThanToken */: - if (lastNonTriviaToken === 73 /* Identifier */) { + case 29 /* LessThanToken */: + if (lastNonTriviaToken === 75 /* 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 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 121 /* AnyKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: + case 124 /* AnyKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* 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 = 73 /* Identifier */; + token = 75 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -100246,14 +104695,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 73 /* Identifier */; + token = 75 /* 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 = 73 /* Identifier */; + token = 75 /* Identifier */; } } } @@ -100267,19 +104716,19 @@ 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([ - 73 /* Identifier */, + 75 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 101 /* ThisKeyword */, - 44 /* PlusPlusToken */, - 45 /* MinusMinusToken */, + 103 /* ThisKeyword */, + 45 /* PlusPlusToken */, + 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 103 /* TrueKeyword */, - 88 /* FalseKeyword */, + 105 /* TrueKeyword */, + 90 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -100391,10 +104840,10 @@ var ts; return true; } switch (keyword2) { - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 125 /* ConstructorKeyword */: - case 117 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 128 /* ConstructorKeyword */: + case 119 /* 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. @@ -100427,43 +104876,44 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - 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 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* 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 71 /* BarEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 60 /* EqualsToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 50 /* AmpersandToken */: + case 52 /* CaretToken */: + case 51 /* BarToken */: + case 55 /* AmpersandAmpersandToken */: + case 56 /* BarBarToken */: + case 73 /* BarEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: + case 60 /* QuestionQuestionToken */: return true; default: return false; @@ -100471,12 +104921,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: return true; default: return false; @@ -100489,7 +104939,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 72 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 74 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -100508,7 +104958,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 73 /* Identifier */: + case 75 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -100533,10 +104983,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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -100729,6 +105179,11 @@ var ts; return; } } + else if (kind === 2 /* SingleLineCommentTrivia */) { + if (tryClassifyTripleSlashComment(start, width)) { + return; + } + } // Simple comment. Just add as is. pushCommentRange(start, width); } @@ -100749,18 +105204,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 306 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 307 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -100789,6 +105244,70 @@ var ts; } } } + function tryClassifyTripleSlashComment(start, width) { + var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; + var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + var text = sourceFile.text.substr(start, width); + var match = tripleSlashXMLCommentRegEx.exec(text); + if (!match) { + return false; + } + // Limiting classification to exactly the elements and attributes + // defined in `ts.commentPragmas` would be excessive, but we can avoid + // some obvious false positives (e.g. in XML-like doc comments) by + // checking the element name. + // eslint-disable-next-line no-in-operator + if (!match[3] || !(match[3] in ts.commentPragmas)) { + return false; + } + var pos = start; + pushCommentRange(pos, match[1].length); // /// + pos += match[1].length; + pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pos += match[2].length; + pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pos += match[3].length; + var attrText = match[4]; + var attrPos = pos; + while (true) { + var attrMatch = attributeRegex.exec(attrText); + if (!attrMatch) { + break; + } + var newAttrPos = pos + attrMatch.index; + if (newAttrPos > attrPos) { + pushCommentRange(attrPos, newAttrPos - attrPos); + attrPos = newAttrPos; + } + pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[1].length; + if (attrMatch[2].length) { + pushCommentRange(attrPos, attrMatch[2].length); // whitespace + attrPos += attrMatch[2].length; + } + pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = + attrPos += attrMatch[3].length; + if (attrMatch[4].length) { + pushCommentRange(attrPos, attrMatch[4].length); // whitespace + attrPos += attrMatch[4].length; + } + pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[5].length; + } + pos += match[4].length; + if (pos > attrPos) { + pushCommentRange(attrPos, pos - attrPos); + } + if (match[5]) { + pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pos += match[5].length; + } + var end = start + width; + if (pos < end) { + pushCommentRange(pos, end - pos); + } + return true; + } function processJSDocTemplateTag(tag) { for (var _i = 0, _a = tag.getChildren(); _i < _a.length; _i++) { var child = _a[_i]; @@ -100847,22 +105366,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -100879,7 +105398,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* GreaterThanToken */) { + if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* 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)) { @@ -100889,19 +105408,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 60 /* EqualsToken */) { + if (tokenKind === 62 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 241 /* VariableDeclaration */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 155 /* Parameter */ || + parent.kind === 271 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 208 /* BinaryExpression */ || + parent.kind === 206 /* PrefixUnaryExpression */ || + parent.kind === 207 /* PostfixUnaryExpression */ || + parent.kind === 209 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -100915,7 +105434,7 @@ var ts; } else if (tokenKind === 10 /* StringLiteral */) { // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 271 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -100928,35 +105447,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 73 /* Identifier */) { + else if (tokenKind === 75 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 155 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -101079,11 +105598,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -101091,9 +105610,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 187 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 177 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -101103,7 +105622,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -101120,7 +105639,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -101133,8 +105652,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* 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 @@ -101143,9 +105662,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 263 /* 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*/"); @@ -101189,11 +105708,8 @@ var ts; 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; + 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 }; @@ -101250,7 +105766,7 @@ var ts; return ts.containsPath(rootDirectory, scriptDirectory, basePath, ignoreCase) ? scriptDirectory.substr(rootDirectory.length) : undefined; }); // TODO: GH#18217 // 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); }).concat([scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); + return ts.deduplicate(__spreadArrays(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), [scriptDirectory]), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptDirectory, extensionOptions, compilerOptions, host, exclude) { var basePath = compilerOptions.project || host.getCurrentDirectory(); @@ -101283,10 +105799,10 @@ 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)) + if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { /** * Multiple file entries might map to the same truncated name once we remove extensions @@ -101309,7 +105825,7 @@ var ts; }); } // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); + var directories = ts.tryGetDirectories(host, baseDirectory); if (directories) { for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var directory = directories_1[_b]; @@ -101320,7 +105836,7 @@ var ts; } } // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); + var packageJsonPath = ts.findPackageJson(baseDirectory, host); if (packageJsonPath) { var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; @@ -101398,7 +105914,7 @@ var ts; if (!foundGlobal) { ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); - if (tryDirectoryExists(host, nodeModules)) { + if (ts.tryDirectoryExists(host, nodeModules)) { getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); @@ -101448,16 +105964,16 @@ 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 = ts.mapDefined(tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); }); - var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var directories = ts.mapDefined(ts.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); + return __spreadArrays(matches, directories); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); return inner === undefined ? undefined : removeLeadingDirectorySeparator(inner); @@ -101505,22 +106021,22 @@ var ts; if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + var typeRoots = ts.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); } // Also get all @types typings installed in visible node_modules directories - for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + for (var _a = 0, _b = ts.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) { - if (!tryDirectoryExists(host, directory)) + if (!ts.tryDirectoryExists(host, directory)) return; - for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.tryGetDirectories(host, directory); _i < _a.length; _i++) { var typeDirectoryName = _a[_i]; var packageName = ts.unmangleScopedPackageName(typeDirectoryName); if (options.types && !ts.contains(options.types, packageName)) @@ -101541,34 +106057,11 @@ var ts; } } } - function findPackageJsons(directory, host) { - var paths = []; - ts.forEachAncestorDirectory(directory, function (ancestor) { - var currentConfigPath = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (!currentConfigPath) { - return true; // break out - } - paths.push(currentConfigPath); - }); - return paths; - } - function findPackageJson(directory, host) { - var packageJson; - ts.forEachAncestorDirectory(directory, function (ancestor) { - if (ancestor === "node_modules") - return true; - packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (packageJson) { - return true; // break out - } - }); - return packageJson; - } function enumerateNodeModulesVisibleToScript(host, scriptPath) { if (!host.readFile || !host.fileExists) return ts.emptyArray; var result = []; - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.findPackageJsons(scriptPath, host); _i < _a.length; _i++) { var packageJson = _a[_i]; var contents = ts.readJson(packageJson, host); // Cast to assert that readFile is defined // Provide completions for all non @types dependencies @@ -101617,33 +106110,6 @@ var ts; */ var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*" 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, 30 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -101816,14 +106341,25 @@ var ts; function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { var insertText; var replacementSpan; - if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; + var insertQuestionDot = origin && originIsNullableMember(origin); + var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; + if (origin && originIsThisType(origin)) { + insertText = needsConvertPropertyAccess + ? "this" + (insertQuestionDot ? "?." : "") + "[" + ts.quote(name, preferences) + "]" + : "this" + (insertQuestionDot ? "?." : ".") + 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 ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); + else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { + insertText = useBraces ? needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]" : name; + if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { + insertText = "?." + insertText; + } + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + if (!dot) { + return undefined; + } // 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); @@ -101836,6 +106372,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -101930,9 +106473,9 @@ var ts; } return entries; } - function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { + function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host) { var compilerOptions = program.getCompilerOptions(); - var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { return { type: "none" }; } @@ -101972,7 +106515,7 @@ var ts; 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); + var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); switch (symbolCompletion.type) { case "request": { var request = symbolCompletion.request; @@ -102028,8 +106571,8 @@ var ts; var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } - function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { - var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host) { + var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); return completion.type === "symbol" ? completion.symbol : undefined; } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; @@ -102062,34 +106605,34 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return checker.getContextualType(parent); - case 75 /* CaseKeyword */: + case 77 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 264 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.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); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -102099,9 +106642,9 @@ 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 === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 288 /* SourceFile */; }); } - function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 @@ -102150,11 +106693,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 312 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 316 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -102190,6 +106733,7 @@ var ts; var node = currentToken; var propertyAccessToConvert; var isRightOfDot = false; + var isRightOfQuestionDot = false; var isRightOfOpenTag = false; var isStartingCloseTag = false; var isJsxInitializer = false; @@ -102201,10 +106745,11 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */) { - isRightOfDot = true; + if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -102216,14 +106761,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 187 /* ImportType */: + case 218 /* MetaProperty */: node = parent; break; default: @@ -102236,56 +106781,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 === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 193 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + case 31 /* GreaterThanToken */: + if (currentToken.parent.kind === 264 /* JsxElement */ || currentToken.parent.kind === 266 /* JsxOpeningElement */) { location = currentToken; } break; - case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + case 43 /* SlashToken */: + if (currentToken.parent.kind === 265 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: - if (contextToken.kind === 42 /* SlashToken */) { + case 267 /* JsxClosingElement */: + if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: - if (contextToken.kind === 28 /* LessThanToken */) { + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: + case 266 /* JsxOpeningElement */: + if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: switch (previousToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: isJsxInitializer = true; break; - case 73 /* Identifier */: + case 75 /* 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, 60 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 62 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -102300,7 +106845,8 @@ var ts; var symbols = []; var symbolToOriginInfoMap = []; var symbolToSortTextMap = []; - if (isRightOfDot) { + var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { @@ -102350,11 +106896,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 311 /* JSDocTypedefTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 315 /* JSDocTypedefTag */: return true; default: return false; @@ -102398,24 +106944,40 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 288 /* SourceFile */ && d.kind !== 248 /* ModuleDeclaration */ && d.kind !== 247 /* EnumDeclaration */; })) { + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + insertQuestionDot = isRightOfDot && !isRightOfQuestionDot; + type = type.getNonNullableType(); + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 96 /* NewKeyword */ || node.keywordToken === 93 /* ImportKeyword */)) { - var completion = (node.keywordToken === 96 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 98 /* NewKeyword */ || node.keywordToken === 95 /* ImportKeyword */)) { + var completion = (node.keywordToken === 98 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + var type = typeChecker.getTypeAtLocation(node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + insertQuestionDot = isRightOfDot && !isRightOfQuestionDot; + type = type.getNonNullableType(); + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait, insertQuestionDot) { isNewIdentifierLocation = !!type.getStringIndexType(); + if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { + isNewIdentifierLocation = true; + } + var propertyAccess = node.kind === 187 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -102427,13 +106989,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { - addPropertySymbol(symbol); + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { + addPropertySymbol(symbol, /*insertAwait*/ false, insertQuestionDot); + } + } + } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true, insertQuestionDot); + } } } } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait, insertQuestionDot) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -102447,15 +107020,32 @@ var ts; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) + ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } + : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addSymbolOriginInfo(symbol); symbols.push(symbol); } + function addSymbolOriginInfo(symbol) { + if (preferences.includeCompletionsWithInsertText) { + if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + } + else if (insertQuestionDot) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + } + } + } + function getNullableSymbolOriginInfoKind(kind) { + return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -102488,6 +107078,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -102531,7 +107122,7 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); var isTypeOnly = isTypeOnlyCompletion(); - var symbolMeanings = (isTypeOnly ? 0 /* None */ : 67220415 /* Value */) | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; @@ -102541,19 +107132,38 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 288 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ }; + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; } } } if (shouldOfferImportCompletions()) { - getSymbolsFromOtherSourceFileExports(symbols, previousToken && ts.isIdentifier(previousToken) ? previousToken.text : "", program.getCompilerOptions().target); + var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); + if (!detailsEntryId && importSuggestionsCache) { + importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); + } + autoImportSuggestions.forEach(function (_a) { + var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; + if (detailsEntryId) { + if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { + return; + } + } + else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { + return; + } + var symbolId = ts.getSymbolId(symbol); + symbols.push(symbol); + symbolToOriginInfoMap[symbolId] = origin; + symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; + }); } filterGlobalCompletion(symbols); } @@ -102575,10 +107185,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 210 /* TemplateExpression */: + case 274 /* JsxExpression */: + case 222 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -102608,7 +107218,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 67220415 /* Value */); + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); }); } function isTypeAssertion() { @@ -102623,28 +107233,28 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 107 /* TypeOfKeyword */ && + (contextToken.parent.kind === 171 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + case 58 /* ColonToken */: + return parentKind === 158 /* PropertyDeclaration */ || + parentKind === 157 /* PropertySignature */ || + parentKind === 155 /* Parameter */ || + parentKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; - case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; - case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; - case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + case 62 /* EqualsToken */: + return parentKind === 246 /* TypeAliasDeclaration */; + case 122 /* AsKeyword */: + return parentKind === 216 /* AsExpression */; + case 29 /* LessThanToken */: + return parentKind === 168 /* TypeReference */ || + parentKind === 198 /* TypeAssertionExpression */; + case 89 /* ExtendsKeyword */: + return parentKind === 154 /* TypeParameter */; } } return false; @@ -102653,15 +107263,76 @@ var ts; function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { if (seenModules === void 0) { seenModules = ts.createMap(); } var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 67897832 /* Type */) || + return !!(sym.flags & 788968 /* 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(); + /** + * Gathers symbols that can be imported from other files, deduplicating along the way. Symbols can be “duplicates” + * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but + * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, + * if and only if the the first can be imported (it may be excluded due to package.json filtering in + * `codefix.forEachExternalModuleToImportFrom`). + * + * Example. Imagine a chain of node_modules re-exporting one original symbol: + * + * ```js + * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js + * +-----------------------+ +--------------------------+ +--------------------------+ + * | | | | | | + * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | + * | | | | | | + * +-----------------------+ +--------------------------+ +--------------------------+ + * ``` + * + * Also imagine three buckets, which we’ll reference soon: + * + * ```md + * | | | | | | + * | **Bucket A** | | **Bucket B** | | **Bucket C** | + * | Symbols to | | Aliases to symbols | | Symbols to return | + * | definitely | | in Buckets A or C | | if nothing better | + * | return | | (don’t return these) | | comes along | + * |__________________| |______________________| |___________________| + * ``` + * + * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it + * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not + * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we + * may not be sure whether or not it should go in the list. So, we’ll take the following steps: + * + * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is + * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B + * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. + * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. + * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' + * should never be returned in the final list, so put it in Bucket B. + * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so + * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. + * Put this symbol in Bucket A. + * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t + * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move + * everything from Bucket C to Bucket A. + */ + function getSymbolsFromOtherSourceFileExports(target, host) { + var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); + if (cached) { + log("getSymbolsFromOtherSourceFileExports: Using cached list"); + return cached; + } + var startTime = ts.timestamp(); + log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); var seenResolvedModules = ts.createMap(); - ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + /** Bucket B */ + var aliasesToAlreadyIncludedSymbols = ts.createMap(); + /** Bucket C */ + var aliasesToReturnIfOriginalsAreMissing = ts.createMap(); + /** Bucket A */ + var results = []; + /** Ids present in `results` for faster lookup */ + var resultSymbolIds = ts.createMap(); + ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, function (moduleSymbol) { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; @@ -102671,41 +107342,75 @@ var ts; if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { return; } + // Don't add another completion for `export =` of a symbol that's already global. + // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. if (resolvedModuleSymbol !== moduleSymbol && - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - ts.some(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { - symbols.push(resolvedModuleSymbol); - symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { + pushSymbol(resolvedModuleSymbol, moduleSymbol, /*skipFilter*/ true); } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; - // Don't add a completion for a re-export, only for the original. - // 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 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) { - // 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); - })) { + // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. + if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { continue; } - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + var symbolId = ts.getSymbolId(symbol).toString(); + // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. + var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; + // 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). + if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { + // Walk the export chain back one module (step 1 or 2 in diagrammed example). + // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. + var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); + if (!nearestExportSymbol) + continue; + var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); + var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); + if (!symbolHasBeenSeen) { + aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol }); + aliasesToAlreadyIncludedSymbols.set(symbolId, true); + } + else { + // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here + // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. + ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); + } } - var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; - if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) { - symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin; + else { + // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.delete(symbolId); + pushSymbol(symbol, moduleSymbol); } } }); + // By this point, any potential duplicates that were actually duplicates have been + // removed, so the rest need to be added. (Step 4 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { + var alias = _a.alias, moduleSymbol = _a.moduleSymbol; + return pushSymbol(alias, moduleSymbol); + }); + log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); + return results; + function pushSymbol(symbol, moduleSymbol, skipFilter) { + if (skipFilter === void 0) { skipFilter = false; } + var isDefaultExport = symbol.escapedName === "default" /* Default */; + if (isDefaultExport) { + symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + } + ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); + var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; + results.push({ + symbol: symbol, + symbolName: getSymbolName(symbol, origin, target), + origin: origin, + skipFilter: skipFilter, + }); + } + } + function getNearestExportSymbol(fromSymbol) { + return findAlias(typeChecker, fromSymbol, function (alias) { + return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); + }); } /** * True if you could remove some characters in `a` to get `b`. @@ -102752,12 +107457,12 @@ var ts; if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 266 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 267 /* JsxClosingElement */ || contextToken.parent.kind === 265 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 264 /* JsxElement */; } } return false; @@ -102768,40 +107473,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 195 /* CallExpression */ // func( a, | + || containingNodeKind === 161 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 196 /* NewExpression */ // new C(a, | + || containingNodeKind === 191 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 208 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 169 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 195 /* CallExpression */ // func( | + || containingNodeKind === 161 /* Constructor */ // constructor( | + || containingNodeKind === 196 /* NewExpression */ // new C(a| + || containingNodeKind === 199 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 181 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 131 /* ModuleKeyword */: // module | - case 132 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 191 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 166 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 153 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 134 /* ModuleKeyword */: // module | + case 135 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 248 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | - case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 244 /* ClassDeclaration */; // class A{ | + case 62 /* EqualsToken */: + return containingNodeKind === 241 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 208 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 210 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 220 /* TemplateSpan */; // `aa ${10} dd ${| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -102828,7 +107533,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 192 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; @@ -102837,7 +107542,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 188 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -102848,12 +107553,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 === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 231 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 155 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 160 /* MethodDeclaration */ || rootDeclaration.parent.kind === 163 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -102870,6 +107575,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -102895,7 +107601,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 256 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -102918,15 +107624,15 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 41 /* 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)) return 1 /* Success */; - var classElement = contextToken.parent; + var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : 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 === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 75 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -102961,9 +107667,9 @@ var ts; return parent; } break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 73 /* Identifier */: + case 75 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -103013,23 +107719,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 30 /* GreaterThanToken */: // End of a type argument list - case 29 /* LessThanSlashToken */: - case 42 /* SlashToken */: - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { - if (contextToken.kind === 30 /* GreaterThanToken */) { + case 31 /* GreaterThanToken */: // End of a type argument list + case 30 /* LessThanSlashToken */: + case 43 /* SlashToken */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 272 /* JsxAttributes */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 265 /* JsxSelfClosingElement */ || parent.kind === 266 /* JsxOpeningElement */)) { + if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) break; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103041,7 +107747,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 271 /* JsxAttribute */) || (parent.kind === 273 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103051,8 +107757,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 274 /* JsxExpression */ && + parent.parent && parent.parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103060,7 +107766,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 273 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103080,64 +107786,64 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 241 /* VariableDeclaration */ || + containingNodeKind === 242 /* VariableDeclarationList */ || + containingNodeKind === 224 /* VariableStatement */ || + containingNodeKind === 247 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| - case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [.| + case 58 /* ColonToken */: + return containingNodeKind === 190 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 278 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | - case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 247 /* EnumDeclaration */; // enum a { | + case 29 /* LessThanToken */: + return containingNodeKind === 244 /* ClassDeclaration */ || // class A< | + containingNodeKind === 213 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 245 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 246 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 119 /* StaticKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + return containingNodeKind === 155 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 189 /* ArrayBindingPattern */); // var [...z| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 155 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 122 /* AsKeyword */: + return containingNodeKind === 257 /* ImportSpecifier */ || + containingNodeKind === 261 /* ExportSpecifier */ || + containingNodeKind === 255 /* NamespaceImport */; + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 111 /* InterfaceKeyword */: - case 91 /* FunctionKeyword */: - case 106 /* VarKeyword */: - case 93 /* ImportKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 118 /* YieldKeyword */: - case 141 /* TypeKeyword */: // type htm| + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 113 /* InterfaceKeyword */: + case 93 /* FunctionKeyword */: + case 108 /* VarKeyword */: + case 95 /* ImportKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 120 /* YieldKeyword */: + case 144 /* TypeKeyword */: // type htm| return true; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -103158,22 +107864,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 119 /* AbstractKeyword */: - case 77 /* ClassKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 91 /* FunctionKeyword */: - case 111 /* InterfaceKeyword */: - case 112 /* LetKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 117 /* StaticKeyword */: - case 106 /* VarKeyword */: - case 118 /* YieldKeyword */: + case 121 /* AbstractKeyword */: + case 79 /* ClassKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 93 /* FunctionKeyword */: + case 113 /* InterfaceKeyword */: + case 114 /* LetKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 119 /* StaticKeyword */: + case 108 /* VarKeyword */: + case 120 /* YieldKeyword */: return true; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -103183,7 +107889,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 161 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -103202,16 +107908,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); 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 !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 279 /* PropertyAssignment */ && + m.kind !== 280 /* ShorthandPropertyAssignment */ && + m.kind !== 190 /* BindingElement */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */ && + m.kind !== 281 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103219,9 +107927,12 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 73 /* Identifier */) { + if (m.propertyName.kind === 75 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -103234,7 +107945,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -103246,10 +107990,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 !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 158 /* PropertyDeclaration */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103283,17 +108027,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 271 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -103304,7 +108054,7 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.startsWithQuote(name) + || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; @@ -103333,7 +108083,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 76 /* FirstKeyword */; i <= 151 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -103359,9 +108109,9 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 126 /* DeclareKeyword */ - || kind === 131 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 142 /* UndefinedKeyword */; + || kind === 129 /* DeclareKeyword */ + || kind === 134 /* ModuleKeyword */ + || ts.isTypeKeyword(kind) && kind !== 145 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -103371,7 +108121,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 78 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 80 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -103381,55 +108131,55 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 121 /* AnyKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 146 /* GlobalKeyword */: - case 110 /* ImplementsKeyword */: - case 128 /* InferKeyword */: - case 111 /* InterfaceKeyword */: - case 129 /* IsKeyword */: - case 130 /* KeyOfKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 133 /* NeverKeyword */: - case 136 /* NumberKeyword */: - case 137 /* ObjectKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: - case 139 /* StringKeyword */: - case 140 /* SymbolKeyword */: - case 141 /* TypeKeyword */: - case 143 /* UniqueKeyword */: - case 144 /* UnknownKeyword */: + case 121 /* AbstractKeyword */: + case 124 /* AnyKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 149 /* GlobalKeyword */: + case 112 /* ImplementsKeyword */: + case 131 /* InferKeyword */: + case 113 /* InterfaceKeyword */: + case 132 /* IsKeyword */: + case 133 /* KeyOfKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 136 /* NeverKeyword */: + case 139 /* NumberKeyword */: + case 140 /* ObjectKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: + case 142 /* StringKeyword */: + case 143 /* SymbolKeyword */: + case 144 /* TypeKeyword */: + case 146 /* UniqueKeyword */: + case 147 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 134 /* ReadonlyKeyword */; + return kind === 137 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 125 /* ConstructorKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 122 /* AsyncKeyword */: + case 121 /* AbstractKeyword */: + case 128 /* ConstructorKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 125 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 122 /* AsyncKeyword */ - || kind === 123 /* AwaitKeyword */ + return kind === 125 /* AsyncKeyword */ + || kind === 126 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -103467,7 +108217,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 313 /* SyntaxList */: + case 317 /* 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); @@ -103475,7 +108225,7 @@ var ts; return cls; } break; - case 73 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } + case 75 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } if (isFromObjectTypeDeclaration(location)) { return ts.findAncestor(location, ts.isObjectTypeDeclaration); } @@ -103501,7 +108251,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -103521,11 +108271,11 @@ var ts; return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -103534,6 +108284,14 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } + function findAlias(typeChecker, symbol, predicate) { + var currentAlias = symbol; + while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { + if (predicate(currentAlias)) { + return currentAlias; + } + } + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -103586,40 +108344,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 92 /* IfKeyword */: - case 84 /* ElseKeyword */: + case 94 /* IfKeyword */: + case 86 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 98 /* ReturnKeyword */: + case 100 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 104 /* TryKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: - var tryStatement = node.kind === 76 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 106 /* TryKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: + var tryStatement = node.kind === 78 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 75 /* CaseKeyword */: - case 81 /* DefaultKeyword */: + case 77 /* CaseKeyword */: + case 83 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 74 /* BreakKeyword */: - case 79 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 81 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 90 /* ForKeyword */: - case 108 /* WhileKeyword */: - case 83 /* DoKeyword */: + case 92 /* ForKeyword */: + case 110 /* WhileKeyword */: + case 85 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 125 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [125 /* ConstructorKeyword */]); - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [127 /* GetKeyword */, 138 /* SetKeyword */]); - case 123 /* AwaitKeyword */: + case 128 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [128 /* ConstructorKeyword */]); + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [130 /* GetKeyword */, 141 /* SetKeyword */]); + case 126 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 118 /* YieldKeyword */: + case 120 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -103662,7 +108420,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 288 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -103694,16 +108452,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 236 /* SwitchStatement */: + if (statement.kind === 232 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -103719,35 +108477,37 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 222 /* Block */: + case 275 /* CaseClause */: + case 276 /* 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]); + return __spreadArrays(declaration.members, [declaration]); } else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 172 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 28 /* AccessibilityModifier */) { + if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { - return nodes.concat(constructor.parameters); + return __spreadArrays(nodes, constructor.parameters); } } else if (modifierFlag & 128 /* Abstract */) { - return nodes.concat([container]); + return __spreadArrays(nodes, [container]); } return nodes; default: @@ -103767,12 +108527,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 92 /* ForKeyword */, 110 /* WhileKeyword */, 85 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 227 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 110 /* WhileKeyword */)) { break; } } @@ -103780,7 +108540,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */, 79 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */, 81 /* ContinueKeyword */); } }); return keywords; @@ -103789,13 +108549,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -103803,13 +108563,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 100 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 102 /* 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(), 75 /* CaseKeyword */, 81 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 77 /* CaseKeyword */, 83 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */); } }); }); @@ -103817,13 +108577,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 104 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 106 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 76 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 78 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 89 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 91 /* FinallyKeyword */); } return keywords; } @@ -103834,13 +108594,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* 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, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -103852,11 +108612,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* 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, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -103868,13 +108628,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 122 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 125 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 123 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 126 /* AwaitKeyword */); } }); }); @@ -103889,7 +108649,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 118 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 120 /* YieldKeyword */); } }); }); @@ -103908,7 +108668,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 === 84 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 86 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -103943,10 +108703,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], 92 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 94 /* 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], 84 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 86 /* ElseKeyword */)) { break; } } @@ -104162,12 +108922,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 241 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { directImports.push(name); break; } @@ -104176,22 +108936,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 73 /* Identifier */: // for 'const x = require("y"); + case 75 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 255 /* 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 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -104201,7 +108961,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 187 /* ImportType */: directImports.push(direct); break; default: @@ -104218,7 +108978,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 288 /* SourceFile */ || sourceFileLike.kind === 248 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -104273,17 +109033,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 252 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 73 /* Identifier */) { + if (decl.kind === 75 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 187 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -104298,17 +109058,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 259 /* 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 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -104358,7 +109118,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 261 /* 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); @@ -104387,7 +109147,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 === 285 /* SourceFile */) { + if (searchSourceFile.kind === 288 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -104435,7 +109195,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 === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 288 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -104450,15 +109210,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -104472,7 +109232,7 @@ var ts; /** * Given a local reference, we might notice that it's an import/export and recursively search for references of that. * If at an import, look locally for the symbol it imports. - * If an an export, look for all imports of it. + * If at an export, look for all imports of it. * This doesn't handle export specifiers; that is done in `getReferencesAtExportSpecifier`. * @param comingFromExport If we are doing a search for all exports, don't bother looking backwards for the imported symbol, since that's the reason we're here. */ @@ -104482,7 +109242,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 193 /* 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) @@ -104604,10 +109364,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 === 238 /* VariableDeclaration */) { - var p = parent; - return p.name !== node ? undefined : - p.parent.kind === 275 /* CatchClause */ ? undefined : p.parent.parent.kind === 220 /* VariableStatement */ ? p.parent.parent : undefined; + var declaration = ts.isVariableDeclaration(parent) ? parent : ts.isBindingElement(parent) ? ts.walkUpBindingElementsAndPatterns(parent) : undefined; + if (declaration) { + return parent.name !== node ? undefined : + ts.isCatchClause(declaration.parent) ? undefined : ts.isVariableStatement(declaration.parent.parent) ? declaration.parent.parent : undefined; } else { return parent; @@ -104616,13 +109376,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -104655,21 +109415,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 288 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 249 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 248 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 263 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -104718,7 +109478,7 @@ var ts; if (ts.isInJSFile(node)) { var binaryExpression = ts.isBinaryExpression(node.parent) ? node.parent : - ts.isPropertyAccessExpression(node.parent) && + ts.isAccessExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && node.parent.parent.left === node.parent ? node.parent.parent : @@ -104762,7 +109522,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 81 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 83 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -104771,7 +109531,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -104779,27 +109539,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -104843,18 +109603,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* 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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 99 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 101 /* 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); @@ -104934,16 +109694,16 @@ var ts; return { displayParts: displayParts, kind: symbolKind }; } function toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixText) { - return __assign({}, entryToDocumentSpan(entry), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); + return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); } FindAllReferences.toRenameLocation = toRenameLocation; function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); if (entry.kind === 0 /* Span */) { - return __assign({}, documentSpan, { isWriteAccess: false, isDefinition: false }); + return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign({}, documentSpan, { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 83 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -104987,10 +109747,10 @@ var ts; var documentSpan = entryToDocumentSpan(entry); if (entry.kind !== 0 /* Span */) { var node = entry.node; - return __assign({}, documentSpan, implementationKindDisplayParts(node, checker)); + return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign({}, documentSpan, { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -104998,13 +109758,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 213 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -105033,7 +109793,7 @@ var ts; function getTextSpan(node, sourceFile, endNode) { var start = node.getStart(sourceFile); var end = (endNode || node).getEnd(); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { ts.Debug.assert(endNode === undefined); start += 1; end -= 1; @@ -105048,7 +109808,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 === 81 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 83 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -105056,49 +109816,49 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 4194304 /* Ambient */)) + if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 208 /* BinaryExpression */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 83 /* DefaultKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 261 /* ExportSpecifier */: + case 254 /* ImportClause */: // default import + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 245 /* InterfaceDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 271 /* JsxAttribute */: + case 248 /* ModuleDeclaration */: + case 251 /* NamespaceExportDeclaration */: + case 255 /* NamespaceImport */: + case 155 /* Parameter */: + case 280 /* ShorthandPropertyAssignment */: + case 246 /* TypeAliasDeclaration */: + case 154 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 159 /* MethodSignature */: + case 157 /* PropertySignature */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -105258,10 +110018,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 288 /* 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 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -105278,21 +110038,32 @@ var ts; 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, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 88 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } } return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } + /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ + function isReadonlyTypeOperator(node) { + return node.kind === 137 /* ReadonlyKeyword */ + && ts.isTypeOperatorNode(node.parent) + && node.parent.operator === 137 /* ReadonlyKeyword */; + } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + // A modifier readonly (like on a property declaration) is not special; + // a readonly type keyword (like `readonly string[]`) is. + if (node.kind === 137 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + return undefined; + } + // Likewise, when we *are* looking for a special keyword, make sure we + // *don’t* include readonly member modifiers. + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 137 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -105308,7 +110079,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -105325,7 +110096,7 @@ var ts; // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 81 /* DefaultKeyword */) { + else if (node && node.kind === 83 /* 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); } @@ -105353,9 +110124,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: return 1 /* Constructor */; - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -105591,7 +110362,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 === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 200 /* FunctionExpression */ || valueDeclaration.kind === 213 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -105601,7 +110372,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, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 244 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -105630,7 +110401,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 288 /* 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; @@ -105651,7 +110422,7 @@ var ts; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { - var symbol = ts.isParameterPropertyDeclaration(definition.parent) + var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) @@ -105738,8 +110509,9 @@ 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 73 /* Identifier */: + case 75 /* Identifier */: return node.text.length === searchSymbolName.length; + case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && @@ -105747,17 +110519,19 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 81 /* DefaultKeyword */: + case 83 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; } } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, ts.tokenToString(keywordKind), sourceFile), function (referenceLocation) { - return referenceLocation.kind === keywordKind ? FindAllReferences.nodeEntry(referenceLocation) : undefined; + if (referenceLocation.kind === keywordKind && (!filter || filter(referenceLocation))) { + return FindAllReferences.nodeEntry(referenceLocation); + } }); }); return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; @@ -105811,7 +110585,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 73 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 75 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -105867,8 +110641,8 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 81 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 81 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 83 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 83 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.assertDefined(exportSpecifier.symbol); var exportInfo = ts.Debug.assertDefined(FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker)); @@ -105931,7 +110705,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -105947,7 +110721,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 81 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 83 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -105974,7 +110748,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 101 /* ThisKeyword */) { + if (node.kind === 103 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -105993,18 +110767,18 @@ var ts; if (constructorSymbol) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 128 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 161 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 160 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 103 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -106025,10 +110799,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 161 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 101 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -106052,10 +110826,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 73 /* Identifier */) { + if (refNode.kind !== 75 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 280 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -106075,7 +110849,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 222 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -106103,13 +110877,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 191 /* ArrayLiteralExpression */: return true; default: return false; @@ -106162,13 +110936,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -106177,7 +110951,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 99 /* SuperKeyword */) { + if (node.kind !== 101 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -106189,41 +110963,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 75 /* Identifier */ && node.parent.kind === 155 /* Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 288 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -106231,19 +111005,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* 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 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 288 /* SourceFile */: + return container.kind === 288 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -106320,7 +111094,7 @@ var ts; var res = fromRoot(symbol); if (res) return res; - if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] @@ -106362,7 +111136,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 190 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -106412,11 +111186,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 8388608 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -106466,12 +111239,12 @@ var ts; /* @internal */ var ts; (function (ts) { - function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, _preferences, sourceMapper) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences, sourceMapper) { var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); 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) { + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, function (changeTracker) { updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); @@ -106719,9 +111492,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? [sigInfo].concat(defs) : defs.concat([sigInfo]); + return node.kind === 101 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -106729,7 +111502,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 === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -106882,35 +111655,39 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 73 /* Identifier */) { + if (node.kind !== 75 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 257 /* ImportSpecifier */: + return declaration.parent.kind === 256 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { - return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(symbol.declarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { + // There are cases when you extend a function by adding properties to it afterwards, + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; + return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); 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 === 125 /* ConstructorKeyword */)) { - var cls = ts.find(symbol.declarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 128 /* ConstructorKeyword */)) { + var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } } function getCallSignatureDefinition() { return ts.isCallOrNewExpressionTarget(node) || ts.isNameOfFunctionDeclaration(node) - ? getSignatureDefinition(symbol.declarations, /*selectConstructors*/ false) + ? getSignatureDefinition(filteredDeclarations, /*selectConstructors*/ false) : undefined; } function getSignatureDefinition(signatureDeclarations, selectConstructors) { @@ -106918,8 +111695,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -106972,9 +111753,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return true; default: return false; @@ -107092,11 +111873,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return [declaration]; - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -107117,16 +111898,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return withNode(tag.class); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -107303,7 +112084,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 === 73 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 75 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -107313,23 +112094,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 159 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 157 /* PropertySignature */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 246 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -107337,14 +112118,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 288 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 248 /* 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 === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 248 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 208 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -107363,14 +112144,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 199 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 213 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -107432,9 +112213,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -107444,7 +112225,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 153 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -107461,7 +112242,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 === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 153 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -107505,6 +112286,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -107519,6 +112301,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -107529,13 +112316,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -107561,7 +112350,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -107586,28 +112375,56 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isPropertyNameLiteral(entityName)) { + var name = ts.getNameOrArgument(entityName); + var nameText = ts.getElementOrPropertyAccessName(entityName); + entityName = entityName.expression; + if (nameText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -107617,46 +112434,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* 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); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; - if (ts.isParameterPropertyDeclaration(param)) { + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; + if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 159 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -107668,90 +112487,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 280 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 281 /* SpreadAssignment */: + var expression = node.expression; + // Use the expression as the name of the SpreadAssignment, otherwise show as . + ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); + break; + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: + case 241 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + addNodeWithRecursiveChild(node, node.body); + break; + case 247 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 261 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 166 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 246 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && ts.getElementOrPropertyAccessName(assignmentTarget) !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else if (ts.isBindableStaticAccessExpression(assignmentTarget)) { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, ts.getNameOrArgument(assignmentTarget)); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -107774,8 +112671,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -107789,7 +112686,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -107798,7 +112695,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -107806,7 +112703,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -107819,12 +112809,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -107840,7 +112830,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 !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 248 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -107870,7 +112860,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 248 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -107878,35 +112868,37 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 248 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text + : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -107914,24 +112906,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 164 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -107941,28 +112936,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 246 /* TypeAliasDeclaration */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -107972,21 +112967,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -107999,18 +112988,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -108041,7 +113030,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 === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -108055,13 +113044,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 153 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 288 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 241 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -108069,14 +113058,14 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(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 === 60 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -108093,7 +113082,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -108114,14 +113107,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -108135,8 +113138,8 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, _preferences) { - var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext }); + function organizeImports(sourceFile, formatContext, host, program, preferences) { + var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); var coalesceAndOrganizeImports = function (importGroup) { return coalesceImports(removeUnusedImports(importGroup, sourceFile, program)); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); @@ -108464,7 +113467,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 93 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 95 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -108581,7 +113584,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -108589,23 +113592,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 227 /* DoStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 278 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 239 /* 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, 89 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -108613,24 +113616,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 250 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -108672,7 +113675,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 201 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -109207,10 +114210,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 126 /* DeclareKeyword */) { + if (token === 129 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 131 /* ModuleKeyword */) { + if (token === 134 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -109228,7 +114231,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 93 /* ImportKeyword */) { + if (token === 95 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -109244,9 +114247,9 @@ var ts; return true; } else { - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -109254,7 +114257,7 @@ var ts; return true; } } - else if (token === 60 /* EqualsToken */) { + else if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -109277,7 +114280,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -109287,13 +114290,13 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 120 /* AsKeyword */) { + if (token === 122 /* AsKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -109311,7 +114314,7 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 86 /* ExportKeyword */) { + if (token === 88 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); if (token === 18 /* OpenBraceToken */) { @@ -109323,7 +114326,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -109333,9 +114336,9 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -109343,11 +114346,11 @@ var ts; } } } - else if (token === 93 /* ImportKeyword */) { + else if (token === 95 /* ImportKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 60 /* EqualsToken */) { + if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -109360,7 +114363,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 135 /* RequireKeyword */) { + if (token === 138 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -109375,7 +114378,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 73 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 75 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -109509,14 +114512,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 === 81 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 83 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 153 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -109563,7 +114566,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { // Exclude the quotes start += 1; width -= 2; @@ -109572,9 +114575,10 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -109605,7 +114609,7 @@ var ts; if (node.getStart(sourceFile) > pos) { break outer; } - if (positionShouldSnapToNode(pos, node, nextNode)) { + if (positionShouldSnapToNode(sourceFile, pos, node)) { // 1. Blocks are effectively redundant with SyntaxLists. // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping // of things that should be considered independently. @@ -109614,7 +114618,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -109677,12 +114681,11 @@ var ts; * count too, unless that position belongs to the next node. In effect, makes * selections able to snap to preceding tokens when the cursor is on the tail * end of them with only whitespace ahead. + * @param sourceFile The source file containing the nodes. * @param pos The position to check. * @param node The candidate node to snap to. - * @param nextNode The next sibling node in the tree. - * @param sourceFile The source file containing the nodes. */ - function positionShouldSnapToNode(pos, node, nextNode) { + function positionShouldSnapToNode(sourceFile, pos, node) { // Can’t use 'ts.positionBelongsToNode()' here because it cleverly accounts // for missing nodes, which can’t really be considered when deciding what // to select. @@ -109691,9 +114694,8 @@ var ts; return true; } var nodeEnd = node.getEnd(); - var nextNodeStart = nextNode && nextNode.getStart(); if (nodeEnd === pos) { - return pos !== nextNodeStart; + return ts.getTouchingPropertyName(sourceFile, pos).pos < node.end; } return false; } @@ -109728,14 +114730,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 134 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 56 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 137 /* ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 154 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -109743,7 +114745,7 @@ var ts; // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; })), closeBraceToken, ]; @@ -109755,7 +114757,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -109768,14 +114770,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } return node.getChildren(); @@ -109842,7 +114844,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(313 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(317 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -109851,14 +114853,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 266 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 267 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -109951,7 +114953,7 @@ var ts; var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -110010,7 +115012,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* 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 }; @@ -110063,10 +115065,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 197 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 210 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -110133,17 +115135,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 199 /* ParenthesizedExpression */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* 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 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -110214,11 +115216,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -110267,7 +115269,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 === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -110332,14 +115334,14 @@ 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(28 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(29 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } 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); - var suffixDisplayParts = suffix.concat(returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); + var prefixDisplayParts = __spreadArrays(callTargetDisplayParts, prefix); + var suffixDisplayParts = __spreadArrays(suffix, returnTypeToDisplayParts(candidateSignature, enclosingDeclaration, checker)); var documentation = candidateSignature.getDocumentationComment(checker); var tags = candidateSignature.getJsDocTags(); return { isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; @@ -110363,10 +115365,10 @@ var ts; var parameters = (typeParameters || ts.emptyArray).map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var parameterParts = ts.mapToDisplayParts(function (writer) { var thisParameter = candidateSignature.thisParameter ? [checker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: [ts.punctuationPart(30 /* GreaterThanToken */)].concat(parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -110378,7 +115380,7 @@ var ts; } }); var parameters = checker.getExpandedParameters(candidateSignature).map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }); - return { isVariadic: isVariadic, parameters: parameters, prefix: typeParameterParts.concat([ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; + return { isVariadic: isVariadic, parameters: parameters, prefix: __spreadArrays(typeParameterParts, [ts.punctuationPart(20 /* OpenParenToken */)]), suffix: [ts.punctuationPart(21 /* CloseParenToken */)] }; } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -110442,6 +115444,10 @@ var ts; if (!sourceFile) return undefined; var program = host.getProgram(); + // If this is source file of project reference source (instead of redirect) there is no generated position + if (program.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) { + return undefined; + } var options = program.getCompilerOptions(); var outPath = options.outFile || options.out; var declarationPath = outPath ? @@ -110579,7 +115585,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -110589,7 +115595,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 243 /* 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)); @@ -110622,11 +115628,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -110643,12 +115649,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 255 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -110706,13 +115712,13 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ - case 97 /* NullKeyword */: - case 73 /* Identifier */: // identifier includes undefined + // falls through + case 99 /* NullKeyword */: + case 75 /* Identifier */: // identifier includes undefined return true; default: return false; @@ -110735,7 +115741,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -110772,7 +115778,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 101 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 103 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -110823,11 +115829,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 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + return location.kind === 75 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 271 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -110854,13 +115860,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 === 101 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 103 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 101 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(101 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 103 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(103 /* 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 */) { @@ -110870,7 +115876,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 193 /* 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)) { @@ -110890,7 +115896,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 196 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 101 /* 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 @@ -110908,7 +115914,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -110925,14 +115931,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(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* 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(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -110945,29 +115951,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 128 /* ConstructorKeyword */ && location.parent.kind === 161 /* 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 === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 128 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 161 /* 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 === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 161 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 164 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -110977,7 +115983,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 213 /* 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 @@ -110985,7 +115991,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(77 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(79 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -110993,37 +115999,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(111 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(113 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* 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(78 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(80 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(85 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(87 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 248 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 75 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 135 /* NamespaceKeyword */ : 134 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -111042,7 +116048,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 154 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -111050,21 +116056,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + if (declaration.kind === 165 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 164 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 246 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -111076,11 +116082,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 282 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -111106,32 +116112,32 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 251 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(135 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 258 /* ExportAssignment */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 83 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 261 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(93 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(95 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 252 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(135 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(138 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -111140,7 +116146,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -111154,7 +116160,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(101 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(103 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -111165,7 +116171,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -111203,10 +116209,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 === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 288 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 208 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -111249,7 +116255,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(94 /* InKeyword */)); + displayParts.push(ts.keywordPart(96 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -111259,7 +116265,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(56 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -111294,7 +116300,7 @@ var ts; if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(38 /* PlusToken */)); + displayParts.push(ts.operatorPart(39 /* 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")); @@ -111319,16 +116325,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 200 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 241 /* VariableDeclaration */ && declaration.kind !== 243 /* 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 === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 288 /* SourceFile */ || parent.kind === 249 /* ModuleBlock */) { return false; } } @@ -111351,32 +116357,24 @@ var ts; */ function transpileModule(input, transpileOptions) { var diagnostics = []; - var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : ts.getDefaultCompilerOptions(); - options.isolatedModules = true; + var options = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : {}; + // mix in default options + var defaultOptions = ts.getDefaultCompilerOptions(); + for (var key in defaultOptions) { + if (ts.hasProperty(defaultOptions, key) && options[key] === undefined) { + options[key] = defaultOptions[key]; + } + } + for (var _i = 0, transpileOptionValueCompilerOptions_1 = ts.transpileOptionValueCompilerOptions; _i < transpileOptionValueCompilerOptions_1.length; _i++) { + var option = transpileOptionValueCompilerOptions_1[_i]; + options[option.name] = option.transpileOptionValue; + } // transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths. options.suppressOutputPathCheck = true; // Filename can be non-ts file. options.allowNonTsExtensions = true; - // We are not returning a sourceFile for lib file when asked by the program, - // so pass --noLib to avoid reporting a file not found error. - options.noLib = true; - // Clear out other settings that would not be used in transpiling this module - options.lib = undefined; - options.types = undefined; - options.noEmit = undefined; - options.noEmitOnError = undefined; - options.paths = undefined; - options.rootDirs = undefined; - options.declaration = undefined; - options.composite = undefined; - options.declarationDir = undefined; - options.out = undefined; - options.outFile = undefined; - // We are not doing a full typecheck, we are not resolving the whole context, - // so pass --noResolve to avoid reporting missing file errors. - options.noResolve = true; // if jsx is specified then treat file as .tsx - var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); + var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts"); var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; @@ -111581,7 +116579,9 @@ var ts; var res = cb({ advance: advance, readTokenInfo: readTokenInfo, + readEOFTokenRange: readEOFTokenRange, isOnToken: isOnToken, + isOnEOF: isOnEOF, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, @@ -111621,11 +116621,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 32 /* GreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -111633,12 +116633,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 271 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* 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 === 73 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 75 /* Identifier */; } } return false; @@ -111654,23 +116654,18 @@ var ts; container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 42 /* SlashToken */ || t === 65 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -111687,11 +116682,7 @@ var ts; scanner.scan(); } var currentToken = getNextToken(n, expectedScanAction); - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var token = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); // consume trailing trivia if (trailingTrivia) { trailingTrivia = undefined; @@ -111701,11 +116692,7 @@ var ts; if (!ts.isTrivia(currentToken)) { break; } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var trivia = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); if (!trailingTrivia) { trailingTrivia = []; } @@ -111724,7 +116711,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -111758,11 +116745,19 @@ var ts; } return token; } + function readEOFTokenRange() { + ts.Debug.assert(isOnEOF()); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); } + function isOnEOF() { + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + return current === 1 /* EndOfFileToken */; + } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, // then kind needs to be fixed. This might happen in cases @@ -111794,10 +116789,16 @@ var ts; formatting.anyContext = ts.emptyArray; var RuleAction; (function (RuleAction) { - RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; - RuleAction[RuleAction["Space"] = 2] = "Space"; - RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; - RuleAction[RuleAction["Delete"] = 8] = "Delete"; + RuleAction[RuleAction["StopProcessingSpaceActions"] = 1] = "StopProcessingSpaceActions"; + RuleAction[RuleAction["StopProcessingTokenActions"] = 2] = "StopProcessingTokenActions"; + RuleAction[RuleAction["InsertSpace"] = 4] = "InsertSpace"; + RuleAction[RuleAction["InsertNewLine"] = 8] = "InsertNewLine"; + RuleAction[RuleAction["DeleteSpace"] = 16] = "DeleteSpace"; + RuleAction[RuleAction["DeleteToken"] = 32] = "DeleteToken"; + RuleAction[RuleAction["InsertTrailingSemicolon"] = 64] = "InsertTrailingSemicolon"; + RuleAction[RuleAction["StopAction"] = 3] = "StopAction"; + RuleAction[RuleAction["ModifySpaceAction"] = 28] = "ModifySpaceAction"; + RuleAction[RuleAction["ModifyTokenAction"] = 96] = "ModifyTokenAction"; })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); var RuleFlags; (function (RuleFlags) { @@ -111813,8 +116814,10 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { - allTokens.push(token); + for (var token = 0 /* FirstToken */; token <= 151 /* LastToken */; token++) { + if (token !== 1 /* EndOfFileToken */) { + allTokens.push(token); + } } function anyTokenExcept() { var tokens = []; @@ -111824,259 +116827,262 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; - var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArrays(allTokens, [1 /* EndOfFileToken */])); + var keywords = tokenRangeFromRange(76 /* FirstKeyword */, 151 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 74 /* LastBinaryOperator */); + var binaryKeywordOperators = [96 /* InKeyword */, 97 /* InstanceOfKeyword */, 151 /* OfKeyword */, 122 /* AsKeyword */, 132 /* IsKeyword */]; + var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 75 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostincrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; - var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; + var unaryPreincrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostincrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; + var unaryPredecrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostdecrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = [73 /* Identifier */].concat(ts.typeKeywords); + var typeNames = __spreadArrays([75 /* Identifier */], 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([73 /* Identifier */, 3 /* MultiLineCommentTrivia */, 77 /* ClassKeyword */, 86 /* ExportKeyword */, 93 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([75 /* Identifier */, 3 /* MultiLineCommentTrivia */, 79 /* ClassKeyword */, 88 /* ExportKeyword */, 95 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 83 /* DoKeyword */, 104 /* TryKeyword */, 89 /* FinallyKeyword */, 84 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 85 /* DoKeyword */, 106 /* TryKeyword */, 91 /* FinallyKeyword */, 86 /* 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, 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 */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), // in other cases there should be no space between '?' and next token - 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", 93 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 95 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 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 */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 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 */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 84 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 108 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 86 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 110 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 91 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, 73 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 91 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 93 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 75 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 93 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [127 /* GetKeyword */, 138 /* SetKeyword */], 73 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 118 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [118 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 98 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [106 /* VarKeyword */, 102 /* ThrowKeyword */, 96 /* NewKeyword */, 82 /* DeleteKeyword */, 98 /* ReturnKeyword */, 105 /* TypeOfKeyword */, 123 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [112 /* LetKeyword */, 78 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [130 /* GetKeyword */, 141 /* SetKeyword */], 75 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 120 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [120 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 100 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterCertainKeywords", [108 /* VarKeyword */, 104 /* ThrowKeyword */, 98 /* NewKeyword */, 84 /* DeleteKeyword */, 100 /* ReturnKeyword */, 107 /* TypeOfKeyword */, 126 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [114 /* LetKeyword */, 80 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 107 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 109 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 122 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 122 /* AsyncKeyword */, 91 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 125 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 125 /* AsyncKeyword */, 93 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [73 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [75 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 73 /* 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, 60 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 60 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 75 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [131 /* ModuleKeyword */, 135 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [134 /* ModuleKeyword */, 138 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 119 /* AbstractKeyword */, - 77 /* ClassKeyword */, - 126 /* DeclareKeyword */, - 81 /* DefaultKeyword */, - 85 /* EnumKeyword */, - 86 /* ExportKeyword */, - 87 /* ExtendsKeyword */, - 127 /* GetKeyword */, - 110 /* ImplementsKeyword */, - 93 /* ImportKeyword */, - 111 /* InterfaceKeyword */, - 131 /* ModuleKeyword */, - 132 /* NamespaceKeyword */, - 114 /* PrivateKeyword */, - 116 /* PublicKeyword */, - 115 /* ProtectedKeyword */, - 134 /* ReadonlyKeyword */, - 138 /* SetKeyword */, - 117 /* StaticKeyword */, - 141 /* TypeKeyword */, - 145 /* FromKeyword */, - 130 /* KeyOfKeyword */, - 128 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [87 /* ExtendsKeyword */, 110 /* ImplementsKeyword */, 145 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + 121 /* AbstractKeyword */, + 79 /* ClassKeyword */, + 129 /* DeclareKeyword */, + 83 /* DefaultKeyword */, + 87 /* EnumKeyword */, + 88 /* ExportKeyword */, + 89 /* ExtendsKeyword */, + 130 /* GetKeyword */, + 112 /* ImplementsKeyword */, + 95 /* ImportKeyword */, + 113 /* InterfaceKeyword */, + 134 /* ModuleKeyword */, + 135 /* NamespaceKeyword */, + 116 /* PrivateKeyword */, + 118 /* PublicKeyword */, + 117 /* ProtectedKeyword */, + 137 /* ReadonlyKeyword */, + 141 /* SetKeyword */, + 119 /* StaticKeyword */, + 144 /* TypeKeyword */, + 148 /* FromKeyword */, + 133 /* KeyOfKeyword */, + 131 /* InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [89 /* ExtendsKeyword */, 112 /* ImplementsKeyword */, 148 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 73 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 75 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), // generics and type assertions - 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 */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 73 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 75 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 119 /* AbstractKeyword */, - 73 /* Identifier */, - 86 /* ExportKeyword */, - 81 /* DefaultKeyword */, - 77 /* ClassKeyword */, - 117 /* StaticKeyword */, - 116 /* PublicKeyword */, - 114 /* PrivateKeyword */, - 115 /* ProtectedKeyword */, - 127 /* GetKeyword */, - 138 /* SetKeyword */, + 121 /* AbstractKeyword */, + 75 /* Identifier */, + 88 /* ExportKeyword */, + 83 /* DefaultKeyword */, + 79 /* ClassKeyword */, + 119 /* StaticKeyword */, + 118 /* PublicKeyword */, + 116 /* PrivateKeyword */, + 117 /* ProtectedKeyword */, + 130 /* GetKeyword */, + 141 /* SetKeyword */, 22 /* OpenBracketToken */, - 40 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 96 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 28 /* LessThanToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + 41 /* AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 98 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 125 /* 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 */), + rule("SpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 4 /* InsertSpace */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - 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 */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty brackets - 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 */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 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 */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing template string braces - 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 */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space after { and before } in JSX expression - 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 */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), // 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, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 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, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - 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 */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 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 */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(122 /* AsyncKeyword */, 75 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(125 /* AsyncKeyword */, 77 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 90 /* ForKeyword */, 123 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 92 /* ForKeyword */, 126 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 83 /* DoKeyword */, 84 /* ElseKeyword */, 75 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 85 /* DoKeyword */, 86 /* ElseKeyword */, 77 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [106 /* TryKeyword */, 91 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; - return highPriorityCommonRules.concat(userConfigurableRules, lowPriorityCommonRules); + return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } formatting.getAllRules = getAllRules; /** @@ -112114,6 +117120,9 @@ var ts; /// /// Contexts /// + function optionEquals(optionName, optionValue) { + return function (context) { return context.options && context.options[optionName] === optionValue; }; + } function isOptionEnabled(optionName) { return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; }; } @@ -112130,45 +117139,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 229 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 179 /* ConditionalType */: + case 216 /* AsExpression */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 167 /* TypePredicate */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 190 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 252 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 241 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 155 /* Parameter */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: - return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 154 /* TypeParameter */: + return context.currentTokenSpan.kind === 96 /* InKeyword */ || context.nextTokenSpan.kind === 96 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 231 /* ForOfStatement */: + return context.currentTokenSpan.kind === 151 /* OfKeyword */ || context.nextTokenSpan.kind === 151 /* OfKeyword */; } return false; } @@ -112180,22 +117194,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 158 /* PropertyDeclaration */ || + contextKind === 157 /* PropertySignature */ || + contextKind === 155 /* Parameter */ || + contextKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 209 /* ConditionalExpression */ || + context.contextNode.kind === 179 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 188 /* ObjectBindingPattern */ || + context.contextNode.kind === 185 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -112221,31 +117235,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 192 /* ObjectLiteralExpression */: + case 249 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 164 /* CallSignature */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 201 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 245 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -112254,40 +117271,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 243 /* FunctionDeclaration */ || context.contextNode.kind === 200 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 172 /* TypeLiteral */: + case 248 /* ModuleDeclaration */: + case 259 /* ExportDeclaration */: + case 260 /* NamedExports */: + case 253 /* ImportDeclaration */: + case 256 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 278 /* CatchClause */: + case 249 /* ModuleBlock */: + case 236 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 222 /* 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 !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 201 /* ArrowFunction */ && blockParent.kind !== 200 /* FunctionExpression */) { return true; } } @@ -112296,31 +117313,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 235 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 278 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 192 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 195 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 196 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -112332,28 +117350,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 201 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 187 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 264 /* JsxElement */ && context.contextNode.kind !== 268 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 274 /* JsxExpression */ || context.contextNode.kind === 273 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 271 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 271 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 265 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -112368,45 +117386,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 242 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 248 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 172 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 165 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { + if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 198 /* TypeAssertionExpression */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -112417,16 +117435,78 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 198 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 109 /* VoidKeyword */ && context.currentTokenParent.kind === 204 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 211 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 217 /* NonNullExpression */; + } + function isSemicolonDeletionContext(context) { + var nextTokenKind = context.nextTokenSpan.kind; + var nextTokenStart = context.nextTokenSpan.pos; + if (ts.isTrivia(nextTokenKind)) { + var nextRealToken = context.nextTokenParent === context.currentTokenParent + ? ts.findNextToken(context.currentTokenParent, ts.findAncestor(context.currentTokenParent, function (a) { return !a.parent; }), context.sourceFile) + : context.nextTokenParent.getFirstToken(context.sourceFile); + if (!nextRealToken) { + return true; + } + nextTokenKind = nextRealToken.kind; + nextTokenStart = nextRealToken.getStart(context.sourceFile); + } + var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; + var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; + if (startLine === endLine) { + return nextTokenKind === 19 /* CloseBraceToken */ + || nextTokenKind === 1 /* EndOfFileToken */; + } + if (nextTokenKind === 221 /* SemicolonClassElement */ || + nextTokenKind === 26 /* SemicolonToken */) { + return false; + } + if (context.contextNode.kind === 245 /* InterfaceDeclaration */ || + context.contextNode.kind === 246 /* TypeAliasDeclaration */) { + // Can’t remove semicolon after `foo`; it would parse as a method declaration: + // + // interface I { + // foo; + // (): void + // } + return !ts.isPropertySignature(context.currentTokenParent) + || !!context.currentTokenParent.type + || nextTokenKind !== 20 /* OpenParenToken */; + } + if (ts.isPropertyDeclaration(context.currentTokenParent)) { + return !context.currentTokenParent.initializer; + } + return context.currentTokenParent.kind !== 229 /* ForStatement */ + && context.currentTokenParent.kind !== 223 /* EmptyStatement */ + && context.currentTokenParent.kind !== 221 /* SemicolonClassElement */ + && nextTokenKind !== 22 /* OpenBracketToken */ + && nextTokenKind !== 20 /* OpenParenToken */ + && nextTokenKind !== 39 /* PlusToken */ + && nextTokenKind !== 40 /* MinusToken */ + && nextTokenKind !== 43 /* SlashToken */ + && nextTokenKind !== 13 /* RegularExpressionLiteral */ + && nextTokenKind !== 27 /* CommaToken */ + && nextTokenKind !== 210 /* TemplateExpression */ + && nextTokenKind !== 15 /* TemplateHead */ + && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* DotToken */; + } + function isSemicolonInsertionContext(context) { + var contextAncestor = ts.findAncestor(context.currentTokenParent, function (ancestor) { + if (ancestor.end !== context.currentTokenSpan.end) { + return "quit"; + } + return ts.syntaxMayBeASICandidate(ancestor.kind); + }); + return !!contextAncestor && ts.isASICandidate(contextAncestor, context.sourceFile); } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -112436,7 +117516,7 @@ var ts; var formatting; (function (formatting) { function getFormatContext(options) { - return { options: options, getRule: getRulesMap() }; + return { options: options, getRules: getRulesMap() }; } formatting.getFormatContext = getFormatContext; var rulesMapCache; @@ -112446,11 +117526,45 @@ var ts; } return rulesMapCache; } + /** + * For a given rule action, gets a mask of other rule actions that + * cannot be applied at the same position. + */ + function getRuleActionExclusion(ruleAction) { + var mask = 0; + if (ruleAction & 1 /* StopProcessingSpaceActions */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 2 /* StopProcessingTokenActions */) { + mask |= 96 /* ModifyTokenAction */; + } + if (ruleAction & 28 /* ModifySpaceAction */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 96 /* ModifyTokenAction */) { + mask |= 96 /* ModifyTokenAction */; + } + return mask; + } function createRulesMap(rules) { var map = buildMap(rules); return function (context) { var bucket = map[getRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind)]; - return bucket && ts.find(bucket, function (rule) { return ts.every(rule.context, function (c) { return c(context); }); }); + if (bucket) { + var rules_1 = []; + var ruleActionMask = 0; + for (var _i = 0, bucket_1 = bucket; _i < bucket_1.length; _i++) { + var rule = bucket_1[_i]; + var acceptRuleActions = ~getRuleActionExclusion(ruleActionMask); + if (rule.action & acceptRuleActions && ts.every(rule.context, function (c) { return c(context); })) { + rules_1.push(rule); + ruleActionMask |= rule.action; + } + } + if (rules_1.length) { + return rules_1; + } + } }; } function buildMap(rules) { @@ -112458,8 +117572,8 @@ var ts; var map = new Array(mapRowLength * mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(map.length); - for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) { - var rule = rules_1[_i]; + for (var _i = 0, rules_2 = rules; _i < rules_2.length; _i++) { + var rule = rules_2[_i]; var specificRule = rule.leftTokenRange.isSpecific && rule.rightTokenRange.isSpecific; for (var _a = 0, _b = rule.leftTokenRange.tokens; _a < _b.length; _a++) { var left = _b[_a]; @@ -112477,16 +117591,16 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 151 /* LastKeyword */ && column <= 151 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 151 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = maskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; + RulesPosition[RulesPosition["StopRulesAny"] = maskBitSize * 1] = "StopRulesAny"; RulesPosition[RulesPosition["ContextRulesSpecific"] = maskBitSize * 2] = "ContextRulesSpecific"; RulesPosition[RulesPosition["ContextRulesAny"] = maskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = maskBitSize * 4] = "NoContextRulesSpecific"; @@ -112508,11 +117622,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action & 3 /* StopAction */ ? + specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -112537,6 +117651,16 @@ var ts; (function (ts) { var formatting; (function (formatting) { + function createTextRangeWithKind(pos, end, kind) { + var textRangeWithKind = { pos: pos, end: end, kind: kind }; + if (ts.Debug.isDebugging) { + Object.defineProperty(textRangeWithKind, "__debugKind", { + get: function () { return ts.Debug.formatSyntaxKind(kind); }, + }); + } + return textRangeWithKind; + } + formatting.createTextRangeWithKind = createTextRangeWithKind; var Constants; (function (Constants) { Constants[Constants["Unknown"] = -1] = "Unknown"; @@ -112660,17 +117784,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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 249 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 288 /* SourceFile */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -112805,7 +117929,7 @@ var ts; return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) { - var options = _a.options, getRule = _a.getRule; + var options = _a.options, getRules = _a.getRules; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); var previousRange; @@ -112895,19 +118019,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: return 79 /* ClassKeyword */; + case 245 /* InterfaceDeclaration */: return 113 /* InterfaceKeyword */; + case 243 /* FunctionDeclaration */: return 93 /* FunctionKeyword */; + case 247 /* EnumDeclaration */: return 247 /* EnumDeclaration */; + case 162 /* GetAccessor */: return 130 /* GetKeyword */; + case 163 /* SetAccessor */: return 141 /* SetKeyword */; + case 160 /* MethodDeclaration */: if (node.asteriskToken) { - return 40 /* AsteriskToken */; + return 41 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -112957,22 +118081,22 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 84 /* ElseKeyword */: - case 108 /* WhileKeyword */: - case 58 /* AtToken */: + case 86 /* ElseKeyword */: + case 110 /* WhileKeyword */: + case 59 /* AtToken */: return false; - case 42 /* SlashToken */: - case 30 /* GreaterThanToken */: + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 185 /* MappedType */) { return false; } break; @@ -113019,6 +118143,12 @@ var ts; } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } + if (!node.parent && formattingScanner.isOnEOF()) { + var token = formattingScanner.readEOFTokenRange(); + if (token.end <= node.end && previousRange) { + processPair(token, sourceFile.getLineAndCharacterOfPosition(token.pos).line, node, previousRange, previousRangeStartLine, previousParent, contextNode, nodeDynamicIndentation); + } + } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; @@ -113064,7 +118194,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 156 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 11 /* JsxText */) { @@ -113072,7 +118202,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 191 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -113240,35 +118370,39 @@ var ts; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = getRule(formattingContext); - var trimTrailingWhitespaces; + var rules = getRules(formattingContext); + var trimTrailingWhitespaces = false; var lineAction = 0 /* None */; - if (rule) { - lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - switch (lineAction) { - case 2 /* LineRemoved */: - // Handle the case where the next line is moved to be the end of this line. - // In this case we don't indent the next line in the next pass. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); - } - break; - case 1 /* LineAdded */: - // Handle the case where token2 is moved to the new line. - // In this case we indent token2 in the next pass but we set - // sameLineIndent flag to notify the indenter that the indentation is within the line. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); - } - break; - default: - ts.Debug.assert(lineAction === 0 /* None */); - } - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = !(rule.action & 8 /* Delete */) && rule.flags !== 1 /* CanDeleteNewLines */; + if (rules) { + // Apply rules in reverse order so that higher priority rules (which are first in the array) + // win in a conflict with lower priority rules. + ts.forEachRight(rules, function (rule) { + lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + switch (lineAction) { + case 2 /* LineRemoved */: + // Handle the case where the next line is moved to be the end of this line. + // In this case we don't indent the next line in the next pass. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); + } + break; + case 1 /* LineAdded */: + // Handle the case where token2 is moved to the new line. + // In this case we indent token2 in the next pass but we set + // sameLineIndent flag to notify the indenter that the indentation is within the line. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); + } + break; + default: + ts.Debug.assert(lineAction === 0 /* None */); + } + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespaces = !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + }); } else { - trimTrailingWhitespaces = true; + trimTrailingWhitespaces = currentItem.kind !== 1 /* EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -113405,20 +118539,28 @@ var ts; edits.push(ts.createTextChangeFromStartLength(start, len, newText)); } } + function recordInsert(start, text) { + if (text) { + edits.push(ts.createTextChangeFromStartLength(start, 0, text)); + } + } function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* Ignore */: + case 1 /* StopProcessingSpaceActions */: // no action required return 0 /* None */; - case 8 /* Delete */: + case 16 /* DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } break; - case 4 /* NewLine */: + case 32 /* DeleteToken */: + recordDelete(previousRange.pos, previousRange.end - previousRange.pos); + break; + case 8 /* InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines @@ -113432,7 +118574,7 @@ var ts; return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; } break; - case 2 /* Space */: + case 4 /* InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { return 0 /* None */; @@ -113442,6 +118584,9 @@ var ts; recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } + break; + case 64 /* InsertTrailingSemicolon */: + recordInsert(previousRange.end, ";"); } return 0 /* None */; } @@ -113455,8 +118600,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -113465,6 +118609,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -113490,34 +118635,34 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 201 /* ArrowFunction */: if (node.typeParameters === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.parameters === list) { return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.arguments === list) { return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 168 /* TypeReference */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -113526,8 +118671,8 @@ var ts; switch (kind) { case 20 /* OpenParenToken */: return 21 /* CloseParenToken */; - case 28 /* LessThanToken */: - return 30 /* GreaterThanToken */; + case 29 /* LessThanToken */: + return 31 /* GreaterThanToken */; case 18 /* OpenBraceToken */: return 19 /* CloseBraceToken */; } @@ -113615,7 +118760,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -113634,7 +118780,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 208 /* 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 */) { @@ -113788,7 +118934,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 === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 288 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -113836,8 +118982,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); + if (parent.kind === 226 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 86 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -113871,40 +119017,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -113927,7 +119073,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 242 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -114000,83 +119146,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 225 /* ExpressionStatement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 191 /* ArrayLiteralExpression */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 185 /* MappedType */: + case 174 /* TupleType */: + case 250 /* CaseBlock */: + case 276 /* DefaultClause */: + case 275 /* CaseClause */: + case 199 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 224 /* VariableStatement */: + case 258 /* ExportAssignment */: + case 234 /* ReturnStatement */: + case 209 /* ConditionalExpression */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: + case 265 /* JsxSelfClosingElement */: + case 274 /* JsxExpression */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 155 /* Parameter */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 181 /* ParenthesizedType */: + case 197 /* TaggedTemplateExpression */: + case 205 /* AwaitExpression */: + case 260 /* NamedExports */: + case 256 /* NamedImports */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 158 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 241 /* VariableDeclaration */: + case 279 /* PropertyAssignment */: + case 208 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 192 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 208 /* BinaryExpression */) { + return true; + } + break; + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return childKind !== 222 /* Block */; + case 259 /* ExportDeclaration */: + return childKind !== 260 /* NamedExports */; + case 253 /* ImportDeclaration */: + return childKind !== 254 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 256 /* NamedImports */); + case 264 /* JsxElement */: + return childKind !== 267 /* JsxClosingElement */; + case 268 /* JsxFragment */: + return childKind !== 270 /* JsxClosingFragment */; + case 178 /* IntersectionType */: + case 177 /* UnionType */: + if (childKind === 172 /* TypeLiteral */) { return false; } // falls through @@ -114087,11 +119237,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: + return parent.kind !== 222 /* Block */; default: return false; } @@ -114233,7 +119383,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 192 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -114398,7 +119548,7 @@ var ts; } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 241 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -114430,7 +119580,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorStart = function (sourceFile, ctr, newStatement) { var firstStatement = ts.firstOrUndefined(ctr.body.statements); if (!firstStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, [newStatement].concat(ctr.body.statements)); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays([newStatement], ctr.body.statements)); } else { this.insertNodeBefore(sourceFile, firstStatement, newStatement); @@ -114439,7 +119589,7 @@ var ts; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { - this.replaceConstructorBody(sourceFile, ctr, ctr.body.statements.concat([newStatement])); + this.replaceConstructorBody(sourceFile, ctr, __spreadArrays(ctr.body.statements, [newStatement])); } else { this.insertNodeAfter(sourceFile, lastStatement, newStatement); @@ -114472,7 +119622,7 @@ var ts; if (getMembersOrProperties(cls).length === 0) { if (ts.addToSeen(this.classesWithNodesInsertedAtStart, ts.getNodeId(cls), { node: cls, sourceFile: sourceFile })) { // For `class C {\n}`, don't add the trailing "\n" - var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, getClassOrObjectBraceEnds(cls, sourceFile).concat([sourceFile])); // TODO: GH#4130 remove 'as any' + var shouldSuffix = ts.positionsAreOnSameLine.apply(void 0, __spreadArrays(getClassOrObjectBraceEnds(cls, sourceFile), [sourceFile])); // TODO: GH#4130 remove 'as any' return { prefix: this.newLineCharacter, suffix: comma + (shouldSuffix ? this.newLineCharacter : "") }; } else { @@ -114511,22 +119661,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign({}, options, { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 155 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -114535,12 +119685,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + if (node.kind === 201 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(91 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(93 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -114549,14 +119699,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 222 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(100 /* 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 === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 200 /* FunctionExpression */ ? 93 /* FunctionKeyword */ : 79 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -114807,29 +119957,34 @@ var ts; var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + noIndent + (options.suffix || ""); } + function getFormatCodeSettingsForWriting(_a, sourceFile) { + var options = _a.options; + var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore; + var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile); + return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore }); + } /** Note: this may mutate `nodeIn`. */ function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) { var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta; var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text; if (validate) validate(node, text); - var formatOptions = formatContext.options; + var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile); var initialIndentation = indentation !== undefined ? indentation : ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos); if (delta === undefined) { - delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatContext.options, nodeIn) ? (formatOptions.indentSize || 0) : 0; + delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? (formatOptions.indentSize || 0) : 0; } var file = { text: text, getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); } }; - var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, formatContext); + var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, __assign(__assign({}, formatContext), { options: formatOptions })); return applyChanges(text, changes); } /** Note: output node may be mutated input node. */ function getNonformattedText(node, sourceFile, newLineCharacter) { - var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); - var writer = createWriter(newLineCharacter, omitTrailingSemicolon); + var writer = createWriter(newLineCharacter); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -114864,9 +120019,9 @@ var ts; nodeArray.end = getEnd(nodes); return nodeArray; } - function createWriter(newLine, omitTrailingSemicolon) { + function createWriter(newLine) { var lastNonTriviaPosition = 0; - var writer = omitTrailingSemicolon ? ts.getTrailingSemicolonOmittingWriter(ts.createTextWriter(newLine)) : ts.createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var onEmitNode = function (hint, node, printCallback) { if (node) { setPos(node, lastNonTriviaPosition); @@ -115017,6 +120172,8 @@ var ts; getColumn: getColumn, getIndent: getIndent, isAtStartOfLine: isAtStartOfLine, + hasTrailingComment: function () { return writer.hasTrailingComment(); }, + hasTrailingWhitespace: function () { return writer.hasTrailingWhitespace(); }, clear: clear }; } @@ -115081,14 +120238,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 153 /* 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 152 /* Parameter */: { + case 155 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -115103,14 +120260,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 189 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -115118,13 +120275,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -115133,7 +120290,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -115180,13 +120337,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 253 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 278 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; @@ -115197,14 +120354,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -115365,10 +120522,10 @@ var ts; }); 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 assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) - : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(147 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(147 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -115384,7 +120541,7 @@ var ts; ts.Diagnostics.This_expression_is_not_callable.code, ts.Diagnostics.This_expression_is_not_constructable.code, ]; - var errorCodes = [ + var errorCodes = __spreadArrays([ ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type.code, @@ -115400,13 +120557,13 @@ var ts; ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator.code, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code, propertyAccessCode - ].concat(callableConstructableErrorCodes); + ], callableConstructableErrorCodes); codefix.registerCodeFix({ fixIds: [fixId], errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -115420,27 +120577,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -115454,7 +120622,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -115467,64 +120635,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = function (identifier) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + return "continue"; + } + var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); + var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); + var variableStatement = ts.getAncestor(declaration, 224 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; + } + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; + } + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); }); - if (isUsedElsewhere) { - return; - } - return declaration.initializer; + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { - return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 243 /* FunctionDeclaration */ || + ancestor.parent.kind === 200 /* FunctionExpression */ || + ancestor.parent.kind === 201 /* ArrowFunction */ || + ancestor.parent.kind === 160 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -115587,16 +120837,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || fixedNodes.tryAdd(initializer)) { - changeTracker.insertModifierBefore(sourceFile, 78 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 80 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 75 /* Identifier */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -115610,8 +120860,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 75 /* Identifier */: + case 208 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -115631,6 +120881,42 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addMissingDeclareProperty"; + var errorCodes = [ + ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration.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); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Prefix_with_declare, fixId, ts.Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var fixedNodes = new ts.NodeSet(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start, fixedNodes); }); + }, + }); + function makeChange(changeTracker, sourceFile, pos, fixedNodes) { + var token = ts.getTokenAtPosition(sourceFile, pos); + if (!ts.isIdentifier(token)) { + return; + } + var declaration = token.parent; + if (declaration.kind === 158 /* PropertyDeclaration */ && + (!fixedNodes || fixedNodes.tryAdd(declaration))) { + changeTracker.insertModifierBefore(sourceFile, 129 /* DeclareKeyword */, declaration); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -115752,33 +121038,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 241 /* VariableDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 158 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -115800,7 +121086,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 299 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); 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); @@ -115840,8 +121126,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -115945,7 +121231,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 73 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 101 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 103 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -116032,13 +121318,8 @@ var ts; if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, 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); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -116057,14 +121338,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -116099,7 +121377,7 @@ var ts; function annotate(changes, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 157 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -116139,14 +121417,14 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray((oldTags || ts.emptyArray).concat(unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); + var jsDocNode = parent.kind === 201 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 158 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -116156,14 +121434,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 306 /* JSDocParameterTag */: { + case 310 /* 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 307 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -116175,25 +121453,31 @@ var ts; } 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); + return inferTypeFromReferences(program, references, cancellationToken).single(); + } + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); + case 161 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 128 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -116202,54 +121486,109 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - 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); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + var builtinConstructors = { + string: function () { return checker.getStringType(); }, + number: function () { return checker.getNumberType(); }, + Array: function (t) { return checker.createArrayType(t); }, + Promise: function (t) { return checker.createPromiseType(t); }, + }; + var builtins = [ + checker.getStringType(), + checker.getNumberType(), + checker.createArrayType(checker.getAnyType()), + checker.createPromiseType(checker.getAnyType()), + ]; + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function createEmptyUsage() { + return { + isNumber: undefined, + isString: undefined, + isNumberOrString: undefined, + candidateTypes: undefined, + properties: undefined, + calls: undefined, + constructs: undefined, + numberIndex: undefined, + stringIndex: undefined, + candidateThisTypes: undefined, + inferredTypes: undefined, + }; + } + function combineUsages(usages) { + var combinedProperties = ts.createUnderscoreEscapedMap(); + for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) { + var u = usages_1[_i]; + if (u.properties) { + u.properties.forEach(function (p, name) { + if (!combinedProperties.has(name)) { + combinedProperties.set(name, []); + } + combinedProperties.get(name).push(p); + }); + } } - return inferFromContext(usageContext, checker); + var properties = ts.createUnderscoreEscapedMap(); + combinedProperties.forEach(function (ps, name) { + properties.set(name, combineUsages(ps)); + }); + return { + isNumber: usages.some(function (u) { return u.isNumber; }), + isString: usages.some(function (u) { return u.isString; }), + isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }), + candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }), + properties: properties, + calls: ts.flatMap(usages, function (u) { return u.calls; }), + constructs: ts.flatMap(usages, function (u) { return u.constructs; }), + numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }), + stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }), + candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }), + inferredTypes: undefined, + }; + } + function single() { + return combineTypes(inferTypesFromReferencesSingle(references)); } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = createEmptyUsage(); + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = (usageContext.constructContexts || []).concat(usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return 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) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.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])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = combineTypes(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -116257,242 +121596,255 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = createEmptyUsage(); + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return combineTypes(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = createEmptyUsage(); for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferTypes(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 225 /* ExpressionStatement */: + addCandidateType(usage, checker.getVoidType()); + break; + case 207 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 206 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 208 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 193 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 194 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 158 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 241 /* 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)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - usageContext.isNumber = true; + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + usage.isNumber = true; break; - case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + case 39 /* PlusToken */: + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: // MultiplicativeOperator - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + // falls through + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: // ShiftOperator - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // falls through + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator - case 49 /* AmpersandToken */: - case 50 /* BarToken */: - case 51 /* CaretToken */: + // falls through + case 50 /* AmpersandToken */: + case 51 /* BarToken */: + case 52 /* CaretToken */: // CompoundAssignmentOperator - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 71 /* BarEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: + // falls through + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 73 /* BarEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator - case 39 /* MinusToken */: + // falls through + case 40 /* MinusToken */: // RelationalOperator - case 28 /* LessThanToken */: - case 31 /* LessThanEqualsToken */: - case 30 /* GreaterThanToken */: - case 32 /* GreaterThanEqualsToken */: + // falls through + case 29 /* LessThanToken */: + case 32 /* LessThanEqualsToken */: + case 31 /* GreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; - case 61 /* PlusEqualsToken */: - case 38 /* PlusToken */: + case 63 /* PlusEqualsToken */: + case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; + } + else if (otherOperandType.flags & 1 /* Any */) { + // do nothing, maybe we'll learn something elsewhere } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators - case 60 /* EqualsToken */: - case 33 /* EqualsEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + case 62 /* EqualsToken */: + case 34 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 94 /* InKeyword */: + case 96 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; - // LogicalOperator - case 55 /* BarBarToken */: + // LogicalOperator Or NullishCoalescing + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 241 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: // nothing to infer here break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], - returnType: {} + return_: createEmptyUsage() }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.return_); + if (parent.kind === 195 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || createEmptyUsage(); + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = createEmptyUsage(); + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -116501,17 +121853,19 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { - if (fallback === void 0) { fallback = checker.getAnyType(); } + function combineFromUsage(usage) { + return combineTypes(inferTypes(usage)); + } + function combineTypes(inferences) { if (!inferences.length) - return fallback; + return checker.getAnyType(); // 1. string or number individually override string | number // 2. non-any, non-void overrides any or void // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types @@ -116534,12 +121888,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function combineAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -116575,109 +121928,173 @@ var ts; }); 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) { + function inferTypes(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - 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) { - types.push(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 + if (usage.numberIndex) { + types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); } + if (usage.properties && usage.properties.size + || usage.calls && usage.calls.length + || usage.constructs && usage.constructs.length + || usage.stringIndex) { + types.push(inferStructuralType(usage)); + } + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + types.push.apply(types, inferNamedTypesFromProperties(usage)); return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + function inferStructuralType(usage) { + var members = ts.createUnderscoreEscapedMap(); + if (usage.properties) { + usage.properties.forEach(function (u, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = combineFromUsage(u); + members.set(name, symbol); + }); + } + var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; + var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; + var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); + return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 + } + function inferNamedTypesFromProperties(usage) { + if (!usage.properties || !usage.properties.size) + return []; + var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); }); + if (0 < types.length && types.length < 3) { + return types.map(function (t) { return inferInstantiationFromUsage(t, usage); }); } + return []; + } + function allPropertiesAreAssignableToUsage(type, usage) { + if (!usage.properties) + return false; + return !ts.forEachEntry(usage.properties, function (propUsage, name) { + var source = checker.getTypeOfPropertyOfType(type, name); + if (!source) { + return true; + } + if (propUsage.calls) { + var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); + } + else { + return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage)); + } + }); } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + /** + * inference is limited to + * 1. generic types with a single parameter + * 2. inference to/from calls with a single signature + */ + function inferInstantiationFromUsage(type, usage) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + return type; + } + var generic = type.target; + var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters); + if (!singleTypeParameter) + return type; 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])); + usage.properties.forEach(function (propUsage, name) { + var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name); + ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference."); + types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter)); + }); + return builtinConstructors[type.symbol.escapedName](combineTypes(types)); + } + function inferTypeParameters(genericType, usageType, typeParameter) { + if (genericType === typeParameter) { + return [usageType]; + } + else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); + } + else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference + var genericArgs = checker.getTypeArguments(genericType); + var usageArgs = checker.getTypeArguments(usageType); + var types = []; + if (genericArgs && usageArgs) { + for (var i = 0; i < genericArgs.length; i++) { + if (usageArgs[i]) { + types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter)); } } } + return types; } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + if (genericSigs.length === 1 && usageSigs.length === 1) { + return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } - return undefined; + return []; + } + function inferFromSignatures(genericSig, usageSig, typeParameter) { + var types = []; + for (var i = 0; i < genericSig.parameters.length; i++) { + var genericParam = genericSig.parameters[i]; + var usageParam = usageSig.parameters[i]; + var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]); + if (!usageParam) { + break; + } + var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); + if (elementType) { + genericParamType = elementType; + } + var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); + } + var genericReturn = checker.getReturnTypeOfSignature(genericSig); + var usageReturn = checker.getReturnTypeOfSignature(usageSig); + types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter)); + return types; } - function getSignatureFromCallContext(callContext, checker) { + function getFunctionFromCalls(calls) { + return checker.createAnonymousType(undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } + function getSignatureFromCalls(calls) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); + var _loop_12 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); + if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { + symbol.flags |= 16777216 /* Optional */; + } parameters.push(symbol); + }; + for (var i = 0; i < length; i++) { + _loop_12(i); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -116706,12 +122123,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -116743,7 +122160,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(117 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(119 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -116766,7 +122183,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 === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 225 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -116774,27 +122191,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 201 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 222 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -116815,17 +122232,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 200 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 73 /* Identifier */) { + if (node.name.kind !== 75 /* 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, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 88 /* 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 @@ -116836,7 +122253,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 88 /* 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 @@ -116899,12 +122316,12 @@ var ts; return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 122 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 125 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_13 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -116916,7 +122333,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_13(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -117210,10 +122627,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 73 /* Identifier */: // identifier includes undefined + case 75 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -117235,8 +122652,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -117348,6 +122765,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -117439,10 +122857,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -117468,7 +122886,7 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(node.name.text, node, 67220415 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. res.set(text, makeUniqueName("_" + text, identifiers)); } @@ -117488,29 +122906,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 === 60 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 62 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 195 /* 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 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -117550,8 +122968,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -117559,11 +122977,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -117602,18 +123020,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); + case 160 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(88 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -117642,12 +123061,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -117660,7 +123077,7 @@ 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(86 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(88 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -117669,14 +123086,14 @@ var ts; } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(86 /* ExportKeyword */), ts.createToken(78 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(88 /* ExportKeyword */), ts.createToken(80 /* 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(86 /* ExportKeyword */)]; + var modifiers = [ts.createToken(88 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -117684,10 +123101,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -117705,18 +123122,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 188 /* 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 + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 189 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -117727,10 +123146,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -117752,7 +123171,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` var idName = namedBindingsNames.get(propertyName); if (idName === undefined) { idName = makeUniqueName(propertyName, identifiers); @@ -117799,11 +123218,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -117878,8 +123297,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -117906,7 +123327,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -118004,7 +123425,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -118017,7 +123438,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -118025,14 +123446,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -118069,28 +123490,29 @@ var ts; ImportKind[ImportKind["Default"] = 1] = "Default"; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; ImportKind[ImportKind["Equals"] = 3] = "Equals"; + ImportKind[ImportKind["ConstEquals"] = 4] = "ConstEquals"; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { - var exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); + ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getAllReExportingModules(exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { + function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, sourceFile, compilerOptions, checker, allSourceFiles) { var result = []; forEachExternalModule(checker, allSourceFiles, function (moduleSymbol, moduleFile) { // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(sourceFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); if (defaultInfo && defaultInfo.name === symbolName && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); } @@ -118104,7 +123526,7 @@ var ts; return result; } function isTypeOnlySymbol(s, checker) { - return !(ts.skipAlias(s, checker).flags & 67220415 /* Value */); + return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); @@ -118113,7 +123535,7 @@ var ts; var addToExisting = tryAddToExistingImport(existingImports); // Don't bother providing an action to add a new import if we can add to an existing one. var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences); - return (useNamespace ? [useNamespace] : ts.emptyArray).concat(addImport); + return __spreadArrays((useNamespace ? [useNamespace] : ts.emptyArray), addImport); } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { // It is possible that multiple import statements with the same specifier exist in the file. @@ -118142,21 +123564,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 253 /* 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 === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 256 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 253 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 255 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -118167,22 +123589,35 @@ 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 === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 253 /* ImportDeclaration */ || i.kind === 252 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } function getNewImportInfos(program, sourceFile, position, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); + var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); - // Sort to keep the shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + // Sort by presence in package.json, then shortest paths first + return ts.sort(choicesForEachExportingModule, function (a, b) { + var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); + var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); + if (allowsImportingA && !allowsImportingB) { + return -1; + } + if (allowsImportingB && !allowsImportingA) { + return 1; + } + return a.moduleSpecifier.length - b.moduleSpecifier.length; + }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -118190,9 +123625,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 253 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 263 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -118202,7 +123637,7 @@ var ts; var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ? getFixesInfoForUMDImport(context, symbolToken) : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken) : undefined; - return info && __assign({}, info, { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -118212,7 +123647,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } @@ -118224,10 +123659,10 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 67220415 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } - function getUmdImportKind(compilerOptions) { + function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { return 1 /* Default */; @@ -118238,6 +123673,9 @@ var ts; case ts.ModuleKind.AMD: case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 4 /* ConstEquals */; + } return 3 /* Equals */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: @@ -118246,7 +123684,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -118259,24 +123697,25 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - ts.Debug.assert(symbolName !== "default" /* Default */); - var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); + var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, host); + var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program, host) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); function addSymbol(moduleSymbol, exportedSymbol, importKind) { originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); } - forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); - var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, program.getCompilerOptions()); + var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind); } @@ -118288,20 +123727,41 @@ var ts; }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(moduleSymbol, checker); + function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); if (!exported) return undefined; var symbol = exported.symbol, kind = exported.kind; var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); return info && __assign({ symbol: symbol, kind: kind }, info); } - function getDefaultLikeExportWorker(moduleSymbol, checker) { + function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); if (defaultExport) return { symbol: defaultExport, kind: 1 /* Default */ }; var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); - return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: 3 /* Equals */ }; + return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions, checker) }; + } + function getExportEqualsImportKind(importingFile, compilerOptions, checker) { + if (ts.getAllowSyntheticDefaultImports(compilerOptions) && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return 1 /* Default */; + } + if (ts.isInJSFile(importingFile)) { + return ts.isExternalModule(importingFile) ? 1 /* Default */ : 4 /* ConstEquals */; + } + for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isImportEqualsDeclaration(statement)) { + return 3 /* Equals */; + } + if (ts.isImportDeclaration(statement) && statement.importClause && statement.importClause.name) { + var moduleSymbol = checker.getImmediateAliasedSymbol(statement.importClause.symbol); + if (moduleSymbol && moduleSymbol.name !== "default" /* Default */) { + return 1 /* Default */; + } + } + } + return 3 /* Equals */; } function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -118312,7 +123772,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -118328,7 +123788,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -118362,12 +123822,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -118385,7 +123845,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -118410,21 +123870,46 @@ var ts; ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference)); } if (namespaceLikeImport) { - ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ - ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) - : ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); + ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) : + namespaceLikeImport.importKind === 4 /* ConstEquals */ ? createConstEqualsRequireDeclaration(namespaceLikeImport.name, quotedModuleSpecifier) : + ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier)); } } + function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) { + return ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.createIdentifier(name), + /*type*/ undefined, ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) + ], 2 /* Const */)); + } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(checker, from, allSourceFiles, cb) { - forEachExternalModule(checker, allSourceFiles, function (module, sourceFile) { - if (sourceFile === undefined || sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { - cb(module); + function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, cb) { + var filteredCount = 0; + var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host); + var allSourceFiles = program.getSourceFiles(); + forEachExternalModule(program.getTypeChecker(), allSourceFiles, function (module, sourceFile) { + if (sourceFile === undefined) { + if (!packageJson || packageJson.allowsImportingAmbientModule(module, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } + } + else if (sourceFile && sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { + if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } } }); + if (host.log) { + host.log("forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); + } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; function forEachExternalModule(checker, allSourceFiles, cb) { @@ -118479,6 +123964,109 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; + function createAutoImportFilter(fromFile, program, host) { + var packageJsons = host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host); + var dependencyGroups = 1 /* Dependencies */ | 2 /* DevDependencies */ | 8 /* OptionalDependencies */; + // Mix in `getProbablySymlinks` from Program when host doesn't have it + // in order for non-Project hosts to have a symlinks cache. + var moduleSpecifierResolutionHost = { + directoryExists: ts.maybeBind(host, host.directoryExists), + fileExists: ts.maybeBind(host, host.fileExists), + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + readFile: ts.maybeBind(host, host.readFile), + useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || program.getProbableSymlinks, + }; + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName, dependencyGroups) || packageJson.has(ts.getTypesPackageName(packageName), dependencyGroups)) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, allSourceFiles); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, allSourceFiles); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + /** + * Use for a specific module specifier that has already been resolved. + * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve + * the best module specifier for a given module _and_ determine if it’s importable. + */ + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, allSourceFiles) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, allSourceFiles, program.redirectTargetsMap); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -118522,12 +124110,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (property access)"); 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 === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -118556,10 +124144,10 @@ var ts; flags |= 1920 /* Namespace */; } if (meaning & 2 /* Type */) { - flags |= 67897832 /* Type */; + flags |= 788968 /* Type */; } if (meaning & 1 /* Value */) { - flags |= 67220415 /* Value */; + flags |= 111551 /* Value */; } return flags; } @@ -118630,7 +124218,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -118657,7 +124245,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_14(info); } }); })); @@ -118718,7 +124306,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 213 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -118744,7 +124332,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 208 /* 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))); @@ -118754,7 +124342,7 @@ var ts; var contextualType = checker.getContextualType(token.parent); typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; } - return typeNode || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return typeNode || ts.createKeywordTypeNode(124 /* 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); }); @@ -118763,7 +124351,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -118787,7 +124375,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(139 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(142 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -118807,7 +124395,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, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 160 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -119015,7 +124603,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 101 /* ThisKeyword */) + if (token.kind !== 103 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -119054,7 +124642,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 128 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -119098,6 +124686,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -119125,14 +124750,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 87 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 89 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(110 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(112 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 87 /* ExtendsKeyword */ && - heritageClauses[1].token === 110 /* ImplementsKeyword */) { + heritageClauses[0].token === 89 /* ExtendsKeyword */ && + heritageClauses[1].token === 112 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* CommaToken */)); @@ -119219,7 +124844,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 === 28 /* LessThanToken */) { + if (token.kind === 29 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -119239,7 +124864,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* 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)); @@ -119271,7 +124896,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 128 /* InferKeyword */) + if (token.kind === 131 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -119280,7 +124905,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 28 /* LessThanToken */) { + else if (token.kind === 29 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -119290,7 +124915,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -119301,23 +124926,23 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(144 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(147 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 93 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 95 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 155 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -119328,7 +124953,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -119337,7 +124962,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 === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -119346,14 +124971,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 155 /* Parameter */: + case 154 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return true; } } @@ -119400,26 +125025,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 160 /* 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 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* 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); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 75 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -119455,11 +125080,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); 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 223 /* IfStatement */: + case 226 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -119470,15 +125095,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -119520,7 +125145,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, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -119544,7 +125169,7 @@ 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 === 292 /* JSDocNullableType */) { + if (typeNode.kind === 295 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -119564,7 +125189,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 295 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -119581,22 +125206,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 216 /* AsExpression */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 162 /* GetAccessor */: + case 166 /* IndexSignature */: + case 185 /* MappedType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 198 /* TypeAssertionExpression */: + case 241 /* VariableDeclaration */: return true; default: return false; @@ -119625,12 +125250,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -119650,14 +125278,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 93 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -119672,11 +125300,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 73 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 75 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 122 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 125 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -119784,18 +125412,40 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); + var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); switch (declaration.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 158 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: { + var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); + var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + var orderedAccessors = allAccessors.secondAccessor + ? [allAccessors.firstAccessor, allAccessors.secondAccessor] + : [allAccessors.firstAccessor]; + for (var _i = 0, orderedAccessors_1 = orderedAccessors; _i < orderedAccessors_1.length; _i++) { + var accessor = orderedAccessors_1[_i]; + if (ts.isGetAccessorDeclaration(accessor)) { + out(ts.createGetAccessor( + /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); + } + else { + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); + var parameter = ts.getSetAccessorValueParameter(accessor); + var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; + out(ts.createSetAccessor( + /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(preferences))); + } + } + break; + } + case 159 /* MethodSignature */: + case 160 /* 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 @@ -119808,23 +125458,25 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; } - for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { - var signature = signatures_1[_i]; + for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) { + var signature = signatures_1[_a]; // 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)); } - if (declarations.length > signatures.length) { - var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); - } - else { - ts.Debug.assert(declarations.length === signatures.length); - out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + if (!ambient) { + if (declarations.length > signatures.length) { + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + } + else { + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); + out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + } } break; } @@ -119836,14 +125488,14 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 160 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(57 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -119857,15 +125509,14 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(41 /* 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); @@ -119882,8 +125533,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(121 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(124 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -119911,11 +125562,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(121 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(124 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -119926,7 +125577,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -119937,10 +125588,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(116 /* PublicKeyword */); + return ts.createToken(118 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(115 /* ProtectedKeyword */); + return ts.createToken(117 /* ProtectedKeyword */); } return undefined; } @@ -120012,7 +125663,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 195 /* CallExpression */ : 196 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -120123,7 +125774,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(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -120131,7 +125782,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(142 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(145 /* 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)); @@ -120252,6 +125903,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -120273,8 +125957,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 95 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 187 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -120326,8 +126010,8 @@ 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(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); - var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(137 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); @@ -120357,7 +126041,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 123 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 126 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -120368,7 +126052,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 96 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 98 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -120379,6 +126063,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -120395,8 +126113,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -120416,16 +126134,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -120434,7 +126152,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + ts.Debug.assert(!wasDefault, "Can't have a default flag here"); return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } default: @@ -120448,40 +126166,40 @@ 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, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 83 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 88 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(83 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 224 /* 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. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* 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))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -120495,27 +126213,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 257 /* ImportSpecifier */: + case 261 /* 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 251 /* ImportClause */: { + case 254 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 255 /* 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 */; @@ -120536,11 +126254,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 257 /* 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); @@ -120553,7 +126271,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 261 /* 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";` @@ -120562,7 +126280,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -120586,13 +126304,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 255 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 255 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -120609,7 +126327,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 255 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -120630,7 +126348,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -120669,7 +126387,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -120688,7 +126406,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -120809,6 +126527,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -120900,6 +126619,9 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -120952,20 +126674,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 158 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 155 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 161 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 160 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -120983,13 +126705,13 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 4194304 /* Ambient */) { + if (nodeToCheck.flags & 8388608 /* Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -121008,7 +126730,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 241 /* 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`! @@ -121020,13 +126742,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 99 /* SuperKeyword */: + case 101 /* 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 === 192 /* CallExpression */) { + if (node.parent.kind === 195 /* 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)) { @@ -121041,8 +126763,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -121054,20 +126776,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 222 /* Block */: + if (node.parent && node.parent.kind === 239 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -121079,19 +126801,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 182 /* ThisType */: + case 103 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -121100,20 +126822,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 233 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -121167,7 +126889,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 === 152 /* Parameter */) { + if (current.kind === 155 /* 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; } @@ -121178,7 +126900,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 288 /* SourceFile */) { return scopes; } } @@ -121268,32 +126990,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 244 /* 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 === 246 /* ModuleBlock */ + return scope.kind === 249 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -121359,20 +127081,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(114 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(116 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(122 /* AsyncKeyword */)); + modifiers.push(ts.createToken(125 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(122 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(125 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* 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; @@ -121389,7 +127111,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(40 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(41 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -121397,8 +127119,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -121466,7 +127188,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -121513,9 +127235,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 142 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 145 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(142 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); } } /** @@ -121523,6 +127245,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -121533,16 +127256,17 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(114 /* PrivateKeyword */)); + modifiers.push(ts.createToken(116 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } - modifiers.push(ts.createToken(134 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(137 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -121571,7 +127295,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 225 /* 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( @@ -121590,7 +127314,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 225 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -121604,6 +127328,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -121677,7 +127458,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 234 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -121740,11 +127521,11 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; - for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { - var member = members_2[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.pos > maxPos) { return prevMember || members[0]; } @@ -121782,11 +127563,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -121855,7 +127636,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 !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 243 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -121908,7 +127689,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -121918,7 +127699,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -121940,7 +127721,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -121958,7 +127739,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -122171,30 +127952,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 282 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 253 /* ImportDeclaration */ && + parent.kind !== 257 /* ImportSpecifier */; + case 212 /* SpreadElement */: + case 188 /* ObjectBindingPattern */: + case 190 /* BindingElement */: return false; - case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + case 75 /* Identifier */: + return parent.kind !== 190 /* BindingElement */ && + parent.kind !== 257 /* ImportSpecifier */ && + parent.kind !== 261 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 222 /* Block */: + case 288 /* SourceFile */: + case 249 /* ModuleBlock */: + case 275 /* CaseClause */: return true; default: return false; @@ -122210,6 +127991,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -122219,22 +128001,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -122249,11 +128043,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; + } + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function isStatementAndHasJSDoc(n) { return ts.isStatement(n) && ts.hasJSDocNodes(n); @@ -122290,7 +128109,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 67220415 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); if (symbol && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -122304,15 +128123,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(311 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(315 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -122320,10 +128150,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(310 /* JSDocTemplateTag */); + var template = ts.createNode(314 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(154 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -122373,10 +128203,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 116 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 118 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 114 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 116 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -122404,7 +128234,7 @@ var ts; return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { - return ts.isParameterPropertyDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); + return ts.isParameterPropertyDeclaration(node, node.parent) || ts.isPropertyDeclaration(node) || ts.isPropertyAssignment(node); } function createPropertyName(name, originalName) { return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); @@ -122414,7 +128244,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(117 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(119 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -122437,7 +128267,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 155 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -122483,24 +128313,22 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 101 /* ThisKeyword */ && + node.expression.kind === 103 /* ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 103 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -122525,7 +128353,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -122582,11 +128410,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -122621,7 +128449,7 @@ var ts; deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return __spreadArrays(getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference), addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { @@ -122639,10 +128467,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -122664,25 +128492,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 253 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 255 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -122710,20 +128538,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 253 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 252 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -122765,7 +128593,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -122793,19 +128621,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -122814,7 +128642,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 255 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -122824,9 +128652,9 @@ var ts; } if (namedBindings) { if (namedBindingsUnused) { - changes.delete(sourceFile, namedBindings); + changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 256 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -122839,14 +128667,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 188 /* 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); } @@ -122920,7 +128748,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -122973,13 +128801,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -122991,7 +128819,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -123001,18 +128829,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -123022,11 +128850,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 188 /* 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; @@ -123078,18 +128906,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -123097,17 +128925,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -123117,13 +128945,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -123131,9 +128959,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -123164,55 +128992,55 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(88 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { - return [decl].concat(getNamesToExportInCommonJS(decl).map(createExportAssignment)); + return __spreadArrays([decl], getNamesToExportInCommonJS(decl).map(createExportAssignment)); } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 225 /* ExpressionStatement */: + return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 60 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 62 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -123335,7 +129163,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -123367,7 +129195,7 @@ var ts; function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); var classNames = ts.isConstructorDeclaration(functionDeclaration) ? getClassNames(functionDeclaration) : []; - var names = ts.deduplicate(functionNames.concat(classNames), ts.equateValues); + var names = ts.deduplicate(__spreadArrays(functionNames, classNames), ts.equateValues); var checker = program.getTypeChecker(); var references = ts.flatMap(names, /*mapfn*/ function (/*mapfn*/ name) { return ts.FindAllReferences.getReferenceEntriesForNode(-1, name, program, program.getSourceFiles(), cancellationToken); }); var groupedReferences = groupReferences(references); @@ -123474,15 +129302,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -123492,7 +129320,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -123511,14 +129339,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -123560,11 +129388,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 161 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -123572,8 +129400,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -123583,7 +129411,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 81 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 83 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -123698,7 +129526,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(56 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, /*initializer*/ undefined); ts.suppressLeadingAndTrailingTrivia(propertySignature); copyComments(parameterDeclaration.name, propertySignature.name); @@ -123744,15 +129572,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 83 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -123763,30 +129591,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 83 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: - var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + case 161 /* Constructor */: + var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 128 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 213 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -123798,10 +129626,10 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 73 /* Identifier */ ? new IdentifierObject(73 /* Identifier */, pos, end) : + kind === 75 /* Identifier */ ? new IdentifierObject(75 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 12679168 /* ContextFlags */; + node.flags = parent.flags & 25358336 /* ContextFlags */; return node; } var NodeObject = /** @class */ (function () { @@ -123815,7 +129643,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -123872,8 +129700,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 312 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 292 /* FirstJSDocNode */ || kid.kind > 316 /* LastJSDocNode */; }); + return child.kind < 152 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -123884,7 +129712,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 152 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -123930,7 +129758,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 73 /* Identifier */) { + if (token === 75 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -123942,7 +129770,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(313 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(317 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -124065,7 +129893,9 @@ var ts; var IdentifierObject = /** @class */ (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { - return _super.call(this, pos, end) || this; + var _this = _super.call(this, pos, end) || this; + _this.kind = 75 /* Identifier */; + return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { get: function () { @@ -124076,7 +129906,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 73 /* Identifier */; + IdentifierObject.prototype.kind = 75 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -124112,9 +129942,15 @@ var ts; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; }; + TypeObject.prototype.isNullableType = function () { + return this.checker.isNullableType(this); + }; TypeObject.prototype.getNonNullableType = function () { return this.checker.getNonNullableType(this); }; + TypeObject.prototype.getNonOptionalType = function () { + return this.checker.getNonOptionalType(this); + }; TypeObject.prototype.getConstraint = function () { return this.checker.getBaseConstraintOfType(this); }; @@ -124219,7 +130055,9 @@ var ts; var SourceFileObject = /** @class */ (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - return _super.call(this, kind, pos, end) || this; + var _this = _super.call(this, kind, pos, end) || this; + _this.kind = 288 /* SourceFile */; + return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -124277,10 +130115,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -124300,31 +130138,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 172 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -124335,19 +130173,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 259 /* 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 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -124359,7 +130197,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -124368,7 +130206,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -124565,7 +130403,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -124685,16 +130523,20 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; }, getCurrentDirectory: function () { return currentDirectory; }, getProgram: getProgram, - fileExists: host.fileExists && (function (f) { return host.fileExists(f); }), - readFile: host.readFile && (function (f, encoding) { return host.readFile(f, encoding); }), - getDocumentPositionMapper: host.getDocumentPositionMapper && (function (generatedFileName, sourceFileName) { return host.getDocumentPositionMapper(generatedFileName, sourceFileName); }), - getSourceFileLike: host.getSourceFileLike && (function (f) { return host.getSourceFileLike(f); }), + fileExists: ts.maybeBind(host, host.fileExists), + readFile: ts.maybeBind(host, host.readFile), + getDocumentPositionMapper: ts.maybeBind(host, host.getDocumentPositionMapper), + getSourceFileLike: ts.maybeBind(host, host.getSourceFileLike), log: log }); function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - throw new Error("Could not find sourceFile: '" + fileName + "' in " + (program && JSON.stringify(program.getSourceFiles().map(function (f) { return f.fileName; }))) + "."); + var error = new Error("Could not find source file: '" + fileName + "'."); + // We've been having trouble debugging this, so attach sidecar data for the tsserver log. + // See https://github.com/microsoft/TypeScript/issues/30180. + error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); + throw error; } return sourceFile; } @@ -124763,13 +130605,29 @@ var ts; compilerHost.trace = function (message) { return host.trace(message); }; } if (host.resolveModuleNames) { - compilerHost.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }; + compilerHost.resolveModuleNames = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }; } if (host.resolveTypeReferenceDirectives) { - compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { - return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile, redirectedReference); + compilerHost.resolveTypeReferenceDirectives = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); }; } + if (host.setResolvedProjectReferenceCallbacks) { + compilerHost.setResolvedProjectReferenceCallbacks = function (callbacks) { return host.setResolvedProjectReferenceCallbacks(callbacks); }; + } + if (host.useSourceOfProjectReferenceRedirect) { + compilerHost.useSourceOfProjectReferenceRedirect = function () { return host.useSourceOfProjectReferenceRedirect(); }; + } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -124905,7 +130763,7 @@ var ts; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return semanticDiagnostics.concat(declarationDiagnostics); + return __spreadArrays(semanticDiagnostics, declarationDiagnostics); } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); @@ -124913,12 +130771,12 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); + return __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken)); } function getCompletionsAtPosition(fileName, position, options) { if (options === void 0) { options = ts.emptyOptions; } // Convert from deprecated options names to new names - var fullPreferences = __assign({}, ts.identity(options), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); + var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions }); synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } @@ -124930,7 +130788,7 @@ var ts; } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); - return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }); + return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host); } function getQuickInfoAtPosition(fileName, position) { synchronizeHostData(); @@ -124974,15 +130832,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 99 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 101 /* SuperKeyword */: return true; default: return false; @@ -125008,13 +130866,13 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }, highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, isDefinition: false }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); ts.Debug.assert(filesToSearch.some(function (f) { return ts.normalizePath(f) === normalizedFileName; })); synchronizeHostData(); - var sourceFilesToSearch = filesToSearch.map(getValidSourceFile); + var sourceFilesToSearch = ts.mapDefined(filesToSearch, function (fileName) { return program.getSourceFile(fileName); }); var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch); } @@ -125084,16 +130942,16 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: case 10 /* StringLiteral */: - case 88 /* FalseKeyword */: - case 103 /* TrueKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 73 /* Identifier */: + case 90 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 75 /* Identifier */: break; // Cant create the text span default: @@ -125109,7 +130967,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 === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 248 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -125174,7 +131032,7 @@ var ts; _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, + _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -125298,7 +131156,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -125561,7 +131419,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 263 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -125577,14 +131435,15 @@ var ts; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 153 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 192 /* ObjectLiteralExpression */ || node.parent.parent.kind === 272 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -125626,7 +131485,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -125673,7 +131532,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 4194304 /* Ambient */) { + if (tokenAtLocation.flags & 8388608 /* Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -125706,114 +131565,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 190 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 156 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -125831,19 +131690,19 @@ var ts; return spanInOpenParenToken(node); case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 57 /* ColonToken */: + case 58 /* ColonToken */: return spanInColonToken(node); - case 30 /* GreaterThanToken */: - case 28 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return spanInWhileKeyword(node); - case 84 /* ElseKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + case 86 /* ElseKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 151 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -125855,14 +131714,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 === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + if ((node.kind === 75 /* Identifier */ || + node.kind === 212 /* SpreadElement */ || + node.kind === 279 /* PropertyAssignment */ || + node.kind === 280 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 208 /* 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 @@ -125871,7 +131730,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 60 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -125884,22 +131743,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 156 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 208 /* 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 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -125908,21 +131767,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 279 /* 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 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 241 /* VariableDeclaration */: + case 155 /* 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)) { @@ -125930,7 +131789,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -125960,7 +131819,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 230 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -125972,7 +131831,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 231 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -126013,7 +131872,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 244 /* ClassDeclaration */ && functionDeclaration.kind !== 161 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -126036,26 +131895,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 230 /* 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 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* 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 === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 242 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -126080,21 +131939,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 190 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 189 /* ArrayBindingPattern */ && node.kind !== 188 /* ObjectBindingPattern */); + var elements = node.kind === 191 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -126102,18 +131961,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 === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 208 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -126121,25 +131980,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 249 /* 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 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -126147,7 +132006,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 188 /* 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); @@ -126163,7 +132022,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 189 /* 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); @@ -126178,12 +132037,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 227 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 195 /* CallExpression */ || + node.parent.kind === 196 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 199 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -126192,21 +132051,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 199 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -126216,20 +132075,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 279 /* PropertyAssignment */ || + node.parent.kind === 155 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 198 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 227 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -126237,7 +132096,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 231 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -126282,10 +132141,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -126307,9 +132165,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -126380,6 +132240,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -126408,6 +132269,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -126419,6 +132281,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -126562,13 +132425,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -126576,13 +132439,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -126953,7 +132817,7 @@ var ts; typeAcquisition: configFile.typeAcquisition, files: configFile.fileNames, raw: configFile.raw, - errors: realizeDiagnostics(result.parseDiagnostics.concat(configFile.errors), "\r\n") + errors: realizeDiagnostics(__spreadArrays(result.parseDiagnostics, configFile.errors), "\r\n") }; }); }; @@ -127040,8 +132904,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index d13ea15429262..245c71a018f74 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -15,6 +15,13 @@ and limitations under the License. "use strict"; +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -74,7 +81,7 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -92,7 +99,7 @@ var ts; ts.emptyArray = []; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-null // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -127,7 +134,7 @@ var ts; } ts.createMapFromTemplate = createMapFromTemplate; // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name + // eslint-disable-next-line no-in-operator ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. function shimMap() { @@ -191,7 +198,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -288,6 +295,21 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Like `forEach`, but iterates in reverse order. + */ + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ function firstDefined(array, callback) { if (array === undefined) { @@ -784,7 +806,7 @@ var ts; return array1; if (!some(array1)) return array2; - return array1.concat(array2); + return __spreadArrays(array1, array2); } ts.concatenate = concatenate; function deduplicateRelational(array, equalityComparer, comparer) { @@ -841,6 +863,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1231,6 +1254,18 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; function getOwnValues(sparseArray) { var values = []; for (var key in sparseArray) { @@ -1369,6 +1404,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1428,7 +1469,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1462,7 +1503,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1936,11 +1977,33 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2017,8 +2080,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2067,6 +2132,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2082,7 +2148,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2190,6 +2256,9 @@ var ts; Debug.assertNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1 /* Normal */) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -2370,6 +2439,47 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + // require() will throw an exception if the module is not installed + // It may also return undefined if not installed properly + etwModule = require("@microsoft/typescript-etw"); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; + var args = typeof process === "undefined" ? [] : process.argv; + ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { // https://semver.org/#spec-item-2 // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative @@ -2768,358 +2878,366 @@ var ts; 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"; + SyntaxKind[SyntaxKind["QuestionDotToken"] = 28] = "QuestionDotToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 29] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 30] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 31] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 32] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 33] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 34] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 35] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 36] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 37] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 38] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 39] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 40] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 41] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 42] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 43] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 44] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 45] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 46] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 47] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 49] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 50] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 51] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 52] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 53] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 54] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 55] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 56] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 57] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 58] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 59] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - SyntaxKind[SyntaxKind["BacktickToken"] = 59] = "BacktickToken"; + SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 60] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 61] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 62] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 63] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 64] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 65] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 66] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 67] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 69] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 70] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 71] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 72] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 74] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 73] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 75] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 74] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 75] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 76] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 77] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 78] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 79] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 80] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 81] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 82] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 83] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 84] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 85] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 86] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 87] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 88] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 89] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 90] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 91] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 92] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 93] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 94] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 95] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 96] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 97] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 98] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 99] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 100] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 101] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 102] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 103] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 104] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 105] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 106] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 107] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 108] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 109] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 76] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 77] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 78] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 79] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 80] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 81] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 82] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 83] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 84] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 85] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 86] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 87] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 88] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 89] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 90] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 91] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 92] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 93] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 94] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 95] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 96] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 97] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 98] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 99] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 100] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 101] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 102] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 103] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 104] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 105] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 106] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 107] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 108] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 109] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 110] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 111] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 110] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 111] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 112] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 113] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 114] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 115] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 116] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 117] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 118] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 112] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 113] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 114] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 115] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 116] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 117] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 118] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 119] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 120] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 119] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 120] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 121] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 122] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 123] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 124] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 125] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 126] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 127] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 128] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 129] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 130] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 131] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 132] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 133] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 134] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 135] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 136] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 137] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 138] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 139] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 140] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 141] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 142] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 143] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 144] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 121] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 122] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 123] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 124] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 125] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 126] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 127] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 128] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 129] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 130] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 131] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 132] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 133] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 134] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 135] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 136] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 137] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 138] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 139] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 140] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 141] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 142] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 143] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 144] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 145] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 146] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 147] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 148] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 149] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 150] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 151] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 152] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 153] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 154] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 155] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 156] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 157] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 158] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 159] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 160] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 161] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 162] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 163] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 164] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 165] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 166] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 167] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 168] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 169] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 170] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 171] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 172] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 173] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 174] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 175] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 176] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 177] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 178] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 179] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 180] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 181] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 182] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 183] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 184] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 185] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 186] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 187] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 188] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 189] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 190] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 191] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 192] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 193] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 194] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 195] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 196] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 197] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 198] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 199] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 200] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 201] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 202] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 203] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 204] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 205] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 206] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 207] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 208] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 209] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 210] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 211] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 212] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 213] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 214] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 215] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 216] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 217] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 218] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 219] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 220] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 221] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 222] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 223] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 224] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 225] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 226] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 227] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 228] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 229] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 230] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 231] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 232] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 233] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 234] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 235] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 236] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 237] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 238] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 239] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 240] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 241] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 242] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 243] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 244] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 245] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 246] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 247] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 248] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 249] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 250] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 251] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 252] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 253] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 254] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 255] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 256] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 257] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 258] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 259] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 260] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 261] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 262] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 263] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 264] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 265] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 266] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 267] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 268] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 269] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 270] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 271] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 272] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 273] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 274] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 275] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 276] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 277] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 278] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 279] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 280] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 281] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 282] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 283] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 284] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 285] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 286] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 287] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 288] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 289] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 290] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 291] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 292] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 293] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 297] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 298] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 299] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 300] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 301] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 302] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 303] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 304] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 305] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 306] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 307] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 308] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 309] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 310] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 311] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 312] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 294] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 295] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 296] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 297] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 298] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 299] = "JSDocVariadicType"; + // https://jsdoc.app/about-namepaths.html + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 300] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 301] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 302] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 303] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 304] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 305] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 306] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 307] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 308] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 309] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 310] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 311] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 312] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 313] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 314] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 315] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 316] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 313] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 317] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 314] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 315] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 316] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 317] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 318] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 318] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 319] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 320] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 321] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 322] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 323] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 319] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 324] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 61] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 72] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 74] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 74] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 76] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 111] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 76] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 151] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 112] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 120] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 167] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 187] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 74] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 151] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 312] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 300] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 312] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 74] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 224] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 240] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 152] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 292] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 316] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 304] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 316] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 121] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 151] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3129,20 +3247,21 @@ var ts; NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain"; + NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 1024] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2048] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4096] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData"; // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid // walking the tree if the flags are not set. However, these flags are just a approximation // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. @@ -3152,23 +3271,23 @@ var ts; // removal, it is likely that users will add the import anyway. // The advantage of this approach is its simplicity. For the case of batch compilation, // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta"; - NodeFlags[NodeFlags["JSDoc"] = 2097152] = "JSDoc"; - /* @internal */ NodeFlags[NodeFlags["Ambient"] = 4194304] = "Ambient"; - /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 8388608] = "InWithStatement"; - NodeFlags[NodeFlags["JsonFile"] = 16777216] = "JsonFile"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta"; + NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc"; + /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient"; + /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement"; + NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 12679168] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags"; // Represents all flags that are potentially set once and // never cleared on SourceFiles which get re-used in between incremental parses. // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. - /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags"; + /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -3207,7 +3326,10 @@ var ts; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; - RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + RelationComparisonResult[RelationComparisonResult["Reported"] = 4] = "Reported"; + RelationComparisonResult[RelationComparisonResult["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable"; + RelationComparisonResult[RelationComparisonResult["ReportsUnreliable"] = 16] = "ReportsUnreliable"; + RelationComparisonResult[RelationComparisonResult["ReportsMask"] = 24] = "ReportsMask"; })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ var GeneratedIdentifierFlags; @@ -3243,6 +3365,8 @@ var ts; /* @internal */ TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator"; /* @internal */ + TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; + /* @internal */ TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; @@ -3258,12 +3382,13 @@ var ts; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; - FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Call"] = 512] = "Call"; + FlowFlags[FlowFlags["Referenced"] = 1024] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 2048] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 4096] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 8192] = "AfterFinally"; /** @internal */ - FlowFlags[FlowFlags["Cached"] = 8192] = "Cached"; + FlowFlags[FlowFlags["Cached"] = 16384] = "Cached"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -3273,6 +3398,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3293,6 +3425,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3358,7 +3492,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3408,27 +3541,40 @@ var ts; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + TypePredicateKind[TypePredicateKind["AssertsThis"] = 2] = "AssertsThis"; + TypePredicateKind[TypePredicateKind["AssertsIdentifier"] = 3] = "AssertsIdentifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3466,32 +3612,32 @@ var ts; SymbolFlags[SymbolFlags["All"] = 67108863] = "All"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = 67220415] = "Value"; - SymbolFlags[SymbolFlags["Type"] = 67897832] = "Type"; + SymbolFlags[SymbolFlags["Value"] = 111551] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 788968] = "Type"; SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; // Variables can be redeclared, but can not redeclare a block-scoped declaration with the // same name, or any other value that is not a variable, e.g. ValueModule or Class - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 67220414] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 111550] = "FunctionScopedVariableExcludes"; // Block-scoped declarations are not allowed to be re-declared // they can not merge with anything in the value space - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 67220415] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = 67220415] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 111551] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 111551] = "ParameterExcludes"; SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 68008959] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = 67219887] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 68008383] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 67897736] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 68008191] = "RegularEnumExcludes"; - SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 68008831] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 110991] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899503] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 788872] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 110735] = "ValueModuleExcludes"; SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = 67212223] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 67154879] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 67187647] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 67635688] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 67897832] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 103359] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 46015] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 78783] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 526824] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 788968] = "TypeAliasExcludes"; SymbolFlags[SymbolFlags["AliasExcludes"] = 2097152] = "AliasExcludes"; SymbolFlags[SymbolFlags["ModuleMember"] = 2623475] = "ModuleMember"; SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; @@ -3499,11 +3645,15 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; /* @internal */ + SymbolFlags[SymbolFlags["ExportSupportsDefaultModifier"] = 112] = "ExportSupportsDefaultModifier"; + /* @internal */ + SymbolFlags[SymbolFlags["ExportDoesNotSupportDefaultModifier"] = -113] = "ExportDoesNotSupportDefaultModifier"; + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable"; /* @internal */ - SymbolFlags[SymbolFlags["LateBindingContainer"] = 6240] = "LateBindingContainer"; + SymbolFlags[SymbolFlags["LateBindingContainer"] = 6256] = "LateBindingContainer"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ var EnumKind; @@ -3741,7 +3891,9 @@ var ts; InferencePriority[InferencePriority["LiteralKeyof"] = 32] = "LiteralKeyof"; InferencePriority[InferencePriority["NoConstraints"] = 64] = "NoConstraints"; InferencePriority[InferencePriority["AlwaysStrict"] = 128] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 256] = "MaxValue"; InferencePriority[InferencePriority["PriorityImpliesCombination"] = 56] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ var InferenceFlags; @@ -3819,6 +3971,9 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; + // NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind. + // Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES + // module kind). ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); @@ -4403,7 +4558,7 @@ var ts; function getCustomPollingBasedLevels(baseVariable, defaultLevels) { var customLevels = getCustomLevels(baseVariable); return (pollingIntervalChanged || customLevels) && - createPollingIntervalBasedLevels(customLevels ? __assign({}, defaultLevels, customLevels) : defaultLevels); + createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels); } } ts.setCustomPollingValues = setCustomPollingValues; @@ -4557,6 +4712,38 @@ var ts; } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; + /* @internal */ + function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { + var cache = ts.createMap(); + var callbacksCache = ts.createMultiMap(); + var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + return function (fileName, callback, pollingInterval) { + var path = toCanonicalFileName(fileName); + var existing = cache.get(path); + if (existing) { + existing.refCount++; + } + else { + cache.set(path, { + watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval), + refCount: 1 + }); + } + callbacksCache.add(path, callback); + return { + close: function () { + var watcher = ts.Debug.assertDefined(cache.get(path)); + callbacksCache.remove(path, callback); + watcher.refCount--; + if (watcher.refCount) + return; + cache.delete(path); + ts.closeFileWatcherOf(watcher); + } + }; + }; + } + ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName; /** * Returns true if file status changed */ @@ -4583,6 +4770,8 @@ var ts; ts.getFileWatcherEventKind = getFileWatcherEventKind; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; + /*@internal*/ + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4687,6 +4876,32 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + /** + * patch writefile to create folder before writing the file + */ + /*@internal*/ + function patchWriteFileEnsuringDirectory(sys) { + // patch writefile to create folder before writing the file + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -4703,12 +4918,14 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does // not actually work. var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -4720,9 +4937,12 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; + var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); var FileSystemEntryKind; @@ -4733,6 +4953,7 @@ var ts; var useNonPollingWatchers = process.env.TSC_NONPOLLING_WATCHER; var tscWatchFile = process.env.TSC_WATCHFILE; var tscWatchDirectory = process.env.TSC_WATCHDIRECTORY; + var fsWatchFile = createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames); var dynamicPollingWatchFile; var nodeSystem = { args: process.argv.slice(2), @@ -4799,8 +5020,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -4826,6 +5049,90 @@ var ts; base64encode: function (input) { return bufferFrom(input).toString("base64"); }, }; return nodeSystem; + /** + * Uses the builtin inspector APIs to capture a CPU profile + * See https://nodejs.org/api/inspector.html#inspector_example_usage for details + */ + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + /** + * Strips non-TS paths from the profile, so users with private projects shouldn't + * need to worry about leaking paths by submitting a cpu profile to us + */ + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + // do nothing and ignore fallible fs operation + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + // do nothing and ignore fallible fs operation + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { // See https://github.com/Microsoft/TypeScript/issues/25652 return Buffer.from && Buffer.from !== Int8Array.from @@ -4869,7 +5176,7 @@ var ts; return useNonPollingWatchers ? createNonPollingWatchFile() : // Default to do not use polling interval as it is before this experiment branch - function (fileName, callback) { return fsWatchFile(fileName, callback); }; + function (fileName, callback) { return fsWatchFile(fileName, callback, /*pollingInterval*/ undefined); }; } function getWatchDirectory() { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows @@ -4943,7 +5250,7 @@ var ts; return watcher; } } - function fsWatchFile(fileName, callback, pollingInterval) { + function fsWatchFileWorker(fileName, callback, pollingInterval) { _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); var eventKind; return { @@ -5001,6 +5308,12 @@ var ts; } function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingWatchFile, pollingInterval) { var options; + var lastDirectoryPartWithDirectorySeparator; + var lastDirectoryPart; + if (isLinuxOrMacOs) { + lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator)); + lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length); + } /** Watcher for the file system entry depending on whether it is missing or present */ var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ? watchMissingFileSystemEntry() : @@ -5017,6 +5330,7 @@ var ts; * @param createWatcher */ function invokeCallbackAndUpdateWatcher(createWatcher) { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); // Call the callback for current directory callback("rename", ""); // If watcher is not closed, update it @@ -5041,7 +5355,9 @@ var ts; } } try { - var presentWatcher = _fs.watch(fileOrDirectory, options, callback); + var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ? + callbackChangingToMissingFileSystemEntry : + callback); // Watch the missing file or directory or error presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); }); return presentWatcher; @@ -5053,11 +5369,23 @@ var ts; return watchPresentFileSystemEntryWithFsWatchFile(); } } + function callbackChangingToMissingFileSystemEntry(event, relativeName) { + // because relativeName is not guaranteed to be correct we need to check on each rename with few combinations + // Eg on ubuntu while watching app/node_modules the relativeName is "node_modules" which is neither relative nor full path + return event === "rename" && + (!relativeName || + relativeName === lastDirectoryPart || + relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + !fileSystemEntryExists(fileOrDirectory, entryKind) ? + invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : + callback(event, relativeName); + } /** * Watch the file or directory using fs.watchFile since fs.watch threw exception * Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point */ function watchPresentFileSystemEntryWithFsWatchFile() { + ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile"); return fallbackPollingWatchFile(fileOrDirectory, createFileWatcherCallback(callback), pollingInterval); } /** @@ -5090,7 +5418,7 @@ var ts; function createWatchDirectoryUsing(fsWatchFile) { return function (directoryName, callback) { return fsWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium); }; } - function readFile(fileName, _encoding) { + function readFileWorker(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -5118,7 +5446,14 @@ var ts; // Default is UTF-8 with no byte order mark return buffer.toString("utf8"); } + function readFile(fileName, _encoding) { + ts.perfLogger.logStartReadFile(fileName); + var file = readFileWorker(fileName, _encoding); + ts.perfLogger.logStopReadFile(); + return file; + } function writeFile(fileName, data, writeByteOrderMark) { + ts.perfLogger.logEvent("WriteFile: " + fileName); // If a BOM is required, emit one if (writeByteOrderMark) { data = byteOrderMarkIndicator + data; @@ -5135,6 +5470,7 @@ var ts; } } function getAccessibleFileSystemEntries(path) { + ts.perfLogger.logEvent("ReadDir: " + (path || ".")); try { var entries = _fs.readdirSync(path || ".").sort(); var files = []; @@ -5190,6 +5526,7 @@ var ts; return fileSystemEntryExists(path, 1 /* Directory */); } function getDirectories(path) { + ts.perfLogger.logEvent("ReadDir: " + path); return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } function realpath(path) { @@ -5267,16 +5604,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -5288,14 +5615,7 @@ var ts; } if (sys) { // patch writefile to create folder before writing the file - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -5314,10 +5634,9 @@ var ts; /* @internal */ var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; } - // tslint:disable-next-line variable-name ts.Diagnostics = { Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), @@ -5380,7 +5699,6 @@ var ts; A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - An_accessor_cannot_be_declared_in_an_ambient_context: diag(1086, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_declared_in_an_ambient_context_1086", "An accessor cannot be declared in an ambient context."), _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), @@ -5435,7 +5753,6 @@ var ts; Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), @@ -5533,6 +5850,7 @@ var ts; A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), @@ -5565,7 +5883,7 @@ var ts; Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343", "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -5579,6 +5897,16 @@ var ts; readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(1359, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_1359", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(1360, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_1360", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), 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."), @@ -5622,7 +5950,7 @@ var ts; Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), @@ -5870,6 +6198,9 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -5992,6 +6323,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), 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}'."), @@ -6078,6 +6417,9 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -6088,6 +6430,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -6113,6 +6456,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -6300,6 +6644,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + 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}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -6318,9 +6663,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), 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}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -6359,6 +6706,8 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), @@ -6445,6 +6794,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -6474,6 +6825,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6591,6 +6943,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -6601,94 +6961,95 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 73 /* Identifier */; + return token >= 75 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119 /* AbstractKeyword */, - any: 121 /* AnyKeyword */, - as: 120 /* AsKeyword */, - bigint: 147 /* BigIntKeyword */, - boolean: 124 /* BooleanKeyword */, - break: 74 /* BreakKeyword */, - case: 75 /* CaseKeyword */, - catch: 76 /* CatchKeyword */, - class: 77 /* ClassKeyword */, - continue: 79 /* ContinueKeyword */, - const: 78 /* ConstKeyword */ + abstract: 121 /* AbstractKeyword */, + any: 124 /* AnyKeyword */, + as: 122 /* AsKeyword */, + asserts: 123 /* AssertsKeyword */, + bigint: 150 /* BigIntKeyword */, + boolean: 127 /* BooleanKeyword */, + break: 76 /* BreakKeyword */, + case: 77 /* CaseKeyword */, + catch: 78 /* CatchKeyword */, + class: 79 /* ClassKeyword */, + continue: 81 /* ContinueKeyword */, + const: 80 /* ConstKeyword */ }, - _a["" + "constructor"] = 125 /* ConstructorKeyword */, - _a.debugger = 80 /* DebuggerKeyword */, - _a.declare = 126 /* DeclareKeyword */, - _a.default = 81 /* DefaultKeyword */, - _a.delete = 82 /* DeleteKeyword */, - _a.do = 83 /* DoKeyword */, - _a.else = 84 /* ElseKeyword */, - _a.enum = 85 /* EnumKeyword */, - _a.export = 86 /* ExportKeyword */, - _a.extends = 87 /* ExtendsKeyword */, - _a.false = 88 /* FalseKeyword */, - _a.finally = 89 /* FinallyKeyword */, - _a.for = 90 /* ForKeyword */, - _a.from = 145 /* FromKeyword */, - _a.function = 91 /* FunctionKeyword */, - _a.get = 127 /* GetKeyword */, - _a.if = 92 /* IfKeyword */, - _a.implements = 110 /* ImplementsKeyword */, - _a.import = 93 /* ImportKeyword */, - _a.in = 94 /* InKeyword */, - _a.infer = 128 /* InferKeyword */, - _a.instanceof = 95 /* InstanceOfKeyword */, - _a.interface = 111 /* InterfaceKeyword */, - _a.is = 129 /* IsKeyword */, - _a.keyof = 130 /* KeyOfKeyword */, - _a.let = 112 /* LetKeyword */, - _a.module = 131 /* ModuleKeyword */, - _a.namespace = 132 /* NamespaceKeyword */, - _a.never = 133 /* NeverKeyword */, - _a.new = 96 /* NewKeyword */, - _a.null = 97 /* NullKeyword */, - _a.number = 136 /* NumberKeyword */, - _a.object = 137 /* ObjectKeyword */, - _a.package = 113 /* PackageKeyword */, - _a.private = 114 /* PrivateKeyword */, - _a.protected = 115 /* ProtectedKeyword */, - _a.public = 116 /* PublicKeyword */, - _a.readonly = 134 /* ReadonlyKeyword */, - _a.require = 135 /* RequireKeyword */, - _a.global = 146 /* GlobalKeyword */, - _a.return = 98 /* ReturnKeyword */, - _a.set = 138 /* SetKeyword */, - _a.static = 117 /* StaticKeyword */, - _a.string = 139 /* StringKeyword */, - _a.super = 99 /* SuperKeyword */, - _a.switch = 100 /* SwitchKeyword */, - _a.symbol = 140 /* SymbolKeyword */, - _a.this = 101 /* ThisKeyword */, - _a.throw = 102 /* ThrowKeyword */, - _a.true = 103 /* TrueKeyword */, - _a.try = 104 /* TryKeyword */, - _a.type = 141 /* TypeKeyword */, - _a.typeof = 105 /* TypeOfKeyword */, - _a.undefined = 142 /* UndefinedKeyword */, - _a.unique = 143 /* UniqueKeyword */, - _a.unknown = 144 /* UnknownKeyword */, - _a.var = 106 /* VarKeyword */, - _a.void = 107 /* VoidKeyword */, - _a.while = 108 /* WhileKeyword */, - _a.with = 109 /* WithKeyword */, - _a.yield = 118 /* YieldKeyword */, - _a.async = 122 /* AsyncKeyword */, - _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a["" + "constructor"] = 128 /* ConstructorKeyword */, + _a.debugger = 82 /* DebuggerKeyword */, + _a.declare = 129 /* DeclareKeyword */, + _a.default = 83 /* DefaultKeyword */, + _a.delete = 84 /* DeleteKeyword */, + _a.do = 85 /* DoKeyword */, + _a.else = 86 /* ElseKeyword */, + _a.enum = 87 /* EnumKeyword */, + _a.export = 88 /* ExportKeyword */, + _a.extends = 89 /* ExtendsKeyword */, + _a.false = 90 /* FalseKeyword */, + _a.finally = 91 /* FinallyKeyword */, + _a.for = 92 /* ForKeyword */, + _a.from = 148 /* FromKeyword */, + _a.function = 93 /* FunctionKeyword */, + _a.get = 130 /* GetKeyword */, + _a.if = 94 /* IfKeyword */, + _a.implements = 112 /* ImplementsKeyword */, + _a.import = 95 /* ImportKeyword */, + _a.in = 96 /* InKeyword */, + _a.infer = 131 /* InferKeyword */, + _a.instanceof = 97 /* InstanceOfKeyword */, + _a.interface = 113 /* InterfaceKeyword */, + _a.is = 132 /* IsKeyword */, + _a.keyof = 133 /* KeyOfKeyword */, + _a.let = 114 /* LetKeyword */, + _a.module = 134 /* ModuleKeyword */, + _a.namespace = 135 /* NamespaceKeyword */, + _a.never = 136 /* NeverKeyword */, + _a.new = 98 /* NewKeyword */, + _a.null = 99 /* NullKeyword */, + _a.number = 139 /* NumberKeyword */, + _a.object = 140 /* ObjectKeyword */, + _a.package = 115 /* PackageKeyword */, + _a.private = 116 /* PrivateKeyword */, + _a.protected = 117 /* ProtectedKeyword */, + _a.public = 118 /* PublicKeyword */, + _a.readonly = 137 /* ReadonlyKeyword */, + _a.require = 138 /* RequireKeyword */, + _a.global = 149 /* GlobalKeyword */, + _a.return = 100 /* ReturnKeyword */, + _a.set = 141 /* SetKeyword */, + _a.static = 119 /* StaticKeyword */, + _a.string = 142 /* StringKeyword */, + _a.super = 101 /* SuperKeyword */, + _a.switch = 102 /* SwitchKeyword */, + _a.symbol = 143 /* SymbolKeyword */, + _a.this = 103 /* ThisKeyword */, + _a.throw = 104 /* ThrowKeyword */, + _a.true = 105 /* TrueKeyword */, + _a.try = 106 /* TryKeyword */, + _a.type = 144 /* TypeKeyword */, + _a.typeof = 107 /* TypeOfKeyword */, + _a.undefined = 145 /* UndefinedKeyword */, + _a.unique = 146 /* UniqueKeyword */, + _a.unknown = 147 /* UnknownKeyword */, + _a.var = 108 /* VarKeyword */, + _a.void = 109 /* VoidKeyword */, + _a.while = 110 /* WhileKeyword */, + _a.with = 111 /* WithKeyword */, + _a.yield = 120 /* YieldKeyword */, + _a.async = 125 /* AsyncKeyword */, + _a.await = 126 /* AwaitKeyword */, + _a.of = 151 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - 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 */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 74 /* CaretEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -6735,6 +7096,14 @@ var ts; */ 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,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 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, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 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, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 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, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 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, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + /** + * Generated by scripts/regenerate-unicode-identifier-parts.js on node v12.4.0 with unicode 12.1 + * based on http://www.unicode.org/reports/tr31/ and https://www.ecma-international.org/ecma-262/6.0/#sec-names-and-keywords + * unicodeESNextIdentifierStart corresponds to the ID_Start and Other_ID_Start property, and + * unicodeESNextIdentifierPart corresponds to ID_Continue, Other_ID_Continue, plus ID_Start and Other_ID_Start + */ + var unicodeESNextIdentifierStart = [65, 90, 97, 122, 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, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 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, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 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, 2809, 2809, 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, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 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, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 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, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 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, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 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, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 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, 43824, 43866, 43868, 43879, 43888, 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, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; + var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 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, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 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, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -6761,15 +7130,17 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 /* ES5 */ ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); + return languageVersion >= 2 /* ES2015 */ ? + lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : + languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { var result = []; @@ -6942,6 +7313,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7265,11 +7637,12 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + var ch = codePointAt(name, 0); + if (!isIdentifierStart(ch, languageVersion)) { return false; } - for (var i = 1; i < name.length; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + for (var i = charSize(ch); i < name.length; i += charSize(ch)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { return false; } } @@ -7293,17 +7666,18 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */; }, + isIdentifier: function () { return token === 75 /* Identifier */ || token > 111 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -7313,6 +7687,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -7327,6 +7702,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7426,7 +7810,7 @@ var ts; } } function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { - if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) { + if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { return; } var identifierStart = pos; @@ -7634,6 +8018,7 @@ var ts; pos++; return scanExtendedUnicodeEscape(); } + tokenFlags |= 1024 /* UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: @@ -7716,21 +8101,41 @@ var ts; } return -1; } + function peekExtendedUnicodeEscape() { + if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + var start_2 = pos; + pos += 3; + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + pos = start_2; + return escapedValue; + } + return -1; + } function scanIdentifierParts() { var result = ""; var start = pos; while (pos < end) { - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); if (isIdentifierPart(ch, languageVersion)) { - pos++; + pos += charSize(ch); } else if (ch === 92 /* backslash */) { + ch = peekExtendedUnicodeEscape(); + if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + result += scanExtendedUnicodeEscape(); + start = pos; + continue; + } ch = peekUnicodeEscape(); if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } + tokenFlags |= 1024 /* UnicodeEscape */; result += text.substring(start, pos); - result += String.fromCharCode(ch); + result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters pos += 6; start = pos; @@ -7754,7 +8159,7 @@ var ts; } } } - return token = 73 /* Identifier */; + return token = 75 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -7818,14 +8223,14 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); + var ch = codePointAt(text, pos); // Special handling for shebang if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); @@ -7889,12 +8294,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 34 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* ExclamationEqualsToken */; } pos++; - return token = 52 /* ExclamationToken */; + return token = 53 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -7903,19 +8308,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* PercentEqualsToken */; + return pos += 2, token = 68 /* PercentEqualsToken */; } pos++; - return token = 43 /* PercentToken */; + return token = 44 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 54 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* AmpersandEqualsToken */; + return pos += 2, token = 72 /* AmpersandEqualsToken */; } pos++; - return token = 49 /* AmpersandToken */; + return token = 50 /* AmpersandToken */; case 40 /* openParen */: pos++; return token = 20 /* OpenParenToken */; @@ -7924,13 +8329,13 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AsteriskEqualsToken */; + return pos += 2, token = 65 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 41 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -7938,28 +8343,28 @@ var ts; asteriskSeen = true; continue; } - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 44 /* PlusPlusToken */; + return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* PlusEqualsToken */; + return pos += 2, token = 63 /* PlusEqualsToken */; } pos++; - return token = 38 /* PlusToken */; + return token = 39 /* PlusToken */; case 44 /* comma */: pos++; return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 45 /* MinusMinusToken */; + return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* MinusEqualsToken */; + return pos += 2, token = 64 /* MinusEqualsToken */; } pos++; - return token = 39 /* MinusToken */; + return token = 40 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -8020,10 +8425,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* SlashEqualsToken */; + return pos += 2, token = 67 /* SlashEqualsToken */; } pos++; - return token = 42 /* SlashToken */; + return token = 43 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -8081,7 +8486,7 @@ var ts; return token; case 58 /* colon */: pos++; - return token = 57 /* ColonToken */; + return token = 58 /* ColonToken */; case 59 /* semicolon */: pos++; return token = 26 /* SemicolonToken */; @@ -8097,20 +8502,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 46 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 31 /* LessThanEqualsToken */; + return pos += 2, token = 32 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 29 /* LessThanSlashToken */; + return pos += 2, token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8123,15 +8528,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 33 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 37 /* EqualsGreaterThanToken */; + return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8143,10 +8548,18 @@ var ts; } } pos++; - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 56 /* QuestionToken */; + if (text.charCodeAt(pos) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28 /* QuestionDotToken */; + } + if (text.charCodeAt(pos) === 63 /* question */) { + pos++; + return token = 60 /* QuestionQuestionToken */; + } + return token = 57 /* QuestionToken */; case 91 /* openBracket */: pos++; return token = 22 /* OpenBracketToken */; @@ -8155,10 +8568,10 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* CaretEqualsToken */; + return pos += 2, token = 74 /* CaretEqualsToken */; } pos++; - return token = 51 /* CaretToken */; + return token = 52 /* CaretToken */; case 123 /* openBrace */: pos++; return token = 18 /* OpenBraceToken */; @@ -8173,26 +8586,34 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 55 /* BarBarToken */; + return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* BarEqualsToken */; + return pos += 2, token = 73 /* BarEqualsToken */; } pos++; - return token = 50 /* BarToken */; + return token = 51 /* BarToken */; case 125 /* closeBrace */: pos++; return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 53 /* TildeToken */; + return token = 54 /* TildeToken */; case 64 /* at */: pos++; - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 92 /* backslash */: + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } @@ -8201,9 +8622,9 @@ var ts; return token = 0 /* Unknown */; default: if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); if (ch === 92 /* backslash */) { tokenValue += scanIdentifierParts(); @@ -8211,44 +8632,44 @@ var ts; return token = getIdentifierToken(); } else if (isWhiteSpaceSingleLine(ch)) { - pos++; + pos += charSize(ch); continue; } else if (isLineBreak(ch)) { tokenFlags |= 1 /* PrecedingLineBreak */; - pos++; + pos += charSize(ch); continue; } error(ts.Diagnostics.Invalid_character); - pos++; + pos += charSize(ch); return token = 0 /* Unknown */; } } } function reScanGreaterToken() { - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 47 /* GreaterThanGreaterThanToken */; + return token = 48 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 32 /* GreaterThanEqualsToken */; + return token = 33 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 42 /* SlashToken */ || token === 65 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -8310,12 +8731,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46 /* LessThanLessThanToken */) { + if (token === 47 /* LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57 /* QuestionToken */; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -8325,10 +8751,10 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 29 /* LessThanSlashToken */; + return token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; @@ -8337,7 +8763,7 @@ var ts; // First non-whitespace character on this line. var firstNonWhitespace = 0; // These initial values are special because the first line is: - // firstNonWhitespace = 0 to indicate that we want leading whitspace, + // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { @@ -8371,17 +8797,22 @@ var ts; // they allow dashes function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; + // An identifier or keyword has already been parsed - check for a `-` and then append it and everything after it to the token + // Do note that this means that `scanJsxIdentifier` effectively _mutates_ the visible token without advancing to a new token + // Any caller should be expecting this behavior and should only read the pos or token value after calling it. while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + if (ch === 45 /* minus */) { + tokenValue += "-"; pos++; + continue; } - else { + var oldPos = pos; + tokenValue += scanIdentifierParts(); // reuse `scanIdentifierParts` so unicode escapes are handled + if (pos === oldPos) { break; } } - tokenValue += text.substring(firstCharPosition, pos); } return token; } @@ -8399,12 +8830,12 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } - var ch = text.charCodeAt(pos); - pos++; + var ch = codePointAt(text, pos); + pos += charSize(ch); switch (ch) { case 9 /* tab */: case 11 /* verticalTab */: @@ -8415,13 +8846,13 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 123 /* openBrace */: return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: @@ -8431,23 +8862,44 @@ var ts; case 93 /* closeBracket */: return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 62 /* greaterThan */: - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 44 /* comma */: return token = 27 /* CommaToken */; case 46 /* dot */: return token = 24 /* DotToken */; case 96 /* backtick */: - return token = 59 /* BacktickToken */; - } - if (isIdentifierStart(ch, 99 /* Latest */)) { - while (isIdentifierPart(text.charCodeAt(pos), 99 /* Latest */) && pos < end) { + return token = 61 /* BacktickToken */; + case 92 /* backslash */: + pos--; + var extendedCookedChar = peekExtendedUnicodeEscape(); + if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { + pos += 3; + tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); + return token = getIdentifierToken(); + } + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenFlags |= 1024 /* UnicodeEscape */; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } pos++; - } + return token = 0 /* Unknown */; + } + if (isIdentifierStart(ch, languageVersion)) { + var char = ch; + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + pos += charSize(char); tokenValue = text.substring(tokenPos, pos); + if (char === 92 /* backslash */) { + tokenValue += scanIdentifierParts(); + } return token = getIdentifierToken(); } else { @@ -8523,13 +8975,40 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; } } ts.createScanner = createScanner; + /* @internal */ + var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) { + // from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt + var size = str.length; + // Account for out-of-bounds indices: + if (i < 0 || i >= size) { + return undefined; // String.codePointAt returns `undefined` for OOB indexes + } + // Get the first code unit + var first = str.charCodeAt(i); + // check if it’s the start of a surrogate pair + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { // high surrogate and there is a next code unit + var second = str.charCodeAt(i + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + }; + /* @internal */ + function charSize(ch) { + if (ch >= 0x10000) { + return 2; + } + return 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -8609,6 +9088,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str += " "; }, @@ -8696,7 +9177,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -8784,28 +9265,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144 /* HasAggregatedChildData */)) { + if (!(node.flags & 524288 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 262144 /* HasAggregatedChildData */; + node.flags |= 524288 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 288 /* SourceFile */) { node = node.parent; } return node; @@ -8813,11 +9294,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return true; } return false; @@ -8902,7 +9383,7 @@ var ts; break; } } - to.splice.apply(to, [statementIndex, 0].concat(from)); + to.splice.apply(to, __spreadArrays([statementIndex, 0], from)); return to; } function insertStatementAfterPrologue(to, statement, isPrologueDirective) { @@ -8985,7 +9466,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 === 313 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 317 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9004,7 +9485,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9050,6 +9531,8 @@ var ts; ts.isBigIntLiteral(node))) { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } + // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text + // had to include a backslash: `not \${a} substitution`. 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. @@ -9062,15 +9545,21 @@ var ts; return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; } case 14 /* NoSubstitutionTemplateLiteral */: - return "`" + escapeText(node.text, 96 /* backtick */) + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings - return "`" + escapeText(node.text, 96 /* backtick */) + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings - return "}" + escapeText(node.text, 96 /* backtick */) + "${"; case 17 /* TemplateTail */: - return "}" + escapeText(node.text, 96 /* backtick */) + "`"; + var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + switch (node.kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + return "`" + rawText + "`"; + case 15 /* TemplateHead */: + return "`" + rawText + "${"; + case 16 /* TemplateMiddle */: + return "}" + rawText + "${"; + case 17 /* TemplateTail */: + return "}" + rawText + "`"; + } + break; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 13 /* RegularExpressionLiteral */: @@ -9096,7 +9585,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 241 /* VariableDeclaration */ && node.parent.kind === 278 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9128,16 +9617,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 248 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 288 /* SourceFile */ || + node.kind === 248 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -9149,9 +9638,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 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9165,24 +9654,61 @@ var ts; return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; + /** + * Returns whether the source file will be treated as if it were in strict mode at runtime. + */ + function isEffectiveStrictModeSourceFile(node, compilerOptions) { + // We can only verify strict mode for JS/TS files + switch (node.scriptKind) { + case 1 /* JS */: + case 3 /* TS */: + case 2 /* JSX */: + case 4 /* TSX */: + break; + default: + return false; + } + // Strict mode does not matter for declaration files. + if (node.isDeclarationFile) { + return false; + } + // If `alwaysStrict` is set, then treat the file as strict. + if (ts.getStrictOptionValue(compilerOptions, "alwaysStrict")) { + return true; + } + // Starting with a "use strict" directive indicates the file is strict. + if (ts.startsWithUseStrict(node.statements)) { + return true; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + // ECMAScript Modules are always strict. + if (ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { + return true; + } + // Other modules are strict unless otherwise specified. + return !compilerOptions.noImplicitUseStrict; + } + return false; + } + ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 278 /* CatchClause */: + case 248 /* ModuleDeclaration */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 219 /* Block */: + case 222 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9192,9 +9718,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: - case 299 /* JSDocSignature */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 303 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9204,25 +9730,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9232,8 +9758,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9242,15 +9768,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 224 /* VariableStatement */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -9280,13 +9806,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -9297,11 +9823,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9346,7 +9872,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 222 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9360,7 +9886,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* 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 @@ -9369,25 +9895,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 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9395,6 +9921,7 @@ var ts; // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9424,7 +9951,7 @@ var ts; } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { @@ -9436,19 +9963,25 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 101 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 95 /* ImportKeyword */; } ts.isImportCall = isImportCall; + function isImportMeta(n) { + return ts.isMetaProperty(n) + && n.keywordToken === 95 /* ImportKeyword */ + && n.name.escapedText === "meta"; + } + ts.isImportMeta = isImportMeta; function isLiteralImportTypeNode(n) { return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 225 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9457,11 +9990,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 155 /* Parameter */ || + node.kind === 154 /* TypeParameter */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 201 /* ArrowFunction */ || + node.kind === 199 /* 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 '/**/' @@ -9477,48 +10010,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= node.kind && node.kind <= 187 /* LastTypeNode */) { return true; } switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: return true; - case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + case 109 /* VoidKeyword */: + return node.parent.kind !== 204 /* VoidExpression */; + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 154 /* TypeParameter */: + return node.parent.kind === 185 /* MappedType */ || node.parent.kind === 180 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 73 /* Identifier */: + case 75 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 193 /* 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 === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */ || node.kind === 193 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: - case 101 /* ThisKeyword */: { + case 152 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 103 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 171 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 187 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9527,40 +10060,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 (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= parent.kind && parent.kind <= 187 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return node === parent.constraint; - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9585,23 +10118,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 250 /* CaseBlock */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9611,26 +10144,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* 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 === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* 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); @@ -9653,10 +10186,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 173 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 168 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9666,12 +10199,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 172 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return node.properties; } } @@ -9679,14 +10212,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 282 /* EnumMember */: + case 155 /* Parameter */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 241 /* VariableDeclaration */: return true; } } @@ -9698,8 +10231,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 242 /* VariableDeclarationList */ + && node.parent.parent.kind === 224 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9710,13 +10243,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return true; } return false; @@ -9727,7 +10260,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 237 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9735,17 +10268,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 222 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 160 /* MethodDeclaration */ && node.parent.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 160 /* MethodDeclaration */ && + (node.parent.kind === 192 /* ObjectLiteralExpression */ || + node.parent.kind === 213 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9758,7 +10291,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -9799,14 +10332,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 288 /* 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 150 /* ComputedPropertyName */: + case 153 /* 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 @@ -9821,9 +10354,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* 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; @@ -9834,26 +10367,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 248 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 247 /* EnumDeclaration */: + case 288 /* SourceFile */: return node; } } @@ -9863,9 +10396,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return container; } } @@ -9887,27 +10420,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* 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; @@ -9923,21 +10456,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 200 /* FunctionExpression */ || func.kind === 201 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 199 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 195 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 /* SuperKeyword */ + return node.kind === 101 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -9946,8 +10479,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 99 /* SuperKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 101 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -9955,20 +10488,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 101 /* ThisKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 103 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: return node; } return undefined; @@ -9976,10 +10509,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9988,25 +10521,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 244 /* ClassDeclaration */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* 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 === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 244 /* ClassDeclaration */; + case 155 /* 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 === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 161 /* Constructor */ + || parent.kind === 160 /* MethodDeclaration */ + || parent.kind === 163 /* SetAccessor */) + && grandparent.kind === 244 /* ClassDeclaration */; } return false; } @@ -10022,10 +10555,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10034,9 +10567,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 266 /* JsxOpeningElement */ || + parent.kind === 265 /* JsxSelfClosingElement */ || + parent.kind === 267 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10044,57 +10577,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 216 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 212 /* SpreadElement */: + case 210 /* TemplateExpression */: + case 214 /* OmittedExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 211 /* YieldExpression */: + case 205 /* AwaitExpression */: + case 218 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 152 /* QualifiedName */: + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); - case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node); + case 75 /* Identifier */: + if (node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -10104,49 +10637,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 190 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 225 /* ExpressionStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 234 /* ReturnStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 238 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 229 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 156 /* Decorator */: + case 274 /* JsxExpression */: + case 273 /* JsxSpreadAttribute */: + case 281 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10154,7 +10687,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10163,7 +10696,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 263 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10175,15 +10708,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 131072 /* JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 4194304 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10191,15 +10724,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 /* StringKeyword */ || node.typeArguments[0].kind === 136 /* NumberKeyword */); + (node.typeArguments[0].kind === 142 /* StringKeyword */ || node.typeArguments[0].kind === 139 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + if (callExpression.kind !== 195 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 75 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -10230,21 +10763,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - 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 === 60 /* EqualsToken */ && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 /* EqualsToken */ && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -10254,13 +10791,14 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(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 === 55 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -10274,14 +10812,20 @@ var ts; } 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); }); + 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 === 60 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -10307,11 +10851,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 200 /* FunctionExpression */ || e.kind === 201 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 200 /* FunctionExpression */ || + initializer.kind === 213 /* ClassExpression */ || + initializer.kind === 201 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10328,14 +10872,16 @@ 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 === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && 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 === 60 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -10343,8 +10889,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 === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -10363,19 +10909,20 @@ var ts; * my.app = self.my.app || class { } */ function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 /* ThisKeyword */ || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -10390,10 +10937,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { @@ -10408,55 +10958,116 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0]); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */) || + isEntityNameExpression(node.expression) || + isBindableStaticElementAccessExpression(node.expression, /*excludeThisKeyword*/ true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */ || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0 /* None */; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8 /* ObjectDefinePropertyExports */; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9 /* ObjectDefinePrototypeProperty */; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 60 /* EqualsToken */ || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left)) { return 0 /* None */; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } return 6 /* Prototype */; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); + } + /** + * Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions + * throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand) + */ + /* @internal */ + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; + } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101 /* ThisKeyword */) { + if (lhs.expression.kind === 103 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") { // exports.name = expr OR module.exports.name = expr return 1 /* ExportsProperty */; } @@ -10479,7 +11090,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 225 /* ExpressionStatement */ && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10488,7 +11100,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10497,14 +11109,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 186 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10514,12 +11126,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 252 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 263 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 187 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10528,11 +11140,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10540,19 +11152,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 253 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 155 /* Parameter */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 280 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10566,7 +11178,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 311 /* JSDocTypedefTag */ || node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 315 /* JSDocTypedefTag */ || node.kind === 308 /* JSDocCallbackTag */ || node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10576,7 +11188,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 /* EqualsToken */ + node.expression.operatorToken.kind === 62 /* EqualsToken */ ? node.expression.right : undefined; } @@ -10585,18 +11197,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 /* BarBarToken */ + (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return node.initializer; } } @@ -10607,7 +11219,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 248 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10622,11 +11234,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 154 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10637,12 +11249,12 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 279 /* PropertyAssignment */ || + parent.kind === 258 /* ExportAssignment */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 225 /* ExpressionStatement */ && node.kind === 193 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10653,7 +11265,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10676,7 +11288,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10701,7 +11313,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10711,7 +11323,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 === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10724,31 +11336,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 62 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 191 /* ArrayLiteralExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10775,22 +11387,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 222 /* Block */: + case 224 /* VariableStatement */: + case 235 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return true; } return false; @@ -10807,33 +11419,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 181 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 199 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* 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 !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 202 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10855,11 +11467,12 @@ var ts; var parent = name.parent; switch (name.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -10882,8 +11495,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10891,32 +11504,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 193 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 152 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 171 /* TypeQuery */ || parent.kind === 168 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 190 /* BindingElement */: + case 257 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 261 /* ExportSpecifier */: + case 271 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10932,22 +11545,39 @@ var ts; // export = // export default // module.exports = + // {} + // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); + return node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 251 /* NamespaceExportDeclaration */ || + node.kind === 254 /* ImportClause */ && !!node.name || + node.kind === 255 /* NamespaceImport */ || + node.kind === 257 /* ImportSpecifier */ || + node.kind === 261 /* ExportSpecifier */ || + node.kind === 258 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 280 /* ShorthandPropertyAssignment */ || + node.kind === 279 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 279 /* PropertyAssignment */ ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -10961,24 +11591,24 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 112 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -11005,22 +11635,31 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 76 /* FirstKeyword */ <= token && token <= 151 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 121 /* FirstContextualKeyword */ <= token && token <= 151 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { return isKeyword(token) && !isContextualKeyword(token); } ts.isNonContextualKeyword = isNonContextualKeyword; + function isFutureReservedKeyword(token) { + return 112 /* FirstFutureReservedWord */ <= token && token <= 120 /* LastFutureReservedWord */; + } + ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { var token = ts.stringToToken(name); return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -11044,14 +11683,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11065,10 +11704,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11081,7 +11720,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 /* PlusToken */ || node.operator === 39 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -11101,10 +11740,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 /* ComputedPropertyName */ || name.kind === 194 /* ElementAccessExpression */)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; /** @@ -11118,12 +11760,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11139,7 +11781,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -11150,11 +11792,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 75 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -11169,7 +11811,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 75 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -11178,11 +11820,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 155 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 190 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11190,15 +11832,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 161 /* Constructor */ + || kind === 200 /* FunctionExpression */ + || kind === 243 /* FunctionDeclaration */ + || kind === 201 /* ArrowFunction */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 248 /* ModuleDeclaration */ + || kind === 288 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11217,38 +11859,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operator) { - case 41 /* AsteriskAsteriskToken */: - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 42 /* AsteriskAsteriskToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 1 /* Right */; } } @@ -11257,15 +11899,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 208 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 206 /* PrefixUnaryExpression */ || expression.kind === 207 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11275,73 +11917,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 197 /* TaggedTemplateExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 19; - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 73 /* Identifier */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 75 /* Identifier */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 210 /* TemplateExpression */: + case 199 /* ParenthesizedExpression */: + case 214 /* OmittedExpression */: return 20; default: return -1; @@ -11350,41 +11992,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: + return 4; + case 56 /* BarBarToken */: return 5; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return 6; - case 50 /* BarToken */: + case 51 /* BarToken */: return 7; - case 51 /* CaretToken */: + case 52 /* CaretToken */: return 8; - case 49 /* AmpersandToken */: + case 50 /* AmpersandToken */: return 9; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return 10; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: return 11; - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 38 /* PlusToken */: - case 39 /* MinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: return 13; - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: return 14; - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -11461,6 +12105,10 @@ var ts; } } ts.createDiagnosticCollection = createDiagnosticCollection; + var templateSubstitutionRegExp = /\$\{/g; + function escapeTemplateSubstitution(str) { + return str.replace(templateSubstitutionRegExp, "\\${"); + } // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -11468,7 +12116,8 @@ var ts; // There is no reason for this other than that JSON.stringify does not handle it either. var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - var backtickQuoteEscapedCharsRegExp = /[\\\`\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; + // Template strings should be preserved as much as possible + var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -11497,22 +12146,23 @@ var ts; } ts.escapeString = escapeString; /** - * Strip off existed single quotes or double quotes from a given string + * Strip off existed surrounding single quotes, double quotes, or backticks from a given string * * @return non-quoted string */ function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 /* singleQuote */ || + charCode === 34 /* doubleQuote */ || + charCode === 96 /* backtick */; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0 /* nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); @@ -11563,6 +12213,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -11574,7 +12225,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -11584,17 +12235,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -11608,6 +12271,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -11627,6 +12291,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -11641,12 +12307,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -11654,7 +12320,7 @@ var ts; pendingTrailingSemicolon = false; } } - return __assign({}, writer, { writeTrailingSemicolon: function () { + return __assign(__assign({}, writer), { writeTrailingSemicolon: function () { pendingTrailingSemicolon = true; }, writeLiteral: function (s) { @@ -11710,7 +12376,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -11829,6 +12495,7 @@ var ts; return accessor.parameters[hasThis ? 1 : 0]; } } + ts.getSetAccessorValueParameter = getSetAccessorValueParameter; /** Get the type annotation for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { var parameter = getSetAccessorValueParameter(accessor); @@ -11850,11 +12517,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 75 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101 /* ThisKeyword */; + return id.originalKeywordKind === 103 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -11865,10 +12532,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 163 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11888,10 +12555,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 162 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 163 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11937,7 +12604,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 === 297 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12177,7 +12844,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 73 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 75 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -12185,29 +12852,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117 /* StaticKeyword */: return 32 /* Static */; - case 116 /* PublicKeyword */: return 4 /* Public */; - case 115 /* ProtectedKeyword */: return 16 /* Protected */; - case 114 /* PrivateKeyword */: return 8 /* Private */; - case 119 /* AbstractKeyword */: return 128 /* Abstract */; - case 86 /* ExportKeyword */: return 1 /* Export */; - case 126 /* DeclareKeyword */: return 2 /* Ambient */; - case 78 /* ConstKeyword */: return 2048 /* Const */; - case 81 /* DefaultKeyword */: return 512 /* Default */; - case 122 /* AsyncKeyword */: return 256 /* Async */; - case 134 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 119 /* StaticKeyword */: return 32 /* Static */; + case 118 /* PublicKeyword */: return 4 /* Public */; + case 117 /* ProtectedKeyword */: return 16 /* Protected */; + case 116 /* PrivateKeyword */: return 8 /* Private */; + case 121 /* AbstractKeyword */: return 128 /* Abstract */; + case 88 /* ExportKeyword */: return 1 /* Export */; + case 129 /* DeclareKeyword */: return 2 /* Ambient */; + case 80 /* ConstKeyword */: return 2048 /* Const */; + case 83 /* DefaultKeyword */: return 512 /* Default */; + case 125 /* AsyncKeyword */: return 256 /* Async */; + case 137 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 /* BarBarToken */ - || token === 54 /* AmpersandAmpersandToken */ - || token === 52 /* ExclamationToken */; + return token === 56 /* BarBarToken */ + || token === 55 /* AmpersandAmpersandToken */ + || token === 53 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 /* FirstAssignment */ && token <= 72 /* LastAssignment */; + return token >= 62 /* FirstAssignment */ && token <= 74 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -12220,14 +12887,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 /* EqualsToken */ + ? node.operatorToken.kind === 62 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -12235,8 +12902,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 192 /* ObjectLiteralExpression */ + || kind === 191 /* ArrayLiteralExpression */; } return false; } @@ -12246,9 +12913,15 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function isDottedName(node) { + return node.kind === 75 /* Identifier */ || node.kind === 103 /* ThisKeyword */ || + node.kind === 193 /* PropertyAccessExpression */ && isDottedName(node.expression) || + node.kind === 199 /* ParenthesizedExpression */ && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -12264,21 +12937,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 192 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 191 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12576,8 +13249,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12654,35 +13327,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 208 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 279 /* 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 277 /* ShorthandPropertyAssignment */: + case 280 /* 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 188 /* ArrayLiteralExpression */: + case 191 /* 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 === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -12728,8 +13401,8 @@ var ts; /** * Mutates the map with newMap such that keys in map will be same as newMap. */ - function mutateMap(map, newMap, options) { - var createNewValue = options.createNewValue, onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; + function mutateMapSkippingNewValues(map, newMap, options) { + var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue; // Needs update map.forEach(function (existingValue, key) { var valueInNewMap = newMap.get(key); @@ -12743,6 +13416,15 @@ var ts; onExistingValue(existingValue, valueInNewMap, key); } }); + } + ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues; + /** + * Mutates the map with newMap such that keys in map will be same as newMap. + */ + function mutateMap(map, newMap, options) { + // Needs update + mutateMapSkippingNewValues(map, newMap, options); + var createNewValue = options.createNewValue; // Add new values that are not already present newMap.forEach(function (valueInNewMap, key) { if (!map.has(key)) { @@ -12752,7 +13434,6 @@ var ts; }); } ts.mutateMap = mutateMap; - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ function forEachAncestorDirectory(directory, callback) { while (true) { var result = callback(directory); @@ -12837,32 +13518,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) - || kind === 121 /* AnyKeyword */ - || kind === 144 /* UnknownKeyword */ - || kind === 136 /* NumberKeyword */ - || kind === 147 /* BigIntKeyword */ - || kind === 137 /* ObjectKeyword */ - || kind === 124 /* BooleanKeyword */ - || kind === 139 /* StringKeyword */ - || kind === 140 /* SymbolKeyword */ - || kind === 101 /* ThisKeyword */ - || kind === 107 /* VoidKeyword */ - || kind === 142 /* UndefinedKeyword */ - || kind === 97 /* NullKeyword */ - || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + return (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) + || kind === 124 /* AnyKeyword */ + || kind === 147 /* UnknownKeyword */ + || kind === 139 /* NumberKeyword */ + || kind === 150 /* BigIntKeyword */ + || kind === 140 /* ObjectKeyword */ + || kind === 127 /* BooleanKeyword */ + || kind === 142 /* StringKeyword */ + || kind === 143 /* SymbolKeyword */ + || kind === 103 /* ThisKeyword */ + || kind === 109 /* VoidKeyword */ + || kind === 145 /* UndefinedKeyword */ + || kind === 99 /* NullKeyword */ + || kind === 136 /* NeverKeyword */ + || kind === 215 /* ExpressionWithTypeArguments */ + || kind === 293 /* JSDocAllType */ + || kind === 294 /* JSDocUnknownType */ + || kind === 295 /* JSDocNullableType */ + || kind === 296 /* JSDocNonNullableType */ + || kind === 297 /* JSDocOptionalType */ + || kind === 298 /* JSDocFunctionType */ + || kind === 299 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */ || node.kind === 194 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -12875,6 +13556,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -12982,7 +13667,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13099,17 +13784,17 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 154 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245 /* InterfaceDeclaration */) { return current; } } } } ts.getTypeParameterOwner = getTypeParameterOwner; - function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 158 /* Constructor */; + function isParameterPropertyDeclaration(node, parent) { + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 161 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13139,14 +13824,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 241 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 242 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 224 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13210,7 +13895,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13292,27 +13978,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: var expr = hostNode.expression; + if (expr.kind === 208 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + expr = expr.left; + } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13324,6 +14013,17 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + /** @internal */ + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -13336,39 +14036,46 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return declaration; - case 312 /* JSDocPropertyTag */: - case 306 /* JSDocParameterTag */: { + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 152 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: case 4 /* ThisProperty */: case 5 /* Property */: case 3 /* PrototypeProperty */: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 309 /* JSDocEnumTag */: + return nameForNamelessJSDocTypedef(declaration); + case 258 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194 /* ElementAccessExpression */: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -13391,8 +14098,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -13570,7 +14277,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 297 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 301 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13590,10 +14297,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13638,198 +14344,216 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73 /* Identifier */; + return node.kind === 75 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 152 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 153 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 154 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 155 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 157 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 158 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 159 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 161 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 164 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 165 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 166 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 163 /* SetAccessor */ || node.kind === 162 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 167 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 168 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 169 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 170 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 171 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 172 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 173 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 174 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 177 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 178 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 179 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 180 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 181 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 182 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 183 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 184 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 185 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 186 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 187 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 188 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 189 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 190 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 191 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 194 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 195 /* CallExpression */; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + return isPropertyAccessChain(node) + || isElementAccessChain(node) + || isCallChain(node); + } + ts.isOptionalChain = isOptionalChain; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 196 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 197 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 198 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -13838,376 +14562,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 199 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 315 /* PartiallyEmittedExpression */) { + while (node.kind === 319 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 200 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 201 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 202 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 203 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 204 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 205 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 206 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 207 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 208 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 209 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 210 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 211 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 212 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 213 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 214 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 216 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 217 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 218 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 220 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 221 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 222 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 224 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 223 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 225 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 226 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 227 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 228 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 229 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 230 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 231 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 232 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 233 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 233 /* BreakStatement */ || node.kind === 232 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 234 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 235 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 236 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 237 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 238 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 239 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 240 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 241 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 242 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 243 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 244 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 245 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 246 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 247 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 248 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 249 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 250 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 251 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 252 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 253 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 254 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 255 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 256 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 257 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 258 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 259 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 260 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 261 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 262 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 264 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 265 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 266 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 267 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 268 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 269 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 270 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 271 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 272 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 273 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 274 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 275 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 276 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 277 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 278 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 279 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 280 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 281 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 288 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 289 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 290 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 284 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return true; default: return false; @@ -14216,105 +14940,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 283 /* UnparsedPrologue */ || + node.kind === 287 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 292 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 293 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 294 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 295 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 296 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 297 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 298 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 299 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 297 /* JSDocComment */; + return node.kind === 301 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 302 /* JSDocAuthorTag */; + return node.kind === 306 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 301 /* JSDocAugmentsTag */; + return node.kind === 305 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 303 /* JSDocClassTag */; + return node.kind === 307 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 305 /* JSDocEnumTag */; + return node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 308 /* JSDocThisTag */; + return node.kind === 312 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 306 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 307 /* JSDocReturnTag */; + return node.kind === 311 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 309 /* JSDocTypeTag */; + return node.kind === 313 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 310 /* JSDocTemplateTag */; + return node.kind === 314 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 311 /* JSDocTypedefTag */; + return node.kind === 315 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 312 /* JSDocPropertyTag */; + return node.kind === 316 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 312 /* JSDocPropertyTag */ || node.kind === 306 /* JSDocParameterTag */; + return node.kind === 316 /* JSDocPropertyTag */ || node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 298 /* JSDocTypeLiteral */; + return node.kind === 302 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 304 /* JSDocCallbackTag */; + return node.kind === 308 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 299 /* JSDocSignature */; + return node.kind === 303 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14325,7 +15049,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 313 /* SyntaxList */; + return n.kind === 317 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14335,7 +15059,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 152 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14344,7 +15068,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 <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 151 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14397,17 +15121,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 81 /* DefaultKeyword */: - case 86 /* ExportKeyword */: - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 117 /* StaticKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 83 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 119 /* StaticKeyword */: return true; } return false; @@ -14420,7 +15144,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 119 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -14429,23 +15153,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ + return kind === 75 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 153 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + return kind === 75 /* Identifier */ + || kind === 188 /* ObjectBindingPattern */ + || kind === 189 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14460,13 +15184,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: return false; @@ -14475,14 +15199,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 170 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14497,29 +15221,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 161 /* Constructor */ + || kind === 158 /* PropertyDeclaration */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 166 /* IndexSignature */ + || kind === 221 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; default: return false; @@ -14529,11 +15253,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 165 /* ConstructSignature */ + || kind === 164 /* CallSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */ + || kind === 166 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14542,12 +15266,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 279 /* PropertyAssignment */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 281 /* SpreadAssignment */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14562,8 +15286,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return true; } return false; @@ -14574,8 +15298,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 189 /* ArrayBindingPattern */ + || kind === 188 /* ObjectBindingPattern */; } return false; } @@ -14583,15 +15307,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 191 /* ArrayLiteralExpression */ + || kind === 192 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 190 /* BindingElement */ + || kind === 214 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14600,9 +15324,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: return true; } return false; @@ -14623,8 +15347,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return true; } return false; @@ -14636,8 +15360,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return true; } return false; @@ -14646,26 +15370,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */ + || kind === 187 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 156 /* Decorator */: return true; default: return false; @@ -14673,12 +15397,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 195 /* CallExpression */ || node.kind === 196 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 210 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14689,34 +15413,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 73 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 197 /* TaggedTemplateExpression */: + case 191 /* ArrayLiteralExpression */: + case 199 /* ParenthesizedExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 75 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 103 /* TrueKeyword */: - case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: - case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 210 /* TemplateExpression */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 105 /* TrueKeyword */: + case 101 /* SuperKeyword */: + case 217 /* NonNullExpression */: + case 218 /* MetaProperty */: + case 95 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -14729,13 +15453,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 198 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14744,11 +15468,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 44 /* PlusPlusToken */ || - expr.operator === 45 /* MinusMinusToken */; + case 206 /* PrefixUnaryExpression */: + return expr.operator === 45 /* PlusPlusToken */ || + expr.operator === 46 /* MinusMinusToken */; default: return false; } @@ -14765,15 +15489,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 316 /* CommaListExpression */: - case 315 /* PartiallyEmittedExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: + case 201 /* ArrowFunction */: + case 208 /* BinaryExpression */: + case 212 /* SpreadElement */: + case 216 /* AsExpression */: + case 214 /* OmittedExpression */: + case 320 /* CommaListExpression */: + case 319 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14781,21 +15505,26 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 198 /* TypeAssertionExpression */ + || kind === 216 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 315 /* PartiallyEmittedExpression */; + return node.kind === 319 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 314 /* NotEmittedStatement */; + return node.kind === 318 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ + function isSyntheticReference(node) { + return node.kind === 323 /* SyntheticReferenceExpression */; + } + ts.isSyntheticReference = isSyntheticReference; + /* @internal */ function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -14803,21 +15532,42 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; /* @internal */ + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + /* @internal */ + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + /* @internal */ + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + /* @internal */ + function isExternalModuleIndicator(result) { + // Exported top-level member indicates moduleness + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; + /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 230 /* ForInStatement */ || node.kind === 231 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14841,113 +15591,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ - || kind === 73 /* Identifier */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */ + || kind === 75 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + return kind === 75 /* Identifier */ + || kind === 248 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 256 /* NamedImports */ + || kind === 255 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 248 /* ModuleDeclaration */ || node.kind === 247 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 311 /* JSDocTypedefTag */ - || kind === 304 /* JSDocCallbackTag */ - || kind === 312 /* JSDocPropertyTag */; + return kind === 201 /* ArrowFunction */ + || kind === 190 /* BindingElement */ + || kind === 244 /* ClassDeclaration */ + || kind === 213 /* ClassExpression */ + || kind === 161 /* Constructor */ + || kind === 247 /* EnumDeclaration */ + || kind === 282 /* EnumMember */ + || kind === 261 /* ExportSpecifier */ + || kind === 243 /* FunctionDeclaration */ + || kind === 200 /* FunctionExpression */ + || kind === 162 /* GetAccessor */ + || kind === 254 /* ImportClause */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 257 /* ImportSpecifier */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 271 /* JsxAttribute */ + || kind === 160 /* MethodDeclaration */ + || kind === 159 /* MethodSignature */ + || kind === 248 /* ModuleDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 255 /* NamespaceImport */ + || kind === 155 /* Parameter */ + || kind === 279 /* PropertyAssignment */ + || kind === 158 /* PropertyDeclaration */ + || kind === 157 /* PropertySignature */ + || kind === 163 /* SetAccessor */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 154 /* TypeParameter */ + || kind === 241 /* VariableDeclaration */ + || kind === 315 /* JSDocTypedefTag */ + || kind === 308 /* JSDocCallbackTag */ + || kind === 316 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 243 /* FunctionDeclaration */ + || kind === 262 /* MissingDeclaration */ + || kind === 244 /* ClassDeclaration */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 247 /* EnumDeclaration */ + || kind === 248 /* ModuleDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 258 /* ExportAssignment */ + || kind === 251 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 314 /* NotEmittedStatement */ - || kind === 318 /* EndOfDeclarationMarker */ - || kind === 317 /* MergeDeclarationMarker */; + return kind === 233 /* BreakStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 227 /* DoStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 223 /* EmptyStatement */ + || kind === 230 /* ForInStatement */ + || kind === 231 /* ForOfStatement */ + || kind === 229 /* ForStatement */ + || kind === 226 /* IfStatement */ + || kind === 237 /* LabeledStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 236 /* SwitchStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 239 /* TryStatement */ + || kind === 224 /* VariableStatement */ + || kind === 228 /* WhileStatement */ + || kind === 235 /* WithStatement */ + || kind === 318 /* NotEmittedStatement */ + || kind === 322 /* EndOfDeclarationMarker */ + || kind === 321 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 310 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 154 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 314 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14974,10 +15724,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 222 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 239 /* TryStatement */ || node.parent.kind === 278 /* CatchClause */) { return false; } } @@ -14987,83 +15737,88 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 263 /* ExternalModuleReference */ + || kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 /* ThisKeyword */ - || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + return kind === 103 /* ThisKeyword */ + || kind === 75 /* Identifier */ + || kind === 193 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 264 /* JsxElement */ + || kind === 274 /* JsxExpression */ + || kind === 265 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 268 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 271 /* JsxAttribute */ + || kind === 273 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 274 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 266 /* JsxOpeningElement */ + || kind === 265 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 275 /* CaseClause */ + || kind === 276 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 312 /* LastJSDocNode */; + return node.kind >= 292 /* FirstJSDocNode */ && node.kind <= 316 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 297 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 /* 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 >= 300 /* FirstJSDocTagNode */ && node.kind <= 312 /* LastJSDocTagNode */; + return node.kind >= 304 /* FirstJSDocTagNode */ && node.kind <= 316 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; + /* @internal */ + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; + } + ts.isOptionalChainRoot = isOptionalChainRoot; /** True if has jsdoc nodes attached to it. */ /* @internal */ // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times @@ -15091,12 +15846,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 271 /* JsxAttribute */ || node.kind === 273 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 168 /* TypeReference */ || node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15132,7 +15887,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 256 /* NamedImports */ || node.kind === 260 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15150,7 +15905,7 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature() { } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15167,6 +15922,7 @@ var ts; this.text = text; this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } + // eslint-disable-next-line prefer-const ts.objectAllocator = { getNodeConstructor: function () { return Node; }, getTokenConstructor: function () { return Node; }, @@ -15613,7 +16369,7 @@ var ts; var rest = path.substring(rootLength).split(ts.directorySeparator); if (rest.length && !ts.lastOrUndefined(rest)) rest.pop(); - return [root].concat(rest); + return __spreadArrays([root], rest); } /** * Parse a path into an array containing a root component (at index 0) and zero or more path @@ -15691,6 +16447,37 @@ var ts; return ""; return pathComponents.slice(1).join(ts.directorySeparator); } + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); + } + return result; + } + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); + } + return [getPathFromPathComponents(aParts), getPathFromPathComponents(bParts)]; + } + // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. + // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); + } })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -15713,7 +16500,7 @@ var ts; for (; start < fromComponents.length; start++) { relative.push(".."); } - return [""].concat(relative, components); + return __spreadArrays([""], relative, components); } ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; function getRelativePathFromFile(from, to, getCanonicalFileName) { @@ -15794,7 +16581,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } - var combined = ts.some(paths) ? combinePaths.apply(void 0, [path].concat(paths)) : ts.normalizeSlashes(path); + var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -16233,14 +17020,14 @@ var ts; ts.supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; ts.supportedJSAndJsonExtensions = [".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; - var allSupportedExtensions = ts.supportedTSExtensions.concat(ts.supportedJSExtensions); - var allSupportedExtensionsWithJson = ts.supportedTSExtensions.concat(ts.supportedJSExtensions, [".json" /* Json */]); + var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions); + var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json" /* Json */]); function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && options.allowJs; if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; } - var extensions = (needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions).concat(ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); + var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; })); return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } ts.getSupportedExtensions = getSupportedExtensions; @@ -16254,7 +17041,7 @@ var ts; if (supportedExtensions === ts.supportedTSExtensions) { return ts.supportedTSExtensionsWithJson; } - return supportedExtensions.concat([".json" /* Json */]); + return __spreadArrays(supportedExtensions, [".json" /* Json */]); } ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { @@ -16566,14 +17353,17 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { + function skipTypeChecking(sourceFile, options, host) { // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a // '/// ' directive. - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16677,17 +17467,15 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 288 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73 /* Identifier */) { + else if (kind === 75 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -16736,19 +17524,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 <= 148 /* LastToken */) { + if (!node || node.kind <= 151 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16756,9 +17544,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -16766,7 +17554,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -16774,51 +17562,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 157 /* 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 276 /* PropertyAssignment */: + case 279 /* 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 238 /* VariableDeclaration */: + case 241 /* 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 187 /* BindingElement */: + case 190 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -16830,345 +17618,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || + case 167 /* TypePredicate */: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 174 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 180 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 187 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 181 /* ParenthesizedType */: + case 183 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 185 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 156 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* 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 242 /* InterfaceDeclaration */: + case 245 /* 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 243 /* TypeAliasDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 292 /* JSDocTypeExpression */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 297 /* JSDocOptionalType */: + case 299 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 297 /* JSDocComment */: + case 301 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 302 /* JSDocAuthorTag */: + case 306 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 292 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 304 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 299 /* JSDocSignature */: + case 303 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 298 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 300 /* JSDocTag */: - case 303 /* JSDocClassTag */: + case 304 /* JSDocTag */: + case 307 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17177,12 +17970,14 @@ var ts; if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); var result; + ts.perfLogger.logStartParseSourceFile(fileName); if (languageVersion === 100 /* JSON */) { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */); } else { result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); } + ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); return result; @@ -17220,7 +18015,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -17249,14 +18044,12 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; + var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17266,6 +18059,7 @@ var ts; var identifiers; var identifierCount; var parsingContext; + var notParenthesizedArrow; // Flags that dictate what parsing context we're in. For example: // Whether or not we are in strict parsing mode. All that changes in strict parsing mode is // that some tokens that would be considered identifiers may be considered keywords. @@ -17386,18 +18180,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(225 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 39 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -17406,7 +18200,7 @@ var ts; break; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -17422,6 +18216,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17447,10 +18244,10 @@ var ts; switch (scriptKind) { case 1 /* JS */: case 2 /* JSX */: - contextFlags = 65536 /* JavaScriptFile */; + contextFlags = 131072 /* JavaScriptFile */; break; case 6 /* JSON */: - contextFlags = 65536 /* JavaScriptFile */ | 16777216 /* JsonFile */; + contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */; break; default: contextFlags = 0 /* None */; @@ -17473,11 +18270,12 @@ var ts; identifiers = undefined; syntaxCursor = undefined; sourceText = undefined; + notParenthesizedArrow = undefined; } function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304 /* Ambient */; + contextFlags |= 8388608 /* Ambient */; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -17542,7 +18340,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(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(288 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17563,16 +18361,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048 /* DisallowInContext */); + setContextFlag(val, 4096 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 4096 /* YieldContext */); + setContextFlag(val, 8192 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 8192 /* DecoratorContext */); + setContextFlag(val, 16384 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 16384 /* AwaitContext */); + setContextFlag(val, 32768 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -17613,40 +18411,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(2048 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(4096 /* YieldContext */, func); + return doInsideOfContext(8192 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384 /* AwaitContext */, func); + return doInsideOfContext(32768 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); + return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096 /* YieldContext */); + return inContext(8192 /* YieldContext */); } function inDisallowInContext() { - return inContext(2048 /* DisallowInContext */); + return inContext(4096 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(8192 /* DecoratorContext */); + return inContext(16384 /* DecoratorContext */); } function inAwaitContext() { - return inContext(16384 /* AwaitContext */); + return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -17682,9 +18480,17 @@ var ts; function token() { return currentToken; } - function nextToken() { + function nextTokenWithoutCheck() { return currentToken = scanner.scan(); } + function nextToken() { + // if the keyword had an escape + if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) { + // issue a parse error for the escape + parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters); + } + return nextTokenWithoutCheck(); + } function nextTokenJSDoc() { return currentToken = scanner.scanJsDocToken(); } @@ -17753,20 +18559,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 73 /* Identifier */) { + if (token() === 75 /* 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() === 118 /* YieldKeyword */ && inYieldContext()) { + if (token() === 120 /* 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() === 123 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 126 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 109 /* LastReservedWord */; + return token() > 111 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -17854,7 +18660,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 73 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 75 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -17884,7 +18690,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768 /* ThisNodeHasError */; + node.flags |= 65536 /* ThisNodeHasError */; } return node; } @@ -17896,7 +18702,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73 /* Identifier */) { + if (kind === 75 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -17917,18 +18723,18 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73 /* Identifier */); + var node = createNode(75 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 73 /* Identifier */) { + if (token() !== 75 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); - nextToken(); + nextTokenWithoutCheck(); return finishNode(node); } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(73 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -17959,7 +18765,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(153 /* 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 @@ -17980,20 +18786,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 85 /* EnumKeyword */; - case 86 /* ExportKeyword */: + return nextToken() === 87 /* EnumKeyword */; + case 88 /* ExportKeyword */: nextToken(); - if (token() === 81 /* DefaultKeyword */) { + if (token() === 83 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 /* AsteriskToken */ && token() !== 120 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); - case 81 /* DefaultKeyword */: + return token() !== 41 /* AsteriskToken */ && token() !== 122 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 83 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 117 /* StaticKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + case 119 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -18006,16 +18812,16 @@ var ts; function canFollowModifier() { return token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */ - || token() === 40 /* AsteriskToken */ + || token() === 41 /* AsteriskToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 /* ClassKeyword */ || token() === 91 /* FunctionKeyword */ || - token() === 111 /* InterfaceKeyword */ || - (token() === 119 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 /* ClassKeyword */ || token() === 93 /* FunctionKeyword */ || + token() === 113 /* InterfaceKeyword */ || + (token() === 121 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -18035,7 +18841,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -18051,7 +18857,7 @@ var ts; case 12 /* ObjectLiteralMembers */: switch (token()) { case 22 /* OpenBracketToken */: - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; @@ -18121,7 +18927,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 87 /* ExtendsKeyword */ || next === 110 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 89 /* ExtendsKeyword */ || next === 112 /* ImplementsKeyword */; } return true; } @@ -18138,8 +18944,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 /* ImplementsKeyword */ || - token() === 87 /* ExtendsKeyword */) { + if (token() === 112 /* ImplementsKeyword */ || + token() === 89 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -18169,14 +18975,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -18195,9 +19001,9 @@ var ts; case 22 /* HeritageClauses */: return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; + return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -18217,7 +19023,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() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -18292,7 +19098,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 12679168 /* ContextFlags */; + var nodeContextFlags = node.flags & 25358336 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -18393,20 +19199,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 161 /* Constructor */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 221 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 160 /* 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 === 73 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 125 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 75 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 128 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -18415,8 +19221,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: return true; } } @@ -18425,58 +19231,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 224 /* VariableStatement */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 225 /* ExpressionStatement */: + case 238 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 236 /* SwitchStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 223 /* EmptyStatement */: + case 239 /* TryStatement */: + case 237 /* LabeledStatement */: + case 227 /* DoStatement */: + case 240 /* DebuggerStatement */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 157 /* PropertySignature */: + case 164 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 241 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18497,7 +19303,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 155 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18564,7 +19370,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18602,6 +19408,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18622,7 +19431,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24 /* DotToken */)) { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -18633,7 +19442,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(152 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18664,13 +19473,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(210 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18682,7 +19491,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(220 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -18711,6 +19520,16 @@ var ts; function parseLiteralLikeNode(kind) { var node = createNode(kind); node.text = scanner.getTokenValue(); + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var tokenText = scanner.getTokenText(); + node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); + break; + } if (scanner.hasExtendedUnicodeEscape()) { node.hasExtendedUnicodeEscape = true; } @@ -18732,24 +19551,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 169 /* FunctionType */: + case 170 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -18757,20 +19576,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(167 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(182 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(293 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(297 /* JSDocOptionalType */, result); } else { nextToken(); @@ -18778,7 +19597,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(296 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -18799,63 +19618,80 @@ var ts; if (token() === 27 /* CommaToken */ || token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || - token() === 30 /* GreaterThanToken */ || - token() === 60 /* EqualsToken */ || - token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + token() === 31 /* GreaterThanToken */ || + token() === 62 /* EqualsToken */ || + token() === 51 /* BarToken */) { + var result = createNode(294 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(295 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(298 /* JSDocFunctionType */); nextToken(); - fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(58 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { + var parameter = createNode(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */ || token() === 98 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); + var moduleSpecifier = parseOptionalToken(134 /* ModuleKeyword */); + if (moduleSpecifier) { + var moduleTag = createNode(300 /* JSDocNamepathType */, moduleSpecifier.pos); + terminate: while (true) { + switch (token()) { + case 19 /* CloseBraceToken */: + case 1 /* EndOfFileToken */: + case 27 /* CommaToken */: + case 5 /* WhitespaceTrivia */: + break terminate; + default: + nextTokenJSDoc(); + } + } + scanner.setInJSDocType(false); + return finishNode(moduleTag); + } var dotdotdot = parseOptionalToken(25 /* DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(299 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + if (token() === 62 /* EqualsToken */) { + return createPostfixType(297 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); - parseExpected(105 /* TypeOfKeyword */); + var node = createNode(171 /* TypeQuery */); + parseExpected(107 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(87 /* ExtendsKeyword */)) { + if (parseOptional(89 /* 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 @@ -18874,18 +19710,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60 /* EqualsToken */)) { + if (parseOptional(62 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (token() === 29 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(57 /* ColonToken */)) { + if (parseOptional(58 /* ColonToken */)) { return parseType(); } return undefined; @@ -18894,12 +19730,12 @@ var ts; return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 /* AtToken */ || + token() === 59 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */) { + var node = createNodeWithJSDoc(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); @@ -18921,7 +19757,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.questionToken = parseOptionalToken(57 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -18943,16 +19779,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(57 /* ColonToken */)) { + else if (parseOptional(58 /* ColonToken */)) { return true; } - else if (isType && token() === 37 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); nextToken(); return true; } @@ -18999,10 +19835,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { - parseExpected(96 /* NewKeyword */); + if (kind === 165 /* ConstructSignature */) { + parseExpected(98 /* NewKeyword */); } - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -19046,21 +19882,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* 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() !== 56 /* QuestionToken */) { + if (token() !== 57 /* 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() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 166 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19068,17 +19904,17 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + node.kind = 159 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 157 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* 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. @@ -19090,7 +19926,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return true; } var idToken = false; @@ -19112,20 +19948,20 @@ var ts; // the start of a member declaration if (idToken) { return token() === 20 /* OpenParenToken */ || - token() === 28 /* LessThanToken */ || - token() === 56 /* QuestionToken */ || - token() === 57 /* ColonToken */ || + token() === 29 /* LessThanToken */ || + token() === 57 /* QuestionToken */ || + token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + return parseSignatureMember(164 /* CallSignature */); } - if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + if (token() === 98 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19136,7 +19972,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; } function nextTokenIsDot() { return nextToken() === 24 /* DotToken */; @@ -19144,14 +19980,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20 /* OpenParenToken */: - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(172 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19168,37 +20004,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { - return nextToken() === 134 /* ReadonlyKeyword */; + if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + return nextToken() === 137 /* ReadonlyKeyword */; } - if (token() === 134 /* ReadonlyKeyword */) { + if (token() === 137 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 96 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(94 /* InKeyword */); + parseExpected(96 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(185 /* MappedType */); parseExpected(18 /* OpenBraceToken */); - if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 137 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { - parseExpectedToken(134 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { + parseExpectedToken(137 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); parseExpected(23 /* CloseBracketToken */); - if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56 /* QuestionToken */) { - parseExpectedToken(56 /* QuestionToken */); + if (node.questionToken.kind !== 57 /* QuestionToken */) { + parseExpectedToken(57 /* QuestionToken */); } } node.type = parseTypeAnnotation(); @@ -19209,23 +20045,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(176 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 4194304 /* JSDoc */) && type.kind === 295 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 175 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(174 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(181 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19233,9 +20069,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(98 /* NewKeyword */) ? 170 /* ConstructorType */ : 169 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(38 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -19243,14 +20079,14 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(186 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 39 /* MinusToken */; + unaryMinusExpression = createNode(206 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 40 /* MinusToken */; nextToken(); } - var expression = token() === 103 /* TrueKeyword */ || token() === 88 /* FalseKeyword */ + var expression = token() === 105 /* TrueKeyword */ || token() === 90 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -19263,23 +20099,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93 /* ImportKeyword */; + return token() === 95 /* ImportKeyword */; } function parseImportType() { - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); - if (parseOptional(105 /* TypeOfKeyword */)) { + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; + var node = createNode(187 /* ImportType */); + if (parseOptional(107 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); node.argument = parseType(); parseExpected(21 /* CloseParenToken */); if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } @@ -19289,50 +20125,54 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 140 /* SymbolKeyword */: - case 124 /* BooleanKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 143 /* SymbolKeyword */: + case 127 /* BooleanKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 63 /* AsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 56 /* QuestionToken */: + case 60 /* QuestionQuestionToken */: + // If there is '??', consider that is prefix '?' in JSDoc type. + scanner.reScanQuestionToken(); + // falls through + case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseLiteralTypeNode(); - case 39 /* MinusToken */: + case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 107 /* VoidKeyword */: - case 97 /* NullKeyword */: + case 109 /* VoidKeyword */: + case 99 /* NullKeyword */: return parseTokenNode(); - case 101 /* ThisKeyword */: { + case 103 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -19340,51 +20180,54 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportType(); + case 123 /* AssertsKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 134 /* ReadonlyKeyword */: - case 140 /* SymbolKeyword */: - case 143 /* UniqueKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 105 /* TypeOfKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 137 /* ReadonlyKeyword */: + case 143 /* SymbolKeyword */: + case 146 /* UniqueKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 107 /* TypeOfKeyword */: + case 136 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: - case 28 /* LessThanToken */: - case 50 /* BarToken */: - case 49 /* AmpersandToken */: - case 96 /* NewKeyword */: + case 29 /* LessThanToken */: + case 51 /* BarToken */: + case 50 /* AmpersandToken */: + case 98 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 137 /* ObjectKeyword */: - case 40 /* AsteriskToken */: - case 56 /* QuestionToken */: - case 52 /* ExclamationToken */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 140 /* ObjectKeyword */: + case 41 /* AsteriskToken */: + case 57 /* QuestionToken */: + case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 128 /* InferKeyword */: - case 93 /* ImportKeyword */: + case 131 /* InferKeyword */: + case 95 /* ImportKeyword */: + case 123 /* AssertsKeyword */: return true; - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return !inStartOfParameter; - case 39 /* MinusToken */: + case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -19402,27 +20245,27 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + case 53 /* ExclamationToken */: + type = createPostfixType(296 /* JSDocNonNullableType */, type); break; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type - if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { + if (!(contextFlags & 4194304 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(295 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(184 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(173 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19441,16 +20284,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(183 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); - parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var node = createNode(180 /* InferType */); + parseExpected(131 /* InferKeyword */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19458,11 +20301,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130 /* KeyOfKeyword */: - case 143 /* UniqueKeyword */: - case 134 /* ReadonlyKeyword */: + case 133 /* KeyOfKeyword */: + case 146 /* UniqueKeyword */: + case 137 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 128 /* InferKeyword */: + case 131 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -19483,13 +20326,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(178 /* IntersectionType */, parseTypeOperatorOrHigher, 50 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(177 /* UnionType */, parseIntersectionTypeOrHigher, 51 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { return true; } return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -19499,7 +20342,7 @@ var ts; // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 101 /* ThisKeyword */) { + if (isIdentifier() || token() === 103 /* ThisKeyword */) { nextToken(); return true; } @@ -19521,8 +20364,8 @@ 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() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 56 /* QuestionToken */ || token() === 60 /* EqualsToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 57 /* QuestionToken */ || token() === 62 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -19531,7 +20374,7 @@ var ts; } if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -19543,7 +20386,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(167 /* TypePredicate */, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19554,45 +20398,52 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167 /* TypePredicate */); + node.assertsModifier = parseExpectedToken(123 /* AssertsKeyword */); + node.parameterName = token() === 103 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132 /* IsKeyword */) ? parseType() : undefined; + return finishNode(node); + } function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 98 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89 /* ExtendsKeyword */)) { + var node = createNode(179 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(56 /* QuestionToken */); + parseExpected(57 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -19601,14 +20452,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 96 /* NewKeyword */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 73 /* Identifier */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 98 /* NewKeyword */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 75 /* Identifier */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -19619,18 +20470,18 @@ var ts; return true; } switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 28 /* LessThanToken */: - case 123 /* AwaitKeyword */: - case 118 /* YieldKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 29 /* LessThanToken */: + case 126 /* AwaitKeyword */: + case 120 /* 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. @@ -19649,9 +20500,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && - token() !== 58 /* AtToken */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && + token() !== 59 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -19674,7 +20525,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -19719,7 +20570,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 === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -19735,7 +20586,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118 /* YieldKeyword */) { + if (token() === 120 /* 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()) { @@ -19764,15 +20615,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(211 /* 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() === 40 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -19783,20 +20634,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(201 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(201 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(155 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -19821,8 +20672,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(37 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -19832,10 +20683,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() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 122 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 125 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* 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. @@ -19845,12 +20696,12 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { return 0 /* False */; } } @@ -19864,8 +20715,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 37 /* EqualsGreaterThanToken */: - case 57 /* ColonToken */: + case 38 /* EqualsGreaterThanToken */: + case 58 /* ColonToken */: case 18 /* OpenBraceToken */: return 1 /* True */; default: @@ -19889,30 +20740,30 @@ var ts; // 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 !== 122 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 /* 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 !== 101 /* ThisKeyword */) { + if (!isIdentifier() && second !== 103 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 57 /* ColonToken */: + case 58 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 60 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -19921,7 +20772,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 28 /* LessThanToken */); + ts.Debug.assert(first === 29 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -19931,11 +20782,11 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87 /* ExtendsKeyword */) { + if (third === 89 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 60 /* EqualsToken */: - case 30 /* GreaterThanToken */: + case 62 /* EqualsToken */: + case 31 /* GreaterThanToken */: return false; default: return true; @@ -19956,11 +20807,19 @@ var ts; } } function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + var tokenPos = scanner.getTokenPos(); + if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) { + return undefined; + } + var result = parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + if (!result) { + (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true); + } + return result; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -19973,23 +20832,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() === 122 /* AsyncKeyword */) { + if (token() === 125 /* 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() === 37 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(201 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -19999,7 +20858,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -20012,7 +20871,7 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -20023,8 +20882,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -20049,20 +20908,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(56 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* 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(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(209 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57 /* ColonToken */); + node.colonToken = parseExpectedToken(58 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + : createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -20070,7 +20929,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 96 /* InKeyword */ || t === 151 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20099,16 +20958,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() === 41 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 /* InKeyword */ && inDisallowInContext()) { + if (token() === 96 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -20129,51 +20988,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94 /* InKeyword */) { + if (inDisallowInContext() && token() === 96 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(208 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(216 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(202 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(203 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(204 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123 /* AwaitKeyword */) { + if (token() === 126 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -20183,7 +21042,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(205 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20207,7 +21066,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 /* AsteriskAsteriskToken */ ? + return token() === 42 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -20224,10 +21083,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41 /* AsteriskAsteriskToken */) { + if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 198 /* 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 { @@ -20252,23 +21111,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 82 /* DeleteKeyword */: + case 84 /* DeleteKeyword */: return parseDeleteExpression(); - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return parseVoidExpression(); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 123 /* AwaitKeyword */: + case 126 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -20291,16 +21150,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 123 /* AwaitKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 126 /* AwaitKeyword */: return false; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -20323,21 +21182,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20378,14 +21237,14 @@ 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() === 93 /* ImportKeyword */) { + if (token() === 95 /* ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { @@ -20393,21 +21252,22 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); - node.keywordToken = 93 /* ImportKeyword */; + var node = createNode(218 /* MetaProperty */, fullStart); + node.keywordToken = 95 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; + sourceFile.flags |= 2097152 /* PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 /* 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. + // CallExpression or OptionalExpression. As such, we need to consume the rest + // of it here to be complete. return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { @@ -20459,11 +21319,11 @@ var ts; // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -20475,7 +21335,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(193 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20484,8 +21344,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 266 /* JsxOpeningElement */) { + var node = createNode(264 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20494,15 +21354,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 269 /* JsxOpeningFragment */) { + var node = createNode(268 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 265 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20513,11 +21373,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 28 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(208 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20547,7 +21407,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29 /* LessThanSlashToken */: + case 30 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; case 11 /* JsxText */: @@ -20555,7 +21415,7 @@ var ts; return parseJsxText(); case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -20576,16 +21436,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(272 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28 /* LessThanToken */); - if (token() === 30 /* GreaterThanToken */) { + parseExpected(29 /* LessThanToken */); + if (token() === 31 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(269 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20593,23 +21453,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30 /* GreaterThanToken */) { + if (token() === 31 /* 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(263 /* JsxOpeningElement */, fullStart); + node = createNode(266 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(42 /* SlashToken */); + parseExpected(43 /* SlashToken */); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(265 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20623,10 +21483,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() === 101 /* ThisKeyword */ ? + var expression = token() === 103 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20634,7 +21494,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(274 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -20660,9 +21520,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(271 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -20675,7 +21535,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(273 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -20683,78 +21543,110 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(267 /* JsxClosingElement */); + parseExpected(30 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(270 /* JsxClosingFragment */); + parseExpected(30 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); - parseExpected(28 /* LessThanToken */); + var node = createNode(198 /* TypeAssertionExpression */); + parseExpected(29 /* LessThanToken */); node.type = parseType(); - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 /* OpenBracketToken */ + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 /* QuestionDotToken */ + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + propertyAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23 /* CloseBracketToken */); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + indexedAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24 /* DotToken */); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(217 /* 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(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - if (token() === 23 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23 /* CloseBracketToken */); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, /*typeArguments*/ undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, /*typeArguments*/ undefined); continue; } return expression; @@ -20763,48 +21655,70 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32 /* OptionalChain */) { + tagExpression.flags |= 32 /* OptionalChain */; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); + var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); // handle 'foo<()' - if (token() === 28 /* LessThanToken */ || token() === 46 /* LessThanLessThanToken */) { + if (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the // stack. var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(195 /* CallExpression */, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + // We failed to parse anything, so report a missing identifier here. + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32 /* OptionalChain */; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20 /* OpenParenToken */); @@ -20813,12 +21727,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* LessThanToken */) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(30 /* GreaterThanToken */)) { + if (!parseExpected(31 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -20835,21 +21749,23 @@ var ts; 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. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] - case 57 /* ColonToken */: // foo: + case 58 /* 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 57 /* QuestionToken */: // foo? + case 34 /* EqualsEqualsToken */: // foo == + case 36 /* EqualsEqualsEqualsToken */: // foo === + case 35 /* ExclamationEqualsToken */: // foo != + case 37 /* ExclamationEqualsEqualsToken */: // foo !== + case 55 /* AmpersandAmpersandToken */: // foo && + case 56 /* BarBarToken */: // foo || + case 60 /* QuestionQuestionToken */: // foo ?? + case 52 /* CaretToken */: // foo ^ + case 50 /* AmpersandToken */: // foo & + case 51 /* 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 @@ -20861,6 +21777,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -20873,11 +21790,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -20885,7 +21802,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 122 /* AsyncKeyword */: + case 125 /* 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. @@ -20893,14 +21810,14 @@ var ts; break; } return parseFunctionExpression(); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassExpression(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionExpression(); - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -20911,28 +21828,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(199 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(212 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(214 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(191 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -20944,25 +21861,25 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 281 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(53 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -20970,24 +21887,24 @@ 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() !== 57 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(60 /* EqualsToken */); + node.kind = 280 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(62 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276 /* PropertyAssignment */; - parseExpected(57 /* ColonToken */); + node.kind = 279 /* PropertyAssignment */; + parseExpected(58 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(192 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21006,10 +21923,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(200 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -21017,7 +21934,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -21029,26 +21946,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96 /* NewKeyword */); + parseExpected(98 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); - node_2.keywordToken = 96 /* NewKeyword */; + var node_2 = createNode(218 /* MetaProperty */, fullStart); + node_2.keywordToken = 98 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, /*optionalChain*/ undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(196 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21058,7 +21975,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(222 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21091,25 +22008,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(223 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); - parseExpected(92 /* IfKeyword */); + var node = createNode(226 /* IfStatement */); + parseExpected(94 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); - parseExpected(83 /* DoKeyword */); + var node = createNode(227 /* DoStatement */); + parseExpected(85 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(108 /* WhileKeyword */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21121,8 +22038,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); - parseExpected(108 /* WhileKeyword */); + var node = createNode(228 /* WhileStatement */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21131,12 +22048,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90 /* ForKeyword */); - var awaitToken = parseOptionalToken(123 /* AwaitKeyword */); + parseExpected(92 /* ForKeyword */); + var awaitToken = parseOptionalToken(126 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 106 /* VarKeyword */ || token() === 112 /* LetKeyword */ || token() === 78 /* ConstKeyword */) { + if (token() === 108 /* VarKeyword */ || token() === 114 /* LetKeyword */ || token() === 80 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -21144,23 +22061,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(151 /* OfKeyword */) : parseOptional(151 /* OfKeyword */)) { + var forOfStatement = createNode(231 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + else if (parseOptional(96 /* InKeyword */)) { + var forInStatement = createNode(230 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(229 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21178,7 +22095,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 233 /* BreakStatement */ ? 76 /* BreakKeyword */ : 81 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21186,8 +22103,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); - parseExpected(98 /* ReturnKeyword */); + var node = createNode(234 /* ReturnStatement */); + parseExpected(100 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -21195,39 +22112,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); - parseExpected(109 /* WithKeyword */); + var node = createNode(235 /* WithStatement */); + parseExpected(111 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); + node.statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); - parseExpected(75 /* CaseKeyword */); + var node = createNode(275 /* CaseClause */); + parseExpected(77 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); - parseExpected(81 /* DefaultKeyword */); - parseExpected(57 /* ColonToken */); + var node = createNode(276 /* DefaultClause */); + parseExpected(83 /* DefaultKeyword */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 77 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); - parseExpected(100 /* SwitchKeyword */); + var node = createNode(236 /* SwitchStatement */); + parseExpected(102 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(250 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21242,29 +22159,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); - parseExpected(102 /* ThrowKeyword */); + var node = createNode(238 /* ThrowStatement */); + parseExpected(104 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); - parseExpected(104 /* TryKeyword */); + var node = createNode(239 /* TryStatement */); + parseExpected(106 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 78 /* 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() === 89 /* FinallyKeyword */) { - parseExpected(89 /* FinallyKeyword */); + if (!node.catchClause || token() === 91 /* FinallyKeyword */) { + parseExpected(91 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); - parseExpected(76 /* CatchKeyword */); + var result = createNode(278 /* CatchClause */); + parseExpected(78 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21 /* CloseParenToken */); @@ -21277,8 +22194,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); - parseExpected(80 /* DebuggerKeyword */); + var node = createNode(240 /* DebuggerStatement */); + parseExpected(82 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -21288,13 +22205,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + if (expression.kind === 75 /* Identifier */ && parseOptional(58 /* ColonToken */)) { + node.kind = 237 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 225 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21306,11 +22223,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 79 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 93 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -21319,12 +22236,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* 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 @@ -21347,41 +22264,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146 /* GlobalKeyword */: + case 149 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 73 /* Identifier */ || token() === 86 /* ExportKeyword */; - case 93 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 75 /* Identifier */ || token() === 88 /* ExportKeyword */; + case 95 /* ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); - if (token() === 60 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || token() === 81 /* DefaultKeyword */ || - token() === 120 /* AsKeyword */) { + if (token() === 62 /* EqualsToken */ || token() === 41 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 83 /* DefaultKeyword */ || + token() === 122 /* AsKeyword */) { return true; } continue; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: nextToken(); continue; default: @@ -21394,50 +22311,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 92 /* IfKeyword */: - case 83 /* DoKeyword */: - case 108 /* WhileKeyword */: - case 90 /* ForKeyword */: - case 79 /* ContinueKeyword */: - case 74 /* BreakKeyword */: - case 98 /* ReturnKeyword */: - case 109 /* WithKeyword */: - case 100 /* SwitchKeyword */: - case 102 /* ThrowKeyword */: - case 104 /* TryKeyword */: - case 80 /* DebuggerKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 94 /* IfKeyword */: + case 85 /* DoKeyword */: + case 110 /* WhileKeyword */: + case 92 /* ForKeyword */: + case 81 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 100 /* ReturnKeyword */: + case 111 /* WithKeyword */: + case 102 /* SwitchKeyword */: + case 104 /* ThrowKeyword */: + case 106 /* TryKeyword */: + case 82 /* 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 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78 /* ConstKeyword */: - case 86 /* ExportKeyword */: + case 80 /* ConstKeyword */: + case 88 /* ExportKeyword */: return isStartOfDeclaration(); - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 111 /* InterfaceKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 141 /* TypeKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 113 /* InterfaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 144 /* TypeKeyword */: + case 149 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 119 /* StaticKeyword */: + case 137 /* 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); @@ -21460,63 +22378,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); - case 112 /* LetKeyword */: + case 108 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); + case 114 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); } break; - case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); - case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); - case 92 /* IfKeyword */: + case 93 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(243 /* FunctionDeclaration */)); + case 79 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(244 /* ClassDeclaration */)); + case 94 /* IfKeyword */: return parseIfStatement(); - case 83 /* DoKeyword */: + case 85 /* DoKeyword */: return parseDoStatement(); - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return parseWhileStatement(); - case 90 /* ForKeyword */: + case 92 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); - case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); - case 98 /* ReturnKeyword */: + case 81 /* ContinueKeyword */: + return parseBreakOrContinueStatement(232 /* ContinueStatement */); + case 76 /* BreakKeyword */: + return parseBreakOrContinueStatement(233 /* BreakStatement */); + case 100 /* ReturnKeyword */: return parseReturnStatement(); - case 109 /* WithKeyword */: + case 111 /* WithKeyword */: return parseWithStatement(); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return parseSwitchStatement(); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return parseThrowStatement(); - case 104 /* TryKeyword */: + case 106 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return parseTryStatement(); - case 80 /* DebuggerKeyword */: + case 82 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 58 /* AtToken */: + case 59 /* AtToken */: return parseDeclaration(); - case 122 /* AsyncKeyword */: - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 85 /* EnumKeyword */: - case 86 /* ExportKeyword */: - case 93 /* ImportKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 119 /* AbstractKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 87 /* EnumKeyword */: + case 88 /* ExportKeyword */: + case 95 /* ImportKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 121 /* AbstractKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: + case 149 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -21525,52 +22444,71 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126 /* DeclareKeyword */; + return modifier.kind === 129 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304 /* Ambient */; + m.flags |= 8388608 /* Ambient */; } - return doInsideOfContext(4194304 /* Ambient */, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: return parseVariableStatement(node); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassDeclaration(node); - case 111 /* InterfaceKeyword */: + case 113 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 141 /* TypeKeyword */: + case 144 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 85 /* EnumKeyword */: + case 87 /* EnumKeyword */: return parseEnumDeclaration(node); - case 146 /* GlobalKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 149 /* GlobalKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); switch (token()) { - case 81 /* DefaultKeyword */: - case 60 /* EqualsToken */: + case 83 /* DefaultKeyword */: + case 62 /* EqualsToken */: return parseExportAssignment(node); - case 120 /* AsKeyword */: + case 122 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -21579,7 +22517,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(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21602,24 +22540,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(214 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -21627,14 +22565,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(188 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(189 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -21656,10 +22594,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(241 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 /* Identifier */ && - token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 /* Identifier */ && + token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -21669,14 +22607,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(242 /* VariableDeclarationList */); switch (token()) { - case 106 /* VarKeyword */: + case 108 /* VarKeyword */: break; - case 112 /* LetKeyword */: + case 114 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -21692,7 +22630,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() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -21707,25 +22645,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 224 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + node.kind = 243 /* FunctionDeclaration */; + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* 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(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125 /* ConstructorKeyword */) { - return parseExpected(125 /* ConstructorKeyword */); + if (token() === 128 /* ConstructorKeyword */) { + return parseExpected(128 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -21737,25 +22675,25 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; - fillSignature(57 /* ColonToken */, 0 /* None */, node); + node.kind = 161 /* Constructor */; + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 160 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; - if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 158 /* PropertyDeclaration */; + if (!node.questionToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -21770,17 +22708,17 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. node.initializer = ts.hasModifier(node, 32 /* Static */) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseInitializer); + : doOutsideOfContext(8192 /* YieldContext */ | 4096 /* DisallowInContext */, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* 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(56 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -21788,13 +22726,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57 /* ColonToken */, 0 /* None */, node); + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58 /* AtToken */) { + if (token() === 59 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -21811,7 +22749,7 @@ var ts; } nextToken(); } - if (token() === 40 /* AsteriskToken */) { + if (token() === 41 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -21827,18 +22765,18 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 138 /* SetKeyword */ || idToken === 127 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 141 /* SetKeyword */ || idToken === 130 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { case 20 /* OpenParenToken */: // Method declaration - case 28 /* LessThanToken */: // Generic Method declaration - case 52 /* ExclamationToken */: // Non-null assertion on property name - case 57 /* ColonToken */: // Type Annotation for declaration - case 60 /* EqualsToken */: // Initializer for declaration - case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 29 /* LessThanToken */: // Generic Method declaration + case 53 /* ExclamationToken */: // Non-null assertion on property name + case 58 /* ColonToken */: // Type Annotation for declaration + case 62 /* EqualsToken */: // Initializer for declaration + case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -21856,10 +22794,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58 /* AtToken */)) { + if (!parseOptional(59 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(156 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -21879,7 +22817,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 80 /* 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)) { @@ -21898,7 +22836,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -21909,20 +22847,20 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(221 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 128 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -21936,27 +22874,37 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 40 /* AsteriskToken */ || + token() === 41 /* AsteriskToken */ || token() === 22 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608 /* Ambient */; + } + return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75 /* 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 */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 213 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 244 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77 /* ClassKeyword */); + parseExpected(79 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -21982,7 +22930,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -21994,33 +22942,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + ts.Debug.assert(tok === 89 /* ExtendsKeyword */ || tok === 112 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(277 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 29 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; - parseExpected(111 /* InterfaceKeyword */); + node.kind = 245 /* InterfaceDeclaration */; + parseExpected(113 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22028,11 +22975,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; - parseExpected(141 /* TypeKeyword */); + node.kind = 246 /* TypeAliasDeclaration */; + parseExpected(144 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -22042,14 +22989,14 @@ 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(279 /* EnumMember */); + var node = createNodeWithJSDoc(282 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; - parseExpected(85 /* EnumKeyword */); + node.kind = 247 /* EnumDeclaration */; + parseExpected(87 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -22061,7 +23008,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(249 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22072,7 +23019,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 248 /* 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 */; @@ -22084,11 +23031,11 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; - if (token() === 146 /* GlobalKeyword */) { + node.kind = 248 /* ModuleDeclaration */; + if (token() === 149 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 512 /* GlobalAugmentation */; + node.flags |= 1024 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(); @@ -22104,15 +23051,15 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146 /* GlobalKeyword */) { + if (token() === 149 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132 /* NamespaceKeyword */)) { + else if (parseOptional(135 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(131 /* ModuleKeyword */); + parseExpected(134 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } @@ -22120,52 +23067,52 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 /* RequireKeyword */ && + return token() === 138 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 42 /* SlashToken */; + return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; - parseExpected(120 /* AsKeyword */); - parseExpected(132 /* NamespaceKeyword */); + node.kind = 251 /* NamespaceExportDeclaration */; + parseExpected(122 /* AsKeyword */); + parseExpected(135 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 /* CommaToken */ && token() !== 145 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 148 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 253 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 40 /* AsteriskToken */ || // import * + token() === 41 /* AsteriskToken */ || // import * token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145 /* FromKeyword */); + parseExpected(148 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 252 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -22177,7 +23124,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(254 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22187,7 +23134,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(256 /* NamedImports */); } return finishNode(importClause); } @@ -22197,8 +23144,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); - parseExpected(135 /* RequireKeyword */); + var node = createNode(263 /* ExternalModuleReference */); + parseExpected(138 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -22220,9 +23167,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); - parseExpected(40 /* AsteriskToken */); - parseExpected(120 /* AsKeyword */); + var namespaceImport = createNode(255 /* NamespaceImport */); + parseExpected(41 /* AsteriskToken */); + parseExpected(122 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -22235,14 +23182,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 256 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(261 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(257 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22256,9 +23203,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(120 /* AsKeyword */); + parseExpected(122 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -22267,24 +23214,24 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 257 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; - if (parseOptional(40 /* AsteriskToken */)) { - parseExpected(145 /* FromKeyword */); + node.kind = 259 /* ExportDeclaration */; + if (parseOptional(41 /* AsteriskToken */)) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(260 /* 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() === 145 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(145 /* FromKeyword */); + if (token() === 148 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -22292,12 +23239,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; - if (parseOptional(60 /* EqualsToken */)) { + node.kind = 258 /* ExportAssignment */; + if (parseOptional(62 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(81 /* DefaultKeyword */); + parseExpected(83 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -22312,15 +23259,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */ + || node.kind === 253 /* ImportDeclaration */ + || node.kind === 258 /* ExportAssignment */ + || node.kind === 259 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -22328,7 +23273,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -22379,9 +23324,9 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(292 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); + result.type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -22391,8 +23336,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = parseJSDocCommentWorker(start, length); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22403,11 +23348,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = parseJSDocCommentWorker(start, length); + var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536 /* JavaScriptFile */) { + if (contextFlags & 131072 /* JavaScriptFile */) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -22472,7 +23417,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -22491,7 +23436,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 40 /* AsteriskToken */: + case 41 /* 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 @@ -22542,7 +23487,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(297 /* JSDocComment */, start); + var result = createNode(301 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22578,14 +23523,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { indentText += scanner.getTokenText(); if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40 /* AsteriskToken */) { + else if (token() === 41 /* AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -22593,7 +23538,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -22677,7 +23622,7 @@ var ts; } indent = 0; break; - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 3 /* SavingBackticks */) { comments.push(scanner.getTokenText()); break; @@ -22702,7 +23647,7 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -22710,7 +23655,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59 /* BacktickToken */: + case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { state = 2 /* SavingComments */; } @@ -22719,7 +23664,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -22742,7 +23687,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(300 /* JSDocTag */, start); + var result = createNode(304 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -22770,15 +23715,15 @@ var ts; skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(59 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(60 /* EqualsToken */)) { + if (parseOptionalToken(62 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -22787,9 +23732,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -22805,8 +23750,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(312 /* JSDocPropertyTag */, start) : - createNode(306 /* JSDocParameterTag */, start); + createNode(316 /* JSDocPropertyTag */, start) : + createNode(310 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -22823,20 +23768,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; - var start_2 = scanner.getStartPos(); + var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) { + if (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -22848,7 +23793,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(307 /* JSDocReturnTag */, start); + var result = createNode(311 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -22857,13 +23802,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(309 /* JSDocTypeTag */, start); + var result = createNode(313 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(302 /* JSDocAuthorTag */, start); + var result = createNode(306 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -22885,20 +23830,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 5 /* WhitespaceTrivia */: case 24 /* DotToken */: - case 58 /* AtToken */: + case 59 /* AtToken */: comments.push(scanner.getTokenText()); break; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (!seenLessThan || seenGreaterThan) { return; } @@ -22917,14 +23862,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(301 /* JSDocAugmentsTag */, start); + var result = createNode(305 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -22936,7 +23881,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(193 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -22944,19 +23889,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(303 /* JSDocClassTag */, start); + var tag = createNode(307 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(308 /* JSDocThisTag */, start); + var tag = createNode(312 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(305 /* JSDocEnumTag */, start); + var tag = createNode(309 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -22965,7 +23910,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(311 /* JSDocTypedefTag */, start); + var typedefTag = createNode(315 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -22979,9 +23924,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(298 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start); } - if (child.kind === 309 /* JSDocTypeTag */) { + if (child.kind === 313 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -22994,7 +23939,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23013,7 +23958,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(248 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23027,22 +23972,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(304 /* JSDocCallbackTag */, start); + var callbackTag = createNode(308 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(299 /* JSDocSignature */, start); + var jsdocSignature = createNode(303 /* 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(58 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 307 /* JSDocReturnTag */) { + if (tag && tag.kind === 311 /* JSDocReturnTag */) { return tag; } } @@ -23084,10 +24029,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 306 /* JSDocParameterTag */ || child.kind === 312 /* JSDocPropertyTag */) && + if (child && (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23100,13 +24045,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -23115,7 +24060,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -23151,13 +24096,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(154 /* 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(27 /* CommaToken */)); - var result = createNode(310 /* JSDocTemplateTag */, start); + var result = createNode(314 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23190,18 +24135,21 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } + identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73 /* Identifier */, pos); - result.escapedText = ts.escapeLeadingUnderscores(scanner.getTokenText()); + var result = createNode(75 /* Identifier */, pos); + if (token() !== 75 /* Identifier */) { + result.originalKeywordKind = token(); + } + result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); finishNode(result, end); nextTokenJSDoc(); return result; } } - JSDocParser.parseJSDocCommentWorker = parseJSDocCommentWorker; })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {})); })(Parser || (Parser = {})); var IncrementalParser; @@ -23322,7 +24270,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return true; } return false; @@ -23888,10 +24836,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73 /* Identifier */) { + if (lhs.kind === 75 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101 /* ThisKeyword */) { + if (lhs.kind === 103 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -24041,12 +24989,21 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", type: "boolean", category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_incremental_compilation, + transpileOptionValue: undefined }, { name: "locale", @@ -24056,7 +25013,7 @@ var ts; }, ]; /* @internal */ - ts.optionDeclarations = ts.commonOptionsWithBuild.concat([ + ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "all", type: "boolean", @@ -24158,7 +25115,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, + transpileOptionValue: undefined }, { name: "allowJs", @@ -24195,6 +25153,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "declarationMap", @@ -24203,6 +25162,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, + transpileOptionValue: undefined }, { name: "emitDeclarationOnly", @@ -24210,6 +25170,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, + transpileOptionValue: undefined }, { name: "sourceMap", @@ -24228,6 +25189,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "outDir", @@ -24255,6 +25217,7 @@ var ts; isTSConfigOnly: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Enable_project_compilation, + transpileOptionValue: undefined }, { name: "tsBuildInfoFile", @@ -24264,6 +25227,7 @@ var ts; paramType: ts.Diagnostics.FILE, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, + transpileOptionValue: undefined }, { name: "removeComments", @@ -24280,6 +25244,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Do_not_emit_outputs, + transpileOptionValue: undefined }, { name: "importHelpers", @@ -24299,7 +25264,8 @@ var ts; name: "isolatedModules", type: "boolean", category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, + transpileOptionValue: true }, // Strict Type Checks { @@ -24433,7 +25399,8 @@ var ts; affectsModuleResolution: true, isTSConfigOnly: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, + transpileOptionValue: undefined }, { // this option can only be specified in tsconfig.json @@ -24448,7 +25415,8 @@ var ts; }, affectsModuleResolution: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, + transpileOptionValue: undefined }, { name: "typeRoots", @@ -24472,7 +25440,8 @@ var ts; affectsModuleResolution: true, showInSimplifiedHelpView: true, category: ts.Diagnostics.Module_Resolution_Options, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, + transpileOptionValue: undefined }, { name: "allowSyntheticDefaultImports", @@ -24569,6 +25538,7 @@ var ts; category: ts.Diagnostics.Advanced_Options, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + transpileOptionValue: undefined }, { name: "reactNamespace", @@ -24618,14 +25588,20 @@ var ts; type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, + // We are not returning a sourceFile for lib file when asked by the program, + // so pass --noLib to avoid reporting a file not found error. + transpileOptionValue: true }, { name: "noResolve", type: "boolean", affectsModuleResolution: true, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, + // We are not doing a full typecheck, we are not resolving the whole context, + // so pass --noResolve to avoid reporting missing file errors. + transpileOptionValue: true }, { name: "stripInternal", @@ -24641,6 +25617,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -24661,6 +25643,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + transpileOptionValue: undefined }, { name: "preserveConstEnums", @@ -24676,7 +25659,8 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Output_directory_for_generated_declaration_files + description: ts.Diagnostics.Output_directory_for_generated_declaration_files, + transpileOptionValue: undefined }, { name: "skipLibCheck", @@ -24734,6 +25718,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -24763,7 +25754,11 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ - ts.buildOpts = ts.commonOptionsWithBuild.concat([ + ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { + return ts.hasProperty(option, "transpileOptionValue"); + }); + /* @internal */ + ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [ { name: "verbose", shortName: "v", @@ -24827,7 +25822,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; /* @internal */ @@ -25327,7 +26323,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 !== 276 /* PropertyAssignment */) { + if (element.kind !== 279 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25383,15 +26379,15 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97 /* NullKeyword */: + case 99 /* 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 + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25409,13 +26405,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 206 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25432,7 +26428,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25483,13 +26479,13 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), 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 config = __assign(__assign({ compilerOptions: __assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign({}, r, { path: r.originalPath, originalPath: undefined })); }), files: ts.length(files) ? files : undefined }, (configParseResult.configFileSpecs ? { + return (__assign(__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, build: undefined, version: undefined }), references: ts.map(configParseResult.projectReferences, function (r) { return (__assign(__assign({}, r), { path: r.originalPath ? 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 }); + } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined }); return config; } ts.convertToTSConfig = convertToTSConfig; @@ -25714,8 +26710,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -25881,7 +26876,7 @@ var ts; basePath = ts.normalizeSlashes(basePath); var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> "))); return { raw: json || convertToObject(sourceFile, errors) }; } var ownConfig = json ? @@ -26570,8 +27565,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -26830,7 +27826,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27014,6 +28010,7 @@ var ts; trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); } } + ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); @@ -27024,6 +28021,9 @@ var ts; default: return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } + if (result && result.resolvedModule) + ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, result); if (!ts.isExternalModuleNameRelative(moduleName)) { @@ -27233,7 +28233,7 @@ var ts; ts.tryResolveJSModule = tryResolveJSModule; var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; - var tsPlusJsonExtensions = tsExtensions.concat([Extensions.Json]); + var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]); var tsconfigExtensions = [Extensions.TSConfig]; function tryResolveJSModuleWorker(moduleName, initialDir, host) { return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); @@ -27269,7 +28269,7 @@ var ts; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; - resolvedValue = __assign({}, resolvedValue, { path: path, originalPath: originalPath }); + resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } }; @@ -27290,7 +28290,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -27770,35 +28770,67 @@ var ts; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1 /* Instantiated */; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0 /* NonInstantiated */; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; - // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case 259 /* ExportDeclaration */: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0 /* NonInstantiated */; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1 /* Instantiated */) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. + case 249 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0 /* NonInstantiated */: // child is non-instantiated - continue searching @@ -27817,9 +28849,9 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: - return getModuleInstanceState(node); - case 73 /* Identifier */: + case 248 /* ModuleDeclaration */: + return getModuleInstanceState(node, visited); + case 75 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -27828,6 +28860,36 @@ var ts; } return 1 /* Instantiated */; } + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1 /* Instantiated */) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + } var ContainerFlags; (function (ContainerFlags) { // The current node is not a container, and no container manipulation should happen before @@ -27856,7 +28918,9 @@ var ts; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); + ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); + ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); } @@ -27890,7 +28954,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -27958,7 +29022,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -27969,7 +29033,7 @@ var ts; if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { setValueDeclaration(symbol, node); } } @@ -27985,7 +29049,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 === 255 /* ExportAssignment */) { + if (node.kind === 258 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -27994,7 +29058,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28006,39 +29070,42 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: + case 169 /* FunctionType */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 155 /* 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 === 295 /* 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 === 298 /* 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; @@ -28138,7 +29205,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 === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 258 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28156,7 +29223,7 @@ var ts; } }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); - file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInformation_1)) : diag); + file.bindDiagnostics.push(multipleDefaultExports_1 ? ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)) : diag); symbol = createSymbol(0 /* None */, name); } } @@ -28173,7 +29240,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 261 /* ExportSpecifier */ || (node.kind === 252 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28197,11 +29264,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { - if (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { + if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 67220415 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -28240,7 +29307,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 !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28268,12 +29335,12 @@ var ts; if (!isIIFE) { currentFlow = { flags: 2 /* Start */ }; if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { - currentFlow.container = node; + currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -28281,19 +29348,20 @@ var ts; flowNodeCreated = ts.identity; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~1408 /* ReachabilityAndEmitFlags */; + node.flags &= ~2816 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 128 /* HasImplicitReturn */; + node.flags |= 256 /* HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 256 /* HasExplicitReturn */; + node.flags |= 512 /* HasExplicitReturn */; + node.endFlowNode = currentFlow; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28310,7 +29378,7 @@ var ts; else if (containerFlags & 64 /* IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 /* ContainsThis */ : node.flags & ~64 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; } else { bindChildren(node); @@ -28337,8 +29405,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28370,79 +29438,93 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 /* FirstStatement */ && node.kind <= 240 /* LastStatement */ && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 225 /* ExpressionStatement */: + bindExpressionStatement(node); + break; + case 237 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + bindAccessExpressionFlow(node); + break; + case 195 /* CallExpression */: bindCallExpressionFlow(node); break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; + case 307 /* JSDocClassTag */: + bindJSDocClassTag(node); + break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 288 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28453,29 +29535,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: - return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 203 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || + return expr.kind === 75 /* Identifier */ || expr.kind === 103 /* ThisKeyword */ || expr.kind === 101 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && + ts.isElementAccessExpression(expr) && + ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { @@ -28487,7 +29569,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 193 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28501,17 +29583,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableReference(expr.left); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -28520,11 +29602,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -28533,20 +29615,14 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4 /* BranchLabel */, - antecedents: undefined - }; + return { flags: 4 /* BranchLabel */, antecedents: undefined }; } function createLoopLabel() { - return { - flags: 8 /* LoopLabel */, - antecedents: undefined - }; + return { flags: 8 /* LoopLabel */, antecedents: undefined }; } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; + flow.flags |= flow.flags & 1024 /* Referenced */ ? 2048 /* Shared */ : 1024 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -28561,31 +29637,36 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 103 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 88 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { - return unreachableFlow; + if (expression.kind === 105 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 90 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (!ts.isOptionalChainRoot(expression.parent)) { + return unreachableFlow; + } } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16 /* Assignment */, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -28600,47 +29681,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 229 /* ForStatement */: + case 209 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 206 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 55 /* BarBarToken */); + return node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* BarBarToken */ || + node.operatorToken.kind === 60 /* QuestionQuestionToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && - node.parent.operator === 52 /* ExclamationToken */) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); } @@ -28668,7 +29754,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 237 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -28700,15 +29786,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 231 /* ForOfStatement */) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 242 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -28730,7 +29816,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 234 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -28750,7 +29836,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -28842,7 +29928,7 @@ var ts; // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. - var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = { flags: 4096 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -28860,7 +29946,7 @@ var ts; } } if (!(currentFlow.flags & 1 /* Unreachable */)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096 /* AfterFinally */, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192 /* AfterFinally */, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -28878,9 +29964,10 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276 /* 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). + // case clauses have unreachable end points (e.g. they all return). Note, we no longer need + // this property in control flow analysis, it's there only for backwards compatibility. node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -28934,6 +30021,17 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + // A top level call expression with a dotted function name and at least one argument + // is potentially an assertion and is therefore included in the control flow. + if (node.expression.kind === 195 /* CallExpression */) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -28945,14 +30043,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 227 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -28963,10 +30061,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 191 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 212 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -28974,16 +30072,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 279 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 280 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 281 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -28991,7 +30089,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -29002,7 +30100,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52 /* ExclamationToken */) { + if (node.operator === 53 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -29012,20 +30110,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -29039,7 +30137,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 62 /* EqualsToken */ && node.left.kind === 194 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29050,7 +30148,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 193 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29089,27 +30187,102 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.fullName) { + if (node.kind !== 309 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - // If the target of the call expression is a function expression or arrow function we have - // 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 === 196 /* ParenthesizedExpression */) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + } + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193 /* PropertyAccessExpression */: + bind(node.name); + break; + case 194 /* ElementAccessExpression */: + bind(node.argumentExpression); + break; + case 195 /* CallExpression */: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + // For an optional chain, we emulate the behavior of a logical expression: + // + // a?.b -> a && a.b + // a?.b.c -> a && a.b.c + // a?.b?.c -> a && a.b && a.b.c + // a?.[x = 1] -> a && a[x = 1] + // + // To do this we descend through the chain until we reach the root of a chain (the expression with a `?.`) + // and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest + // of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost + // chain node. We then treat the entire node as the right side of the expression. + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + // If the target of the call expression is a function expression or arrow function we have + // an immediately invoked function expression (IIFE). Initialize the flowNode property to + // the current control flow (which includes evaluation of the IIFE arguments). + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 /* FunctionExpression */ || expr.kind === 201 /* ArrowFunction */) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29118,54 +30291,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 272 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 299 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 298 /* JSDocFunctionType */: + case 169 /* FunctionType */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 170 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 278 /* CatchClause */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 250 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 222 /* 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 @@ -29198,45 +30371,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 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 192 /* ObjectLiteralExpression */: + case 245 /* InterfaceDeclaration */: + case 272 /* 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 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 299 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 303 /* JSDocSignature */: + case 166 /* IndexSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 298 /* JSDocFunctionType */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 246 /* TypeAliasDeclaration */: + case 185 /* 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 @@ -29263,11 +30436,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 4194304 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 32 /* ExportContext */; + if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* ExportContext */; } else { - node.flags &= ~32 /* ExportContext */; + node.flags &= ~64 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -29337,7 +30510,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 === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 281 /* SpreadAssignment */ || prop.name.kind !== 75 /* Identifier */) { continue; } var identifier = prop.name; @@ -29349,7 +30522,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 === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 279 /* PropertyAssignment */ || prop.kind === 280 /* ShorthandPropertyAssignment */ || prop.kind === 160 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29381,10 +30554,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29415,9 +30588,37 @@ var ts; currentFlow = { flags: 2 /* Start */ }; parent = typeAlias; bind(typeAlias.typeExpression); - if (!typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + var declName = ts.getNameOfDeclaration(typeAlias); + if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { + // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C + var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); + if (isTopLevel) { + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); + var oldContainer = container; + switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + container = file; + break; + case 4 /* ThisProperty */: + container = declName.parent.expression; + break; + case 3 /* PrototypeProperty */: + container = declName.parent.expression.name; + break; + case 5 /* Property */: + container = ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; + break; + case 0 /* None */: + return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); + } + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + container = oldContainer; + } + } + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75 /* Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -29433,10 +30634,11 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 112 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 120 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */)) { + !(node.flags & 8388608 /* Ambient */) && + !(node.flags & 4194304 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29470,7 +30672,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 73 /* Identifier */) { + if (inStrictMode && node.expression.kind === 75 /* 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); @@ -29481,7 +30683,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73 /* Identifier */) { + if (name && name.kind === 75 /* 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 @@ -29522,8 +30724,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 288 /* SourceFile */ && + blockScopeContainer.kind !== 248 /* 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. @@ -29549,7 +30751,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -29584,7 +30786,7 @@ var ts; file.bindDiagnostics.push(diag); } else { - file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } } function bind(node) { @@ -29618,7 +30820,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 > 148 /* LastToken */) { + if (node.kind > 151 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -29658,8 +30860,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -29680,7 +30882,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 73 /* Identifier */: + case 75 /* 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. @@ -29689,31 +30891,32 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); break; } // falls through - case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + case 103 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -29741,76 +30944,76 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 182 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 282 /* EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* 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 240 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); + case 243 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67154879 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67187647 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 162 /* GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); + case 163 /* SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: + case 170 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 185 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -29829,64 +31032,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 67897736 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67897832 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); + case 246 /* TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + case 247 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 288 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 222 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 306 /* JSDocParameterTag */: - if (node.parent.kind === 299 /* JSDocSignature */) { + case 310 /* JSDocParameterTag */: + if (node.parent.kind === 303 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 298 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 302 /* JSDocTypeLiteral */) { break; } // falls through - case 312 /* JSDocPropertyTag */: + case 316 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -29994,8 +31198,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); } @@ -30005,7 +31208,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 /* Property */ | 1048576 /* ExportValue */ | 32 /* Class */ : 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, lhs, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); } } function bindModuleExportsAssignment(node) { @@ -30030,13 +31233,13 @@ var ts; ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 === 60 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } @@ -30044,38 +31247,59 @@ var ts; // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220414 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } break; default: ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4 /* Property */, "__computed" /* Computed */); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101 /* ThisKeyword */) { + if (node.expression.kind === 103 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30088,8 +31312,7 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.left.expression, node.left, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); @@ -30108,32 +31331,38 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 288 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { // This can be an alias for the 'exports' or 'module.exports' names, e.g. // var util = module.exports; // util.property = function ... bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -30142,10 +31371,10 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { - if (isToplevel && !isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */))) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { + if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; @@ -30161,6 +31390,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30171,17 +31403,47 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 67212223 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var includes = 0 /* None */; + var excludes = 0 /* None */; + // Method-like + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192 /* Method */; + excludes = 103359 /* MethodExcludes */; + } + // Maybe accessor-like + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this + // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) + includes |= 65536 /* SetAccessor */ | 4 /* Property */; + excludes |= 78783 /* SetAccessorExcludes */; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 /* GetAccessor */ | 4 /* Property */; + excludes |= 46015 /* GetAccessorExcludes */; + } + } + if (includes === 0 /* None */) { + includes = 4 /* Property */; + excludes = 0 /* PropertyExcludes */; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function isTopLevelNamespaceAssignment(propertyAccess) { + return ts.isBinaryExpression(propertyAccess.parent) + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 /* SourceFile */ + : propertyAccess.parent.parent.kind === 288 /* SourceFile */; + } + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); - var isToplevel = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30210,7 +31472,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 === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -30227,7 +31489,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -30239,7 +31501,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -30250,8 +31512,8 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); + if (node.kind === 244 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; @@ -30284,19 +31546,16 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 68008831 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 68008191 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var isEnum = ts.isInJSFile(node) && !!ts.getJSDocEnumTag(node); - var enumFlags = (isEnum ? 256 /* RegularEnum */ : 0 /* None */); - var enumExcludes = (isEnum ? 68008191 /* RegularEnumExcludes */ : 0 /* None */); if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */ | enumFlags, 67220415 /* BlockScopedVariableExcludes */ | enumExcludes); + bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -30308,18 +31567,18 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */ | enumFlags, 67220414 /* FunctionScopedVariableExcludes */ | enumExcludes); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 306 /* JSDocParameterTag */ && container.kind !== 299 /* JSDocSignature */) { + if (node.kind === 310 /* JSDocParameterTag */ && container.kind !== 303 /* JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { + if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); @@ -30328,34 +31587,34 @@ var ts; bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 67220415 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (ts.isParameterPropertyDeclaration(node)) { + if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 67219887 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -30366,8 +31625,8 @@ var ts; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -30387,26 +31646,26 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 180 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } else { bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67635688 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } // reachability checks @@ -30421,11 +31680,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 223 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 248 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30439,7 +31698,7 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 8388608 /* Ambient */) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -30469,12 +31728,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30486,7 +31745,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -30523,58 +31782,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 155 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 161 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -30585,6 +31844,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } if (node.typeArguments) { transformFlags |= 1 /* AssertTypeScript */; } @@ -30596,7 +31858,7 @@ var ts; transformFlags |= 2048 /* ContainsLexicalThis */; } } - if (expression.kind === 93 /* ImportKeyword */) { + if (expression.kind === 95 /* ImportKeyword */) { transformFlags |= 524288 /* ContainsDynamicImport */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -30619,17 +31881,20 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* QuestionQuestionToken */) { + transformFlags |= 4 /* AssertESNext */; + } + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 192 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 191 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ - || operatorTokenKind === 64 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 42 /* AsteriskAsteriskToken */ + || operatorTokenKind === 66 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 64 /* AssertES2016 */; } @@ -30672,8 +31937,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 === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 216 /* AsExpression */ + || expressionKind === 198 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -30713,11 +31978,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87 /* ExtendsKeyword */: + case 89 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; - case 110 /* ImplementsKeyword */: + case 112 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; @@ -30908,9 +32173,12 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -30920,9 +32188,12 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If an ElementAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31010,43 +32281,43 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { - case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 125 /* AsyncKeyword */: + case 205 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; break; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 217 /* NonNullExpression */: + case 137 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 267 /* JsxClosingElement */: + case 268 /* JsxFragment */: + case 269 /* JsxOpeningFragment */: + case 270 /* JsxClosingFragment */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 274 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31054,11 +32325,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: - case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 280 /* ShorthandPropertyAssignment */: + case 119 /* StaticKeyword */: + case 218 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31075,103 +32346,103 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; break; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 167 /* TypePredicate */: + case 168 /* TypeReference */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 171 /* TypeQuery */: + case 172 /* TypeLiteral */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 180 /* InferType */: + case 181 /* ParenthesizedType */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: + case 251 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 153 /* 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. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; excludeFlags = 536870912 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31184,26 +32455,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31221,67 +32492,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 191 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 155 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 161 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 139 /* StringKeyword */: - case 137 /* ObjectKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 142 /* StringKeyword */: + case 140 /* ObjectKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 278 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 315 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: - case 99 /* SuperKeyword */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: + case 199 /* ParenthesizedExpression */: + case 101 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31300,7 +32571,7 @@ var ts; /** @internal */ var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -31373,7 +32644,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -31456,7 +32727,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 === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 171 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -31507,6 +32778,180 @@ var ts; WideningKind[WideningKind["Normal"] = 0] = "Normal"; WideningKind[WideningKind["GeneratorYield"] = 1] = "GeneratorYield"; })(WideningKind || (WideningKind = {})); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + 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"] = 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 */, + bigint: 4 /* TypeofEQBigInt */, + boolean: 8 /* TypeofEQBoolean */, + symbol: 16 /* TypeofEQSymbol */, + undefined: 65536 /* EQUndefined */, + object: 32 /* TypeofEQObject */, + function: 64 /* TypeofEQFunction */ + }); + var typeofNEFacts = ts.createMapFromTemplate({ + 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 TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; + TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; + TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; + CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; + CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; + })(CheckMode || (CheckMode = {})); + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + ContextFlags[ContextFlags["NoConstraints"] = 2] = "NoConstraints"; + })(ContextFlags || (ContextFlags = {})); + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; + })(AccessFlags || (AccessFlags = {})); + var CallbackCheck; + (function (CallbackCheck) { + CallbackCheck[CallbackCheck["None"] = 0] = "None"; + CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; + CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; + })(CallbackCheck || (CallbackCheck = {})); + var MappedTypeModifiers; + (function (MappedTypeModifiers) { + MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; + MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; + MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; + })(MappedTypeModifiers || (MappedTypeModifiers = {})); + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var MembersOrExportsResolutionKind; + (function (MembersOrExportsResolutionKind) { + MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; + MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; + })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); + var UnusedKind; + (function (UnusedKind) { + UnusedKind[UnusedKind["Local"] = 0] = "Local"; + UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; + })(UnusedKind || (UnusedKind = {})); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); + var DeclarationMeaning; + (function (DeclarationMeaning) { + DeclarationMeaning[DeclarationMeaning["GetAccessor"] = 1] = "GetAccessor"; + DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; + DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; + DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; + })(DeclarationMeaning || (DeclarationMeaning = {})); + var DeclarationSpaces; + (function (DeclarationSpaces) { + DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; + DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; + DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; + DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; + })(DeclarationSpaces || (DeclarationSpaces = {})); function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -31554,11 +32999,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -31592,6 +33035,9 @@ var ts; var requireSymbol = createSymbol(4 /* Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; + // This object is reused for `checkOptionalExpression` return values to avoid frequent GC due to nursery object allocations. + // This object represents a pool-size of 1. + var pooledOptionalTypeResult = { isOptional: false, type: undefined }; // for public members that accept a Node or one of its subtypes, we must guard against // synthetic nodes created during transformations by calling `getParseTreeNode`. // for most of these, we perform the guard only on `checker` to avoid any possible @@ -31640,8 +33086,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -31758,7 +33207,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -31774,6 +33223,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -31792,6 +33244,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -31820,7 +33273,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -31832,7 +33285,7 @@ var ts; // Ensure file is type checked checkSourceFile(file); ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); - diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { addUnusedDiagnostics(); } @@ -31844,7 +33297,7 @@ var ts; function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { if (!ts.containsParseError(containingNode) && !unusedIsError(kind)) { - (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); } @@ -31884,6 +33337,7 @@ var ts; var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 262144 /* ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); var nullType = createIntrinsicType(65536 /* Null */, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 262144 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); @@ -31913,6 +33367,7 @@ var ts; var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 1048576 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -31936,7 +33391,7 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); + var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 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); @@ -32033,6 +33488,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -32045,113 +33503,18 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); - // Suggestion diagnostics must have a file. Keyed by source file name. - var suggestionDiagnostics = ts.createMultiMap(); - var TypeFacts; - (function (TypeFacts) { - TypeFacts[TypeFacts["None"] = 0] = "None"; - TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; - TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; - 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"] = 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 */, - bigint: 4 /* TypeofEQBigInt */, - boolean: 8 /* TypeofEQBoolean */, - symbol: 16 /* TypeofEQSymbol */, - undefined: 65536 /* EQUndefined */, - object: 32 /* TypeofEQObject */, - function: 64 /* TypeofEQFunction */ - }); - var typeofNEFacts = ts.createMapFromTemplate({ - 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 suggestionDiagnostics = ts.createDiagnosticCollection(); var typeofTypesByName = ts.createMapFromTemplate({ string: stringType, number: numberType, @@ -32169,71 +33532,8 @@ var ts; var comparableRelation = ts.createMap(); var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); - var TypeSystemPropertyName; - (function (TypeSystemPropertyName) { - TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; - TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; - TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; - TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; - TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; - TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; - })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); - var CheckMode; - (function (CheckMode) { - CheckMode[CheckMode["Normal"] = 0] = "Normal"; - CheckMode[CheckMode["Contextual"] = 1] = "Contextual"; - CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; - CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive"; - CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; - CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; - })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - })(AccessFlags || (AccessFlags = {})); - var CallbackCheck; - (function (CallbackCheck) { - CallbackCheck[CallbackCheck["None"] = 0] = "None"; - CallbackCheck[CallbackCheck["Bivariant"] = 1] = "Bivariant"; - CallbackCheck[CallbackCheck["Strict"] = 2] = "Strict"; - })(CallbackCheck || (CallbackCheck = {})); - var MappedTypeModifiers; - (function (MappedTypeModifiers) { - MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeReadonly"] = 2] = "ExcludeReadonly"; - MappedTypeModifiers[MappedTypeModifiers["IncludeOptional"] = 4] = "IncludeOptional"; - MappedTypeModifiers[MappedTypeModifiers["ExcludeOptional"] = 8] = "ExcludeOptional"; - })(MappedTypeModifiers || (MappedTypeModifiers = {})); - var ExpandingFlags; - (function (ExpandingFlags) { - ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; - ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; - ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; - ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; - })(ExpandingFlags || (ExpandingFlags = {})); - var MembersOrExportsResolutionKind; - (function (MembersOrExportsResolutionKind) { - MembersOrExportsResolutionKind["resolvedExports"] = "resolvedExports"; - MembersOrExportsResolutionKind["resolvedMembers"] = "resolvedMembers"; - })(MembersOrExportsResolutionKind || (MembersOrExportsResolutionKind = {})); - var UnusedKind; - (function (UnusedKind) { - UnusedKind[UnusedKind["Local"] = 0] = "Local"; - UnusedKind[UnusedKind["Parameter"] = 1] = "Parameter"; - })(UnusedKind || (UnusedKind = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); - var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -32245,7 +33545,7 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; @@ -32298,11 +33598,11 @@ var ts; diagnostics.add(diagnostic); } else { - suggestionDiagnostics.add(diagnostic.file.fileName, __assign({}, diagnostic, { category: ts.DiagnosticCategory.Suggestion })); + suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion })); } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32324,35 +33624,35 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= 67220415 /* BlockScopedVariableExcludes */; + result |= 111551 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= 67220414 /* FunctionScopedVariableExcludes */; + result |= 111550 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) result |= 0 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= 68008959 /* EnumMemberExcludes */; + result |= 900095 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= 67219887 /* FunctionExcludes */; + result |= 110991 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 68008383 /* ClassExcludes */; + result |= 899503 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 67897736 /* InterfaceExcludes */; + result |= 788872 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) - result |= 68008191 /* RegularEnumExcludes */; + result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) - result |= 68008831 /* ConstEnumExcludes */; + result |= 899967 /* ConstEnumExcludes */; if (flags & 512 /* ValueModule */) result |= 110735 /* ValueModuleExcludes */; if (flags & 8192 /* Method */) - result |= 67212223 /* MethodExcludes */; + result |= 103359 /* MethodExcludes */; if (flags & 32768 /* GetAccessor */) - result |= 67154879 /* GetAccessorExcludes */; + result |= 46015 /* GetAccessorExcludes */; if (flags & 65536 /* SetAccessor */) - result |= 67187647 /* SetAccessorExcludes */; + result |= 78783 /* SetAccessorExcludes */; if (flags & 262144 /* TypeParameter */) - result |= 67635688 /* TypeParameterExcludes */; + result |= 526824 /* TypeParameterExcludes */; if (flags & 524288 /* TypeAlias */) - result |= 67897832 /* TypeAliasExcludes */; + result |= 788968 /* TypeAliasExcludes */; if (flags & 2097152 /* Alias */) result |= 2097152 /* AliasExcludes */; return result; @@ -32387,7 +33687,11 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* Assignment */) { - ts.Debug.assert(source !== target); + if (source === target) { + // This can happen when an export assigned namespace exports something also erroneously exported at the top level + // See `declarationFileNoCrashOnExtraExportModifier` for an example + return target; + } if (!(target.flags & 33554432 /* Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -32516,7 +33820,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -32526,7 +33830,7 @@ var ts; // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); if (mainModule_1.flags & 1920 /* Namespace */) { - // If we’re merging an augmentation to a pattern ambient module, we want to + // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you // all the exports both from the pattern and from the augmentation, but @@ -32575,7 +33879,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -32605,8 +33909,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 67220415 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 67220415 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -32619,7 +33923,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304 /* Ambient */) { + declaration.flags & 8388608 /* Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -32633,17 +33937,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 190 /* 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, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 190 /* 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, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 241 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -32666,22 +33970,22 @@ 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 === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 /* ExportSpecifier */ || (usage.parent.kind === 258 /* 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 === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 258 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 224 /* VariableStatement */: + case 229 /* ForStatement */: + case 231 /* 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)) { @@ -32702,16 +34006,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 158 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 160 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -32732,14 +34036,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 201 /* ArrowFunction */: + case 158 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 222 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return true; default: return false; @@ -32785,12 +34089,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 !== 297 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 301 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 155 /* Parameter */ || + lastLocation.kind === 154 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -32807,13 +34111,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 === 152 /* Parameter */ || + lastLocation.kind === 155 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 179 /* 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; @@ -32828,14 +34132,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + case 248 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -32859,7 +34163,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 261 /* ExportSpecifier */)) { break; } } @@ -32873,12 +34177,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -32888,20 +34192,20 @@ var ts; if (!ts.hasModifier(location, 32 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 67220415 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -32916,7 +34220,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 213 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -32924,11 +34228,11 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 89 /* ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67897832 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -32944,34 +34248,34 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67897832 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -32984,7 +34288,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -32993,7 +34297,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 === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 155 /* Parameter */) { location = location.parent; } // @@ -33008,24 +34312,25 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244 /* ClassDeclaration */)) { location = location.parent; } break; - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 155 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 155 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33045,7 +34350,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 288 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33111,21 +34416,21 @@ var ts; // we want to check for block-scoped if (errorLocation && (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 67220415 /* Value */) === 67220415 /* Value */))) { + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 67220415 /* Value */) === 67220415 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 67220415 /* Value */) === 67220415 /* Value */) { + if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -33141,10 +34446,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 201 /* ArrowFunction */ && location.kind !== 200 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -33157,12 +34462,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33174,7 +34479,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 === 151 /* TypeParameter */) { + if (decl.kind === 154 /* 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 @@ -33229,10 +34534,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33242,9 +34547,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -33263,8 +34568,8 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (67897832 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~67897832 /* Type */ & 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1920 /* Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -33273,12 +34578,12 @@ var ts; return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 67897832 /* Type */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { var message = isES2015OrLaterConstructorName(name) ? ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later @@ -33302,15 +34607,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (67220415 /* Value */ & ~1024 /* NamespaceModule */ & ~67897832 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (67897832 /* Type */ & ~1024 /* NamespaceModule */ & ~67220415 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~67897832 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -33320,11 +34625,15 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); + if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + // constructor functions aren't block scoped + return; + } // 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 === 244 /* EnumDeclaration */) || ts.isInJSFile(d) && !!ts.getJSDocEnumTag(d); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { @@ -33356,13 +34665,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33372,7 +34681,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33437,7 +34746,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -33449,7 +34763,7 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -33473,7 +34787,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (67897832 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -33503,9 +34817,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -33540,7 +34855,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default" /* Default */)) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -33560,34 +34880,56 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; } - var aliasLike = resolveEntityName(expression, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 261 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); + case 258 /* ExportAssignment */: + case 208 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280 /* ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 279 /* PropertyAssignment */: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193 /* PropertyAccessExpression */: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -33597,7 +34939,7 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); @@ -33631,7 +34973,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 67220415 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); + ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -33647,17 +34989,15 @@ var ts; var node = getDeclarationOfAliasSymbol(symbol); if (!node) return ts.Debug.fail(); - if (node.kind === 255 /* ExportAssignment */) { - // export default - checkExpressionCached(node.expression); - } - else if (node.kind === 258 /* ExportSpecifier */) { - // export { } or export { as foo } - checkExpressionCached(node.propertyName || node.name); - } - else if (ts.isInternalModuleImportEqualsDeclaration(node)) { - // import foo = - checkExpressionCached(node.moduleReference); + // We defer checking of the reference of an `import =` until the import itself is referenced, + // This way a chain of imports can be elided if ultimately the final input is only used in a type + // position. + if (ts.isInternalModuleImportEqualsDeclaration(node)) { + var target = resolveSymbol(symbol); + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // import foo = + checkExpressionCached(node.moduleReference); + } } } } @@ -33669,18 +35009,18 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 73 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 75 /* Identifier */ || entityName.parent.kind === 152 /* 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 === 249 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 252 /* ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { @@ -33693,9 +35033,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 67220415 /* Value */ : 0); + var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); @@ -33703,9 +35043,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 152 /* QualifiedName */ || name.kind === 193 /* PropertyAccessExpression */) { + var left = name.kind === 152 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 152 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -33757,7 +35097,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -33796,6 +35136,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -33807,9 +35161,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -33840,7 +35191,7 @@ var ts; if (patternAmbientModules) { var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference); if (pattern) { - // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // If the module reference matched a pattern ambient module ('*.foo') but there's also a // module augmentation by the specific name requested ('a.foo'), we store the merged symbol // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports // from a.foo. @@ -33911,7 +35262,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -33920,9 +35271,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* ValueModule */; if (merged.exports === undefined) { - merged.flags = merged.flags | 512 /* ValueModule */; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -33930,15 +35285,16 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 288 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34012,7 +35368,7 @@ var ts; return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -34149,7 +35505,8 @@ var ts; */ function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + // Type parameters end up in the `members` lists but are not externally visible + if (container && !(symbol.flags & 262144 /* TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { @@ -34158,7 +35515,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -34166,7 +35534,7 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { @@ -34174,33 +35542,42 @@ var ts; // fast path, `symbol` is either already the alias or isn't aliased return symbol; } + // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return + // the container itself as the alias for the symbol + var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + /** + * Checks if two symbols, through aliasing and/or merging, refer to the same thing + */ + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? symbol.exportSymbol : symbol); } function symbolIsValue(symbol) { - return !!(symbol.flags & 67220415 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 67220415 /* Value */); + return !!(symbol.flags & 111551 /* Value */ || symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34278,31 +35655,61 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + case 248 /* ModuleDeclaration */: + var sym = getSymbolOfNode(location); + // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten + // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred + // to one another anyway) + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + // Type parameters are bound into `members` lists so they can merge across declarations + // This is troublesome, since in all other respects, they behave like locals :cries: + // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol + // lookup logic in terms of `resolveName` would be nice + // 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! + var table_1; + // TODO: Should this filtered table be cached in some way? + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 67220415 /* Value */ ? 67220415 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); } @@ -34333,12 +35740,12 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { // If symbol is directly available by its name in the symbol table @@ -34355,7 +35762,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, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34391,7 +35798,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, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34406,10 +35813,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: continue; default: return false; @@ -34420,11 +35827,11 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67897832 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 67220415 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); + var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false); return access.accessibility === 0 /* Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) { @@ -34467,7 +35874,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = ts.first(symbol.declarations); - if (!ts.length(containers) && meaning & 67220415 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { + if (!ts.length(containers) && meaning & 111551 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; } @@ -34526,14 +35933,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -34576,21 +35983,21 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 171 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 153 /* ComputedPropertyName */) { // Typeof value - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 152 /* QualifiedName */ || entityName.kind === 193 /* PropertyAccessExpression */ || + entityName.parent.kind === 252 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 67897832 /* Type */; + meaning = 788968 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); @@ -34632,15 +36039,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructorType */ : 169 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 165 /* ConstructSignature */ : 164 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -34663,14 +36070,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -34701,6 +36111,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -34711,7 +36124,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -34739,37 +36153,37 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(144 /* UnknownKeyword */); + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139 /* StringKeyword */); + return ts.createKeywordTypeNode(142 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136 /* NumberKeyword */); + return ts.createKeywordTypeNode(139 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147 /* BigIntKeyword */); + return ts.createKeywordTypeNode(150 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124 /* BooleanKeyword */); + return ts.createKeywordTypeNode(127 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 67897832 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), /*typeArguments*/ undefined)); return enumLiteralName; } if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 67897832 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* Type */); } if (type.flags & 128 /* StringLiteral */) { context.approximateLength += (type.value.length + 2); @@ -34778,7 +36192,7 @@ var ts; if (type.flags & 256 /* NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048 /* BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -34792,38 +36206,38 @@ var ts; if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 67220415 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143 /* UniqueKeyword */, ts.createKeywordTypeNode(140 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(146 /* UniqueKeyword */, ts.createKeywordTypeNode(143 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107 /* VoidKeyword */); + return ts.createKeywordTypeNode(109 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(145 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97 /* NullKeyword */); + return ts.createKeywordTypeNode(99 /* NullKeyword */); } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133 /* NeverKeyword */); + return ts.createKeywordTypeNode(136 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140 /* SymbolKeyword */); + return ts.createKeywordTypeNode(143 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* ObjectKeyword */); + return ts.createKeywordTypeNode(140 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -34837,10 +36251,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { @@ -34848,6 +36268,7 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; @@ -34855,15 +36276,9 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return type.symbol - ? symbolToTypeNode(type.symbol, context, 67897832 /* Type */) + ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 67897832 /* Type */, typeArgumentNodes); - } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -34871,7 +36286,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 177 /* UnionType */ : 178 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -34935,51 +36350,31 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 67897832 /* Type */ : 67220415 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; 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 === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { - return symbolToTypeNode(symbol, context, 67220415 /* Value */); + return symbolToTypeNode(symbol, context, 111551 /* Value */); } 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) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 67897832 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* Type */); } else { return createElidedInformationPlaceholder(context); } } 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.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -34992,15 +36387,45 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 288 /* SourceFile */ || declaration.parent.kind === 249 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions 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 + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; + var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + // 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.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -35013,12 +36438,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170 /* ConstructorType */, context); return signatureNode; } } @@ -35031,7 +36456,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2 /* WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -35039,7 +36464,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { @@ -35053,12 +36478,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -35066,6 +36491,8 @@ var ts; else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && + // Use `import` types for refs to other scopes, only anonymize something defined in the same scope + ts.findAncestor(type.symbol.valueDeclaration, function (d) { return d === ts.getSourceFileOfNode(context.enclosingDeclaration); }) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return createAnonymousTypeNode(type); } @@ -35088,7 +36515,7 @@ var ts; var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_2 = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 67897832 /* Type */, typeArgumentSlice); + var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); context.flags = flags_2; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -35101,7 +36528,7 @@ var ts; } var flags = context.flags; context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 67897832 /* Type */, typeArgumentNodes); + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -35153,11 +36580,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35204,7 +36631,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); @@ -35215,25 +36642,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } - var propertyName = symbolToName(propertySymbol, context, 67220415 /* Value */, /*expectsIdentifier*/ true); + var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -35244,20 +36675,30 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { // Copy comments to node for declaration emit - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + ts.setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -35298,7 +36739,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 139 /* StringKeyword */ : 136 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 142 /* StringKeyword */ : 139 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -35311,7 +36752,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -35322,7 +36763,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 === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35330,23 +36771,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 /* Identifier */ ? + var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? + ts.createToken(123 /* AssertsKeyword */) : + undefined; + var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 121 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 124 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(124 /* 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); @@ -35366,9 +36810,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 306 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35378,15 +36822,14 @@ var ts; 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) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 152 /* 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) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(57 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -35396,29 +36839,32 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 190 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; // get symbol of the first identifier of the entityName - var firstIdentifier = getFirstIdentifier(node.expression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var firstIdentifier = getFirstIdentifier(accessExpression); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 67220415 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; @@ -35451,6 +36897,13 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent + // No need to lookup an alias for the symbol in itself + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -35531,7 +36984,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 288 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -35567,7 +37020,7 @@ var ts; // using the `baseUrl` compiler option (which we would otherwise never use in declaration emit) and a non-relative // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; - var specifierCompilerOptions = isBundle_1 ? __assign({}, compilerOptions, { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; + var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); @@ -35576,7 +37029,7 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 67220415 /* Value */; + var isTypeOf = meaning === 111551 /* Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -35623,16 +37076,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216 /* InInitialEntityName */; } - var parent = chain[index - 1]; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { @@ -35655,7 +37124,7 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 67897832 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + return !!resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); } function typeParameterToName(type, context) { if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { @@ -35664,7 +37133,10 @@ var ts; return cached; } } - var result = symbolToName(type.symbol, context, 67897832 /* Type */, /*expectsIdentifier*/ true); + var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 75 /* Identifier */)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -35710,9 +37182,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -35721,6 +37190,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -35748,12 +37220,1072 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + // See getNameForSymbolFromNameType for a stringy equivalent + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384 /* StringOrNumberLiteral */) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192 /* UniqueESSymbol */) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + // Make type parameters created within this context not consume the name outside this context + // The symbol serializer ends up creating many sibling scopes that all need "separate" contexts when + // it comes to naming things - within a normal `typeToTypeNode` call, the node builder only ever descends + // through the type tree, so the only cases where we could have used distinct sibling scopes was when there + // were multiple generic overloads with similar generated type parameter names + // The effect: + // When we write out + // export const x: (x: T) => T + // export const y: (x: T) => T + // we write it out like that, rather than as + // export const x: (x: T) => T + // export const y: (x: T_1) => T_1 + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159 /* MethodSignature */, /*useAcessors*/ false); + // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of + // declaration mapping + // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration + // emit codepaths which want to apply more specific contexts (so we can still refer to the root real declaration + // we're trying to emit from later on) + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.mapMap(symbolTable, function (_symbol, name) { return [ts.unescapeLeadingUnderscores(name), true]; }), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false); + if (accessibleResult.accessibility === 0 /* Accessible */) { + // Lookup the root symbol of the chain of refs we'll use to access it and serialize it + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4 /* Property */)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export=" /* ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + symbolTable = ts.createSymbolTable(); + // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) + symbolTable.set("export=" /* ExportEquals */, exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75 /* Identifier */; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from + // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1 /* Export */); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(/*alias*/ undefined, id); })), + /*moduleSpecifier*/ undefined)])); + } + // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + // Pass 2: Combine all `export {}` declarations + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), + /*moduleSpecifier*/ undefined)]); + } + // Pass 2b: Also combine all `export {} from "..."` declarations as needed + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + // remove group members from statements and then merge group members and add back to statements + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + // Pass 3: Move all `export {}`'s to `export` modifiers where possible + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + // all clauses removed, filter the export declaration + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + // some items filtered, others not - update the export declaration + // (mutating because why not, we're building a whole new tree here anyway) + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + // Not a cleanup, but as a final step: If there is a mix of `export` and non-`export` declarations, but no `export =` or `export {}` add a `export {};` so + // declaration privacy is respected. + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1 /* Export */) & ~2 /* Ambient */; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + // deferredPrivates will be filled up by visiting the symbol table + // And will continue to iterate as elements are added while visited `deferredPrivates` + // (As that's how a map iterator is defined to work) + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + // cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but + // still skip reserializing it if we encounter the merged product later on + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; // Already printed + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + // Only actually serialize symbols within the correct enclosing declaration, otherwise do nothing with the out-of-context symbol + var skipMembershipCheck = !isPrivate; // We only call this on exported symbols when we know they're in the correct scope + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias + // or a merge of some number of those. + // An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping + // each symbol in only one of the representations + // Also, synthesizing a default export of some kind + // If it's an alias: emit `export default ref` + // If it's a property: emit `export default _default` with a `_default` prop + // If it's a class/interface/function: emit a class/interface/function with a `default` modifier + // These forms can merge, eg (`export default 12; export default interface A {}`) + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default" /* Default */; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( + context.encounteredError = true; + // TODO: Issue error via symbol tracker? + return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); + if (symbol.flags & 16 /* Function */) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288 /* TypeAlias */) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + // Need to skip over export= symbols below - json source files get a single `Property` flagged + // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. + if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) + && symbol.escapedName !== "export=" /* ExportEquals */ + && !(symbol.flags & 4194304 /* Prototype */) + && !(symbol.flags & 32 /* Class */)) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384 /* Enum */) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 4 /* Property */) { + // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, + // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property + // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if (symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */)) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64 /* Interface */) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152 /* Alias */) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608 /* ExportStar */) { + // synthesize export * from "moduleReference" + // Straightforward - only one thing to do - make an export declaration + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*exportClause*/ undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + } + } + function includePrivateSymbol(symbol) { + ts.Debug.assertDefined(deferredPrivates); + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` + // Note: This _mutates_ `node` without using `updateNode` - the assumption being that all nodes should be manufactured fresh by the node builder + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0 /* None */; + if (additionalModifierFlags & 1 /* Export */ && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private + newModifierFlags |= 1 /* Export */; + } + if (addingDeclare && !(newModifierFlags & 1 /* Export */) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope + newModifierFlags |= 2 /* Ambient */; + } + if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* Default */; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; // Reset computed flags cache + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608 /* InTypeAlias */; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 164 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 165 /* ConstructSignature */); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather + // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, + // so we don't even have placeholders to fill in. + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, /*suppressNewPrivateContext*/ false); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + ts.forEach(mergedMembers, includePrivateSymbol); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + return ts.createExportSpecifier(name === localName ? undefined : localName, name); + })))]); + addResult(ts.createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ + // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` + var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined + : isConstVariable(symbol) ? 2 /* Const */ + : 1 /* Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a seperate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0 /* None */); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0 /* Call */); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + // Each overload becomes a separate function declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, 243 /* FunctionDeclaration */, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + // Module symbol emit will take care of module-y members, provided it has exports + if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + // handle remote props first - we need to make an `import` declaration that points at the module containing each remote + // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) + // Example: + // import Foo_1 = require("./exporter"); + // export namespace ns { + // import Foo = Foo_1.Foo; + // export { Foo }; + // export const c: number; + // } + // This is needed because in JS, statements like `const x = require("./f")` support both type and value lookup, even if they're + // normally just value lookup (so it functions kinda like an alias even when it's not an alias) + // _Usually_, we'll simply print the top-level as an alias instead of a `var` in such situations, however is is theoretically + // possible to encounter a situation where a type has members from both the current file and other files - in those situations, + // emit akin to the above would be needed. + // Add a namespace + var fakespace = ts.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16 /* Namespace */); + fakespace.flags ^= 8 /* Synthesized */; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + // TODO: implement handling for the localVsRemoteMap.get("remote") - should be difficult to trigger (see comment above), as only interesting cross-file js merges should make this possible + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, /*propertyAsAlias*/ true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8 /* Synthesized */; // reset synthesized + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); // namespaces can never be default exported + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); + // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics + var staticMembers = symbol.flags & (16 /* Function */ | 512 /* ValueModule */) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var constructors = serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 161 /* Constructor */); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + // A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration + // `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + // synthesize an alias, eg `export { symbolName as Name }` + // need to mark the alias `symbol` points + // at as something we need to serialize as a private declaration as well + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" /* ExportEquals */ && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match + verbatimTargetName = "default" /* Default */; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first + switch (node.kind) { + case 252 /* ImportEqualsDeclaration */: + // Could be a local `import localName = ns.member` or + // an external `import localName = require("whatever")` + var isLocalImport = !(target.flags & 512 /* ValueModule */); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0 /* None */); + break; + case 251 /* NamespaceExportDeclaration */: + // export as namespace foo + // TODO: Not part of a file's local or export symbol tables + // Is bound into file.symbol.globalExports instead, which we don't currently traverse + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + break; + case 254 /* ImportClause */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(ts.createIdentifier(localName), /*namedBindings*/ undefined), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0 /* None */); + break; + case 255 /* NamespaceImport */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + break; + case 257 /* ImportSpecifier */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent, context))), 0 /* None */); + break; + case 261 /* ExportSpecifier */: + // does not use localName because the symbol name in this case refers to the name in the exports table, + // which we must exactly preserve + var specifier = node.parent.parent.moduleSpecifier; + // targetName is only used when the target is local, as otherwise the target is an alias that points at + // another file + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258 /* ExportAssignment */: + serializeMaybeAliasAssignment(symbol); + break; + case 208 /* BinaryExpression */: + // Could be best encoded as though an export specifier or as though an export assignment + // If name is default or export=, do an export assignment + // Otherwise do an export specifier + if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + case 193 /* PropertyAccessExpression */: + // A PAE alias is _always_ going to exist as an append to a top-level export, where our top level + // handling should always be sufficient to encode the export action itself + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304 /* Prototype */) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export=" /* ExportEquals */; + var isDefault = name === "default" /* Default */; + var isExportAssignment = isExportEquals || isDefault; + // synthesize export = ref + // ref should refer to either be a locally scoped symbol which we need to emit, or + // a reference to another namespace/module which we may need to emit an `import` statement for + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + // serialize what the alias points to, preserve the declaration's initializer + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + if (target) { + // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it + // eg, `namespace A { export class B {} }; exports = A.B;` + // Technically, this is all that's required in the case where the assignment is an entity name expression + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + // We disable the context's symbol traker for the duration of this name serialization + // as, by virtue of being here, the name is required to print something, and we don't want to + // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue + // a visibility error here (as they're not visible within any scope), but we want to hoist them + // into the containing scope anyway, so we want to skip the visibility checks. + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + } + else { + if (first_1 === expr) { + // serialize as `export {target as name}` + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + // serialize as `import _Ref = t.arg.et; export { _Ref as name }` + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + // serialize as an anonymous property declaration + var varName = getUnusedName(name, symbol); + // We have to use `getWidenedType` here since the object within a json file is unwidened within the file + // (Unwidened types can only exist in expression contexts and should never be serialized) + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); + } + else { + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2 /* Const */)); + addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + // Only object types which are not constructable, or indexable, whose members all come from the + // context source file, and whose property names are all valid identifiers and not late-bound, _and_ + // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + !getIndexInfoOfType(typeToSerialize, 0 /* String */) && + !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols + // need to be merged namespace members + return []; + } + if (p.flags & 4194304 /* Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 /* Static */ : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 /* Accessor */ && useAccessors) { + var result = []; + if (p.flags & 65536 /* SetAccessor */) { + result.push(ts.setTextRange(ts.createSetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "arg", + /*questionToken*/ undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], + /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768 /* GetAccessor */) { + result.push(ts.setTextRange(ts.createGetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + // This is an else/if as accessors and properties can't merge in TS, but might in JS + // If this happens, we assume the accessor takes priority, as it imposes more constraints + else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { + return ts.setTextRange(createProperty( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | staticFlag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), + // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 + // interface members can't have initializers, however class members _can_ + /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0 /* Call */); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + // Each overload becomes a separate method declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; // TODO: Clone + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216 /* Optional */) { + decl.questionToken = ts.createToken(57 /* QuestionToken */); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 /* UniqueESSymbol */ && + type.symbol === symbol) { + context.flags |= 1048576 /* AllowUniqueESSymbolType */; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124 /* AnyKeyword */); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99 /* NullKeyword */)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, "x", + /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144 /* TypeParameter */) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1 /* Construct */) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // No base type, every constructor is empty - elide the extraneous `constructor()` + } + if (baseType) { + // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations + var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; // Every signature was identical - elide constructor list as it is inherited + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + // Each overload becomes a separate constructor declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0 /* String */, 1 /* Number */]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2 /* Const */)); + addResult(statement, 0 /* None */); + return ts.createExpressionWithTypeArguments(/*typeArgs*/ undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + // We don't use `isValueSymbolAccessible` below. since that considers alternative containers (like modules) + // which we can't write out in a syntactically valid way as an expression + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (input === "default" /* Default */) { + input = "_default"; + } + else if (input === "export=" /* ExportEquals */) { + input = "_exports"; + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + var flags = context.flags; + context.flags |= 16777216 /* InInitialEntityName */; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = ts.isIdentifierText(nameCandidate, languageVersion) && !ts.isStringANonContextualKeyword(nameCandidate) ? nameCandidate : getUnusedName("_default", symbol); + } + // The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createToken(123 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); @@ -35798,8 +38330,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 !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181 /* ParenthesizedType */; }); + if (node.kind === 246 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -35807,11 +38339,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 249 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 288 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -35849,9 +38381,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -35864,17 +38396,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 241 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -35891,27 +38426,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 304 /* JSDocCallbackTag */: - case 311 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 241 /* 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 247 /* EnumDeclaration */: + case 252 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -35919,53 +38455,54 @@ 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 !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 252 /* ImportEqualsDeclaration */ && parent.kind !== 288 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* 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 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 161 /* Constructor */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 155 /* Parameter */: + case 249 /* ModuleBlock */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 168 /* TypeReference */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 181 /* 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 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 288 /* SourceFile */: + case 251 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return false; default: return false; @@ -35974,14 +38511,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 258 /* ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 261 /* ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -35999,8 +38539,10 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); - if (importSymbol) { + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -36063,8 +38605,10 @@ var ts; } return ts.Debug.assertNever(propertyName); } - // Pop an entry from the type resolution stack and return its associated result value. The result value will - // be true if no circularities were detected, or false if a circularity was found. + /** + * Pop an entry from the type resolution stack and return its associated result value. The result value will + * be true if no circularities were detected, or false if a circularity was found. + */ function popTypeResolution() { resolutionTargets.pop(); resolutionPropertyNames.pop(); @@ -36073,12 +38617,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 241 /* VariableDeclaration */: + case 242 /* VariableDeclarationList */: + case 257 /* ImportSpecifier */: + case 256 /* NamedImports */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: return false; default: return true; @@ -36111,7 +38655,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36163,7 +38707,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(194 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36178,23 +38722,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 190 /* BindingElement */ && parent.kind === 188 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 279 /* PropertyAssignment */ || node.kind === 280 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36212,11 +38756,11 @@ var ts; 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)) { + if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 188 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36284,30 +38828,30 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 /* NullKeyword */ || expr.kind === 73 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 /* NullKeyword */ || expr.kind === 75 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 191 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 155 /* Parameter */ && + (node.parent.kind === 200 /* FunctionExpression */ || node.parent.kind === 201 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration 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 === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230 /* 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 === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231 /* 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, @@ -36326,8 +38870,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { + declaration.kind === 241 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -36340,11 +38884,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 155 /* 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 === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 163 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36411,12 +38955,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4 /* ThisProperty */) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -36434,6 +38980,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { @@ -36459,9 +39008,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -36554,9 +39103,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 === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 /* Constructor */ || + thisContainer.kind === 243 /* FunctionDeclaration */ || + (thisContainer.kind === 200 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -36631,7 +39180,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -36654,7 +39203,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -36693,7 +39242,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 155 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -36755,16 +39304,20 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 258 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -36805,6 +39358,9 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } @@ -36819,7 +39375,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -36846,59 +39402,65 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 163 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return errorType; - } - var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { // If there are no specified types, try to infer it from the body of the get accessor if it exists. if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } // Otherwise, fall back to 'any'. else { if (setter) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* 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)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -36906,19 +39468,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -36930,8 +39483,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 208 /* BinaryExpression */ || + (declaration.kind === 193 /* PropertyAccessExpression */ || declaration.kind === 194 /* ElementAccessExpression */) && + declaration.parent.kind === 208 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -36970,7 +39524,7 @@ var ts; // type symbol, call getDeclaredTypeOfSymbol. // This check is important because without it, a call to getTypeOfSymbol could end // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 67220415 /* Value */ + links.type = targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } @@ -36998,7 +39552,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -37079,39 +39633,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 310 /* JSDocTemplateTag */: - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 185 /* MappedType */: + case 179 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 185 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 179 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */ || node.kind === 245 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37119,7 +39684,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, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37128,9 +39693,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || + node.kind === 213 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37149,19 +39715,19 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37254,24 +39820,18 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37309,14 +39869,21 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } - // A valid base type is `any`, any non-generic object type or intersection of non-generic - // object types. + // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { + if (type.flags & 262144 /* TypeParameter */) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } + // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? + // There's no reason a `T` should be allowed while a `Readonly` should not. return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } @@ -37324,7 +39891,7 @@ var ts; 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 === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37360,8 +39927,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { - if (declaration.flags & 64 /* ContainsThis */) { + if (declaration.kind === 245 /* InterfaceDeclaration */) { + if (declaration.flags & 128 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -37369,7 +39936,7 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 67897832 /* Type */, /*ignoreErrors*/ true); + var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } @@ -37382,9 +39949,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37400,7 +39973,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -37416,9 +39989,10 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 243 /* TypeAliasDeclaration */; - }); + var declaration = ts.find(symbol.declarations, ts.isTypeAlias); + if (!declaration) { + return ts.Debug.fail("Type alias symbol with no valid declaration found"); + } var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -37434,17 +40008,17 @@ var ts; } else { type = errorType; - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isJSDocEnumTag(declaration) ? declaration : declaration.name || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; } return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 208 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37452,18 +40026,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304 /* Ambient */); + return !(member.flags & 8388608 /* Ambient */); } switch (expr.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 39 /* MinusToken */ && + case 206 /* PrefixUnaryExpression */: + return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37477,10 +40052,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -37504,7 +40079,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -37576,23 +40151,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: + case 186 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -37618,7 +40193,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -37634,14 +40209,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -37696,9 +40271,12 @@ var ts; * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 /* _ */ && @@ -37751,7 +40329,7 @@ var ts; else { symbol.declarations.push(member); } - if (symbolFlags & 67220415 /* Value */) { + if (symbolFlags & 111551 /* Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -37792,7 +40370,8 @@ var ts; // In the event we attempt to resolve the late-bound name of this member recursively, // fall back to the early-bound name of this member. links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -37808,9 +40387,9 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); } lateSymbol.nameType = type; @@ -37851,6 +40430,21 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + || assignmentKind === 4 /* ThisProperty */ + || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; @@ -37861,7 +40455,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 /* LateBindingContainer */ + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) : symbol.members || emptySymbols; } @@ -37891,7 +40485,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4 /* Reference */) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -37954,9 +40548,9 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { var sig = new Signature(checker); @@ -37987,13 +40581,18 @@ var ts; result.mapper = undefined; return result; } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.isOptionalCall = true; + return result; + } function getExpandedParameters(sig) { if (sig.hasRestParameter) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -38013,7 +40612,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38057,8 +40656,9 @@ var ts; } var result; for (var i = 0; i < signatureLists.length; i++) { - // Allow matching non-generic signatures to have excess parameters and different return types - var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true); + // Allow matching non-generic signatures to have excess parameters and different return types. + // Prefer matching this types if possible. + var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true); if (!match) { return undefined; } @@ -38082,7 +40682,7 @@ var ts; for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) { var signature = _a[_i]; // Only process signatures with parameter lists that aren't already in the result list - if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true)) { + if (!result || !findMatchingSignature(result, signature, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true)) { var unionSignatures = findMatchingSignatures(signatureLists, signature, i); if (unionSignatures) { var s = signature; @@ -38091,7 +40691,7 @@ var ts; var thisParameter = signature.thisParameter; var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; }); if (firstThisParameterOfUnionSignatures) { - var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); + var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); })); thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType); } s = createUnionSignature(signature, unionSignatures); @@ -38109,7 +40709,7 @@ var ts; // signatures from the type, whose ordering would be non-obvious) var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -38121,8 +40721,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -38135,8 +40735,8 @@ var ts; } // A signature `this` type might be a read or a write position... It's very possible that it should be invariant // and we should refuse to merge signatures if there are `this` types and they do not match. However, so as to be - // permissive when calling, for now, we'll union the `this` types just like the overlapping-union-signature check does - var thisType = getUnionType([getTypeOfSymbol(left), getTypeOfSymbol(right)], 2 /* Subtype */); + // permissive when calling, for now, we'll intersect the `this` types just like we do for param types in union signatures. + var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]); return createSymbolWithType(left, thisType); } function combineUnionParameters(left, right) { @@ -38247,7 +40847,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -38270,19 +40870,19 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } @@ -38290,7 +40890,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38346,14 +40946,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38496,8 +41100,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && - constraintDeclaration.operator === 130 /* KeyOfKeyword */; + return constraintDeclaration.kind === 183 /* TypeOperator */ && + constraintDeclaration.operator === 133 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -38510,7 +41114,7 @@ var ts; else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, // get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T', - // the modifiers type is T. Otherwise, the modifiers type is {}. + // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; @@ -38521,8 +41125,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - 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); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -38738,11 +41342,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; 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). @@ -38752,6 +41356,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908 /* DisjointDomains */) { @@ -38764,8 +41371,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -38851,8 +41458,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -39200,10 +41807,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 === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 297 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39237,13 +41844,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; - } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; } - function createThisTypePredicate(type) { - return { kind: 0 /* This */, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } /** * Gets the minimum number of type arguments needed to satisfy all non-optional type @@ -39309,7 +41913,7 @@ var ts; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 67220415 /* Value */, undefined, undefined, /*isUse*/ false); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this" /* This */) { @@ -39319,7 +41923,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { + if (type && type.kind === 186 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -39333,16 +41937,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 === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 162 /* GetAccessor */ || declaration.kind === 163 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 161 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -39400,13 +42004,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return node.name.kind === 153 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39449,9 +42053,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -39480,13 +42081,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73 /* Identifier */) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 /* ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -39496,8 +42094,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signature.isOptionalCall) { + type = propagateOptionalTypeMarker(type, /*wasOptional*/ true); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -39522,7 +42122,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 161 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39532,12 +42132,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39627,7 +42227,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 161 /* Constructor */ || kind === 165 /* ConstructSignature */ || kind === 170 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -39641,7 +42241,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 136 /* NumberKeyword */ : 139 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 139 /* NumberKeyword */ : 142 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -39668,21 +42268,20 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 151 /* TypeParameter */); - return decl && ts.getEffectiveConstraintOfTypeParameter(decl); + return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { var inferences; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 180 /* 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 === 165 /* TypeReference */) { + if (grandParent.kind === 168 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -39707,7 +42306,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 === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -39731,7 +42330,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -39764,8 +42363,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -39780,7 +42379,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -39789,16 +42388,38 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; + return type; + } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4 /* Reference */, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; return type; } + function getTypeArguments(type) { + if (!type.resolvedTypeArguments) { + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -39808,13 +42429,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -39822,10 +42443,13 @@ var ts; return errorType; } } + if (node.kind === 168 /* TypeReference */ && isAliasedType(node)) { + return createDeferredTypeReference(type, node, /*mapper*/ undefined); + } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -39846,27 +42470,27 @@ var ts; * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -39877,34 +42501,22 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning) { + function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { if (!typeReferenceName) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning) || unknownSymbol; + return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); } - // JS enums are 'string' or 'number', not an enum type. - var enumTag = ts.isInJSFile(node) && symbol.valueDeclaration && ts.getJSDocEnumTag(symbol.valueDeclaration); - if (enumTag) { - var links = getNodeLinks(enumTag); - if (!pushTypeResolution(enumTag, 5 /* EnumTagType */)) { - return errorType; - } - var type_4 = enumTag.typeExpression ? getTypeFromTypeNode(enumTag.typeExpression) : errorType; - if (!popTypeResolution()) { - type_4 = errorType; - error(node, ts.Diagnostics.Enum_type_0_circularly_references_itself, symbolToString(symbol)); - } - return (links.resolvedEnumType = type_4); + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -39913,55 +42525,31 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 67220415 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSAlias(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 67897832 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value imported from commonjs. + * These should really be aliases, but this special-case code fakes alias resolution + * by producing a type from a value. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); - } + function getTypeFromJSAlias(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType.symbol && + valueType.symbol !== symbol && // Make sure this is a commonjs export by checking that symbol -> type -> symbol doesn't roundtrip. + getTypeReferenceType(node, valueType.symbol); + if (typeType) { + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } } function getSubstitutionType(typeVariable, substitute) { @@ -39980,7 +42568,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 174 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -39989,9 +42577,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 297 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 301 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 179 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40002,7 +42590,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 168 /* TypeReference */ || node.kind === 187 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40039,10 +42627,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40054,7 +42642,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40067,10 +42655,19 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - var meaning = 67897832 /* Type */; + var meaning = 788968 /* Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); - meaning |= 67220415 /* Value */; + if (!type) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + if (symbol === unknownSymbol) { + symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + } + type = getTypeReferenceType(node, symbol); + } } if (!type) { symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); @@ -40103,9 +42700,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return declaration; } } @@ -40125,10 +42722,10 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67220415 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 67897832 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { // Don't track references for global symbols anyway, so value if `isReference` is arbitrary @@ -40197,7 +42794,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 67897832 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -40224,15 +42821,55 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 /* ArrayType */ || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176 /* RestType */) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 /* OptionalType */ && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); + } + // Return true when the given node is transitively contained in type constructs that eagerly + // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments + // of type aliases are eagerly resolved. + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181 /* ParenthesizedType */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 184 /* IndexedAccessType */: + case 179 /* ConditionalType */: + case 183 /* TypeOperator */: + return isAliasedType(parent); + case 246 /* TypeAliasDeclaration */: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 /* TupleType */ && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, /*mapper*/ undefined); + } + else { + var elementTypes = node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 137 /* ReadonlyKeyword */; } // We represent tuple types as type references to synthesized generic interface types created by // this function. The types are of the form: @@ -40269,7 +42906,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -40303,27 +42940,13 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* 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; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { // don't slice off rest element index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -40372,8 +42995,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -40402,8 +43025,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -40488,10 +43111,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { continue; } if (first) { @@ -40510,14 +43133,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } // This function assumes the constituent type list is sorted and deduplicated. function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { @@ -40584,8 +43203,8 @@ var ts; // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -40623,6 +43242,15 @@ var ts; } return true; } + function extractIrreducible(types, flag) { + if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); + } + return true; + } + return false; + } // If the given list of types contains more than one union of primitive types, replace the // first with a union containing an intersection of those primitive types, then remove the // other unions and return true. Otherwise, do nothing and return false. @@ -40741,6 +43369,12 @@ var ts; // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } + else if (extractIrreducible(typeSet, 32768 /* Undefined */)) { + result = getUnionType([getIntersectionType(typeSet), undefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } + else if (extractIrreducible(typeSet, 65536 /* Null */)) { + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + } else { // 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. @@ -40845,20 +43479,22 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130 /* KeyOfKeyword */: + case 133 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 140 /* SymbolKeyword */ + case 146 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 143 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -40894,7 +43530,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -40905,13 +43541,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 103 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -41042,13 +43678,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 184 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 153 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41173,7 +43806,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 !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41385,7 +44018,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 67220415 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 67220415 /* Value */ | 67897832 /* Type */ : 67897832 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41408,14 +44041,14 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 67220415 /* Value */ + var errorMessage = targetMeaning === 111551 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -41424,16 +44057,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 67220415 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + if (meaning === 111551 /* Value */) { + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41457,7 +44090,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host)) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -41646,12 +44283,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -41664,89 +44315,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 124 /* AnyKeyword */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return anyType; - case 144 /* UnknownKeyword */: + case 147 /* UnknownKeyword */: return unknownType; - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return stringType; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return numberType; - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return bigintType; - case 124 /* BooleanKeyword */: + case 127 /* BooleanKeyword */: return booleanType; - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return esSymbolType; - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return voidType; - case 142 /* UndefinedKeyword */: + case 145 /* UndefinedKeyword */: return undefinedType; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullType; - case 133 /* NeverKeyword */: + case 136 /* NeverKeyword */: return neverType; - case 137 /* ObjectKeyword */: - return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 140 /* ObjectKeyword */: + return node.flags & 131072 /* JavaScriptFile */ ? anyType : nonPrimitiveType; + case 182 /* ThisType */: + case 103 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: - return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 167 /* TypePredicate */: + return node.assertsModifier ? voidType : booleanType; + case 215 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + return getTypeFromArrayOrTupleTypeNode(node); + case 175 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 181 /* ParenthesizedType */: + case 296 /* JSDocNonNullableType */: + case 292 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 298 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 299 /* JSDocSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 180 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 187 /* 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 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -41835,20 +44486,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1 /* Identifier */, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0 /* This */, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -41902,17 +44540,17 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -41928,7 +44566,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -41941,13 +44579,14 @@ var ts; // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -41955,8 +44594,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 152 /* QualifiedName */ || + node.parent.kind === 168 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -41965,7 +44605,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 /* Block */ || n.kind === 179 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -41974,12 +44614,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 182 /* ThisType */: return !!tp.isThisType; - case 73 /* Identifier */: + case 75 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42033,7 +44673,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -42129,15 +44769,18 @@ var ts; // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32 /* Mapped */) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4 /* Reference */) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -42201,35 +44844,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: - return node.operatorToken.kind === 55 /* BarBarToken */ && + case 208 /* BinaryExpression */: + return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 271 /* 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 271 /* JsxExpression */: { + case 274 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42249,7 +44892,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* 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); @@ -42261,7 +44904,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42364,23 +45007,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 274 /* JsxExpression */: + case 199 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -42552,7 +45195,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -42561,9 +45204,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -42637,7 +45280,7 @@ var ts; var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName); var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName)); var diagnostic = ts.Diagnostics._0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2; - invalidTextDiagnostic = __assign({}, diagnostic, { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); + invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(/*_dummy*/ undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) }); } return invalidTextDiagnostic; } @@ -42705,11 +45348,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 163 /* SetAccessor */: return [3 /*break*/, 2]; + case 162 /* GetAccessor */: return [3 /*break*/, 2]; + case 160 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 280 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 279 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -42744,7 +45387,7 @@ var ts; } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { return compareSignaturesRelated(source, target, 0 /* None */, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -42757,7 +45400,7 @@ var ts; /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -42781,8 +45424,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 /* MethodDeclaration */ && + kind !== 159 /* MethodSignature */ && kind !== 161 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -42815,11 +45458,11 @@ var ts; // with respect to T. var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (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) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -42830,15 +45473,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(target.declaration.symbol) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(source.declaration.symbol) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -42859,6 +45504,9 @@ var ts; // wouldn't be co-variant for T without this rule. result &= callbackCheck === 1 /* Bivariant */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -42871,7 +45519,7 @@ var ts; } return 0 /* False */; } - if (source.kind === 1 /* Identifier */) { + if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -42880,7 +45528,9 @@ var ts; return 0 /* False */; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -42926,12 +45576,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { - return relation === 1 /* Succeeded */; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { + return !!(entry & 1 /* Succeeded */); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -42942,7 +45592,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); } else { enumRelation.set(id, 2 /* Failed */); @@ -43021,7 +45671,7 @@ var ts; if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { - return related === 1 /* Succeeded */; + return !!(related & 1 /* Succeeded */); } } if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { @@ -43053,9 +45703,14 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -43085,7 +45740,7 @@ var ts; } var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation); if (relatedInfo) { - ts.addRelatedInfo.apply(void 0, [diag].concat(relatedInfo)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo)); } if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -43098,8 +45753,131 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0 /* False */; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; // Suppress the next relation error + lastSkippedInfo = undefined; // Reset skipped info cache + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + return; + } + // The first error will be the innermost, while the last will be the outermost - so by popping off the end, + // we can build from left to right + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + // Parenthesize a `new` if there is one + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + // If leading, just print back the arg (irrespective of if it's a valid identifier) + if (path.length === 0) { + path = "" + str; + } + // Otherwise write a dotted name if possible + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + // Failing that, check if the name is already a computed name + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + // And finally write out a computed name as a last resort + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + // Don't flatten signature compatability errors at the start of a chain - instead prefer + // to unify (the with no arguments bit is excessive for printback) and print them back + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + // Remove the innermost secondary error as it will duplicate the error already reported by `reportRelationError` on entry + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; // Teporarily override elision to ensure error is reported + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -43112,6 +45890,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 /* TypeParameter */ && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -43130,8 +45910,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43224,7 +46004,7 @@ var ts; isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isPerformingExcessPropertyChecks = !isApparentIntersectionConstituent && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { var discriminantType = target.flags & 1048576 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { @@ -43234,11 +46014,11 @@ var ts; return 0 /* False */; } } - if (relation !== comparableRelation && !isApparentIntersectionConstituent && + var isPerformingCommonPropertyChecks = 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, isComparingJsxAttributes)) { + (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); + if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); @@ -43253,23 +46033,23 @@ var ts; return 0 /* False */; } var result = 0 /* False */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); 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 & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { if (target.flags & 1048576 /* Union */) { result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` var discriminantType = findMatchingDiscriminantType(source, target) || filterPrimitivesIfContainsNonPrimitive(target); - if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, discriminantType, reportErrors, /*excludedProperties*/ undefined, isIntersectionConstituent)) { return 0 /* False */; } } @@ -43277,9 +46057,9 @@ var ts; else if (target.flags & 2097152 /* Intersection */) { isIntersectionConstituent = true; // set here to affect the following trio of checks result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors); - if (result && isPerformingExcessPropertyChecks) { + if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined)) { + if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, /*isIntersectionConstituent*/ false)) { return 0 /* False */; } } @@ -43298,15 +46078,15 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); } if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152 /* Intersection */) { + if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) { // 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 @@ -43316,21 +46096,30 @@ 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 & 1048576 /* Union */)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) { + if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { @@ -43350,6 +46139,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } @@ -43386,7 +46176,7 @@ var ts; // check excess properties against discriminant type only, not the entire union return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -43401,6 +46191,11 @@ var ts; // 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) + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + // Note that extraneous children (as in `extra`) don't pass this check, + // since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute. + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -43429,9 +46224,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -43567,14 +46362,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors) { + function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { return related; } @@ -43594,7 +46389,7 @@ var ts; } return result; } - function typeArgumentsRelatedTo(sources, targets, variances, reportErrors) { + function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, isIntersectionConstituent) { if (sources === void 0) { sources = ts.emptyArray; } if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } @@ -43621,10 +46416,10 @@ var ts; related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t); } else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, reportErrors); + related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } else if (variance === 3 /* Bivariant */) { // In the bivariant case we first compare contravariantly without reporting @@ -43633,16 +46428,16 @@ var ts; // which is generally easier to reason about. related = isRelatedTo(t, s, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, reportErrors); + related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); if (related) { - related &= isRelatedTo(t, s, reportErrors); + related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } if (!related) { @@ -43653,17 +46448,6 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8 /* Unmeasurable */) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16 /* Unreliable */) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -43674,24 +46458,24 @@ var ts; return 0 /* False */; } var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2 /* Failed */) { + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24 /* ReportsMask */; + if (saved & 8 /* ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16 /* ReportsUnreliable */) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; } } if (!maybeKeys) { @@ -43722,14 +46506,26 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 /* True */ || depth === 0) { // If result is definitely true, record all maybe keys as having succeeded for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */); + relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); } maybeCount = maybeStart; } @@ -43737,7 +46533,7 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); + relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -43777,7 +46573,7 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); // 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. @@ -43785,7 +46581,7 @@ var ts; source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { var variances = getAliasVariances(source.aliasSymbol); - var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43867,7 +46663,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -43878,7 +46674,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43887,25 +46683,25 @@ var ts; if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43914,13 +46710,23 @@ var ts; // 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. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43929,14 +46735,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43950,7 +46756,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -43969,7 +46775,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); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -43996,8 +46802,8 @@ var ts; // relates to X. Thus, we include intersection types on the source side here. 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, /*excludedProperties*/ undefined); + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; + result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); if (result) { @@ -44011,7 +46817,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; // Use variance error (there is no structural one) and return false } else if (result) { return result; @@ -44032,8 +46838,8 @@ var ts; } } return 0 /* False */; - function relateVariances(sourceTypeArguments, targetTypeArguments, variances) { - if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + function relateVariances(sourceTypeArguments, targetTypeArguments, variances, isIntersectionConstituent) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, isIntersectionConstituent)) { return result; } if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { @@ -44042,7 +46848,7 @@ var ts; // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially // be assuming identity of the type parameter. originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -44070,7 +46876,7 @@ var ts; // comparison unexpectedly succeeds. This can happen when the structural comparison result // is a Ternary.Maybe for example caused by the recursion depth limiter. originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44146,11 +46952,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) @@ -44158,7 +46964,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, /*isIntersectionConstituent*/ false); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -44166,8 +46972,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -44180,15 +46986,15 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, /*isIntersectionConstituent*/ false); if (result) { result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); if (result) { @@ -44223,7 +47029,7 @@ var ts; } return result || properties; } - function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); var source = getTypeOfSourceProperty(sourceProp); if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { @@ -44263,10 +47069,10 @@ var ts; return result_7; } else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); + return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, isIntersectionConstituent); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -44304,10 +47110,10 @@ var ts; return 0 /* False */; } // If the target comes from a partial union prop, allow `undefined` in the target type - var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors); + var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0 /* False */; } @@ -44327,7 +47133,7 @@ var ts; } return related; } - function propertiesRelatedTo(source, target, reportErrors, excludedProperties) { + function propertiesRelatedTo(source, target, reportErrors, excludedProperties, isIntersectionConstituent) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } @@ -44343,12 +47149,12 @@ var ts; } if (props.length === 1) { var propName = symbolToString(unmatchedProperty); - reportError.apply(void 0, [ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName].concat(getTypeNamesForErrorDisplay(source, target))); + reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target))); if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) { @@ -44358,8 +47164,8 @@ var ts; 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(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined) @@ -44371,7 +47177,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -44396,8 +47202,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -44411,12 +47218,14 @@ var ts; // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members var properties = target.flags & 1048576 /* Union */ ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304 /* Prototype */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { return 0 /* False */; } @@ -44479,14 +47288,15 @@ var ts; } } var result = -1 /* True */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 /* Instantiated */ && ts.getObjectFlags(target) & 64 /* Instantiated */ && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters // as they are known to always be the same. for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0 /* False */; } @@ -44500,7 +47310,7 @@ var ts; // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -44509,10 +47319,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -44525,11 +47335,23 @@ var ts; } return result; } + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } /** * See signatureAssignableTo, compareSignaturesIdentical */ - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -44595,7 +47417,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -44651,23 +47473,27 @@ var ts; } } function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { - var match; + // undefined=unknown, true=discriminated, false=not discriminated + // The state of each type progresses from left to right. Discriminated types stop at 'true'. + var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, propertyName); if (targetType && related(getDiscriminatingType(), targetType)) { - if (match) { - if (type === match) - continue; // Finding multiple fields which discriminate to the same type is fine - return defaultValue; - } - match = type; + discriminable[i] = discriminable[i] === undefined ? true : discriminable[i]; + } + else { + discriminable[i] = false; } + i++; } } - return match || defaultValue; + var match = discriminable.indexOf(/*searchElement*/ true); + // make sure exactly 1 matches before returning it + return match === -1 || discriminable.indexOf(/*searchElement*/ true, match + 1) !== -1 ? defaultValue : target.types[match]; } /** * A type is 'weak' if it is an object type with at least one optional property @@ -44723,7 +47549,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -44755,7 +47581,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -44781,8 +47607,11 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -44791,7 +47620,7 @@ var ts; function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -44870,6 +47699,9 @@ var ts; // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 // levels, but unequal at some level beyond that. + // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially + // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives + // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`). 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 & 524288 /* Object */) { @@ -44886,8 +47718,30 @@ var ts; } } } + if (depth >= 5 && type.flags & 8388608 /* IndexedAccess */) { + var root = getRootObjectTypeFromIndexedAccessChain(type); + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (getRootObjectTypeFromIndexedAccessChain(t) === root) { + count++; + if (count >= 5) + return true; + } + } + } return false; } + /** + * Gets the leftmost object type in a chain of indexed accesses, eg, in A[P][Q], returns A + */ + function getRootObjectTypeFromIndexedAccessChain(type) { + var t = type; + while (t.flags & 8388608 /* IndexedAccess */) { + t = t.objectType; + } + return t; + } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; } @@ -44995,20 +47849,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - // If they're both type predicates their return types will both be `boolean`, so no need to compare those. - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : + source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type) : + 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -45047,7 +47903,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, @@ -45055,7 +47911,7 @@ var ts; return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -45139,7 +47995,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -45154,8 +48010,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -45220,6 +48076,41 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, function (t) { return t !== optionalType; }) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function createPooledOptionalTypeResult(isOptional, type) { + pooledOptionalTypeResult.isOptional = isOptional; + pooledOptionalTypeResult.type = type; + return pooledOptionalTypeResult; + } + function checkOptionalExpression(parent, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + var isOptional = false; + var type = checkExpression(expression); + if (ts.isOptionalChain(parent)) { + if (parent.questionDotToken) { + // If we have a questionDotToken then we are an OptionalExpression and should remove `null` and + // `undefined` from the type and add the optionalType to the result, if needed. + isOptional = isNullableType(type); + return createPooledOptionalTypeResult(isOptional, isOptional ? getNonNullableType(type) : type); + } + // If we do not have a questionDotToken, then we are an OptionalChain and we remove the optionalType and + // indicate whether we need to add optionalType back into the result. + var nonOptionalType = removeOptionalTypeMarker(type); + if (nonOptionalType !== type) { + isOptional = true; + type = nonOptionalType; + } + } + type = checkNonNullType(type, expression, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + return createPooledOptionalTypeResult(isOptional, type); + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -45249,8 +48140,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45402,7 +48293,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -45439,7 +48330,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -45469,17 +48360,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 208 /* BinaryExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* 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 152 /* Parameter */: + case 155 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 67897832 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); @@ -45489,23 +48380,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -45519,7 +48410,7 @@ var ts; wideningKind === 1 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182 /* MappedType */: + case 185 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -45561,8 +48452,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 /* This */ || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -45631,6 +48521,12 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } @@ -45640,10 +48536,10 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & 32 /* Mapped */ || - type.flags & 3145728 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { @@ -45709,10 +48605,10 @@ 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, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), 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.readonly, source.target.associatedNames); @@ -45798,8 +48694,7 @@ var ts; var visited; var bivariant = false; var propagationType; - var inferenceCount = 0; - var inferenceIncomplete = false; + var inferencePriority = 256 /* MaxValue */; var allowComplexConstraintInference = true; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { @@ -45822,50 +48717,57 @@ var ts; inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); return; } - 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) { - for (var _i = 0, _a = source.types; _i < _a.length; _i++) { - var t = _a[_i]; - inferFromTypes(t, t); - } - return; - } - // Find each source constituent type that has an identically matching target constituent - // type, and for each such type infer from the type to itself. When inferring from a - // type to itself we effectively find all type parameter occurrences within that type - // and infer themselves as their type arguments. We have special handling for numeric - // and string literals because the number and string types are not represented as unions - // of all their possible values. - var matchingTypes = void 0; - for (var _b = 0, _c = source.types; _b < _c.length; _b++) { - var t = _c[_b]; - var matched = findMatchedType(t, target); - if (matched) { - (matchingTypes || (matchingTypes = [])).push(matched); - inferFromTypes(matched, matched); - } - } - // Next, to improve the quality of inferences, reduce the source and target types by - // removing the identically matched constituents. For example, when inferring from - // 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'. - if (matchingTypes) { - var s = removeTypesFromUnionOrIntersection(source, matchingTypes); - var t = removeTypesFromUnionOrIntersection(target, matchingTypes); - if (!(s && t)) - return; - source = s; - target = t; + if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + // When source and target are the same union or intersection type, just relate each constituent + // type to itself. + for (var _i = 0, _a = source.types; _i < _a.length; _i++) { + var t = _a[_i]; + inferFromTypes(t, t); } + return; } - else if (target.flags & 1048576 /* Union */ && !(target.flags & 1024 /* EnumLiteral */) || target.flags & 2097152 /* Intersection */) { - var matched = findMatchedType(source, target); - if (matched) { - inferFromTypes(matched, matched); + if (target.flags & 1048576 /* Union */) { + // First, infer between identically matching source and target constituents and remove the + // matching types. + var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + // Next, infer between closely matching source and target constituents and remove + // the matching types. Types closely match when they are instantiations of the same + // object type or instantiations of the same type alias. + var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1]; + if (targets.length === 0) { + return; + } + target = getUnionType(targets); + if (sources.length === 0) { + // All source constituents have been matched and there is nothing further to infer from. + // However, simply making no inferences is undesirable because it could ultimately mean + // inferring a type parameter constraint. Instead, make a lower priority inference from + // the full source to whatever remains in the target. For example, when inferring from + // string to 'string | T', make a lower priority inference of string for T. + var savePriority = priority; + priority |= 1 /* NakedTypeVariable */; + inferFromTypes(source, target); + priority = savePriority; return; } + source = getUnionType(sources); + } + else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + // We reduce intersection types only when they contain naked type parameters. For example, when + // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and + // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the + // string[] on the source side and infer string for T. + // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" + // in such scenarios. + if (!(source.flags & 1048576 /* Union */)) { + // Infer between identically matching source and target constituents and remove the matching types. + var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + if (sources.length === 0 || targets.length === 0) { + return; + } + source = getIntersectionType(sources); + target = getIntersectionType(targets); + } } else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { target = getActualTypeVariable(target); @@ -45910,7 +48812,7 @@ var ts; clearCachedInferences(inferences); } } - inferenceCount++; + inferencePriority = Math.min(inferencePriority, priority); return; } else { @@ -45932,9 +48834,10 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; @@ -45970,8 +48873,8 @@ var ts; else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; - for (var _d = 0, sourceTypes_3 = sourceTypes; _d < sourceTypes_3.length; _d++) { - var sourceType = sourceTypes_3[_d]; + for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { + var sourceType = sourceTypes_3[_e]; inferFromTypes(sourceType, target); } } @@ -46001,15 +48904,36 @@ var ts; } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; - var count = visited && visited.get(key); - if (count !== undefined) { - inferenceCount += count; + var status = visited && visited.get(key); + if (status !== undefined) { + inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = ts.createMap())).set(key, 0); - var startCount = inferenceCount; + (visited || (visited = ts.createMap())).set(key, -1 /* Circularity */); + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; action(source, target); - visited.set(key, inferenceCount - startCount); + visited.set(key, inferencePriority); + inferencePriority = Math.min(inferencePriority, saveInferencePriority); + } + function inferFromMatchingTypes(sources, targets, matches) { + var matchedSources; + var matchedTargets; + for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { + var t = targets_1[_i]; + for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) { + var s = sources_1[_a]; + if (matches(s, t)) { + inferFromTypes(s, t); + matchedSources = ts.appendIfUnique(matchedSources, s); + matchedTargets = ts.appendIfUnique(matchedTargets, t); + } + } + } + return [ + matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources, + matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets, + ]; } function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; @@ -46049,31 +48973,34 @@ var ts; var nakedTypeVariable = void 0; var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); - var saveInferenceIncomplete = inferenceIncomplete; - inferenceIncomplete = false; + var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we - // track whether inferences were made from that particular type to some target. - for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) { - var t = targets_1[_i]; + // track whether inferences were made from that particular type to some target with + // equal priority (i.e. of equal quality) to what we would infer for a naked type + // parameter. + for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) { + var t = targets_2[_i]; if (getInferenceInfoForType(t)) { nakedTypeVariable = t; typeVariableCount++; } else { for (var i = 0; i < sources.length; i++) { - var count = inferenceCount; + var saveInferencePriority = inferencePriority; + inferencePriority = 256 /* MaxValue */; inferFromTypes(sources[i], t); - if (count !== inferenceCount) + if (inferencePriority === priority) matched_1[i] = true; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } } - var inferenceComplete = !inferenceIncomplete; - inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete; - // If the target has a single naked type variable and inference completed (meaning we - // explored the types fully), create a union of the source types from which no inferences - // have been made so far and infer from that union to the naked type variable. - if (typeVariableCount === 1 && inferenceComplete) { + // If the target has a single naked type variable and no inference circularities were + // encountered above (meaning we explored the types fully), create a union of the source + // types from which no inferences have been made so far and infer from that union to the + // naked type variable. + if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { inferFromTypes(getUnionType(unmatched), nakedTypeVariable); @@ -46085,8 +49012,8 @@ var ts; // We infer from types that are not naked type variables first so that inferences we // make from nested naked type variables and given slightly higher priority by virtue // of being first in the candidates array. - for (var _a = 0, targets_2 = targets; _a < targets_2.length; _a++) { - var t = targets_2[_a]; + for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) { + var t = targets_3[_a]; if (getInferenceInfoForType(t)) { typeVariableCount++; } @@ -46102,8 +49029,8 @@ var ts; if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { var savePriority = priority; priority |= 1 /* NakedTypeVariable */; - for (var _b = 0, targets_3 = targets; _b < targets_3.length; _b++) { - var t = targets_3[_b]; + for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { + var t = targets_4[_b]; if (getInferenceInfoForType(t)) { inferFromTypes(source, t); } @@ -46177,7 +49104,7 @@ var ts; var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { if (ts.contains(symbolStack, symbol)) { - inferenceIncomplete = true; + inferencePriority = -1 /* Circularity */; return; } (symbolStack || (symbolStack = [])).push(symbol); @@ -46189,6 +49116,11 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + // If source and target are references to the same generic type, infer from type arguments + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } 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 // from S to T and from X to Y. @@ -46218,10 +49150,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -46261,7 +49193,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 === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 160 /* MethodDeclaration */ || kind === 159 /* MethodSignature */ || kind === 161 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46287,46 +49219,12 @@ var ts; } } } - function isMatchableType(type) { - // We exclude non-anonymous object types because some frameworks (e.g. Ember) rely on the ability to - // infer between types that don't witness their type variables. Such types would otherwise be eliminated - // because they appear identical. - return !(type.flags & 524288 /* Object */) || !!(ts.getObjectFlags(type) & 16 /* Anonymous */); - } - function typeMatchedBySomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; - if (t === type || isMatchableType(t) && isMatchableType(type) && isTypeIdenticalTo(t, type)) { - return true; - } - } - return false; - } - function findMatchedType(type, target) { - if (typeMatchedBySomeType(type, target.types)) { - return type; - } - if (type.flags & (256 /* NumberLiteral */ | 128 /* StringLiteral */) && target.flags & 1048576 /* Union */) { - var base = getBaseTypeOfLiteralType(type); - if (typeMatchedBySomeType(base, target.types)) { - return base; - } - } - return undefined; + function isTypeOrBaseIdenticalTo(s, t) { + return isTypeIdenticalTo(s, t) || !!(s.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); } - /** - * Return a new union or intersection type computed by removing a given set of types - * from a given union or intersection type. - */ - function removeTypesFromUnionOrIntersection(type, typesToRemove) { - var reducedTypes = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; - if (!typeMatchedBySomeType(t, typesToRemove)) { - reducedTypes.push(t); - } - } - return reducedTypes.length ? type.flags & 1048576 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined; + function isTypeCloselyMatchedBy(s, t) { + return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); @@ -46465,7 +49363,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46477,7 +49375,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; @@ -46486,7 +49384,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 === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 /* TypeQuery */ ? true : n.kind === 75 /* Identifier */ || n.kind === 152 /* 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 @@ -46496,16 +49394,16 @@ var ts; // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46516,24 +49414,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73 /* Identifier */: - return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + case 75 /* Identifier */: + return target.kind === 75 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 /* VariableDeclaration */ || target.kind === 190 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 101 /* ThisKeyword */: - return target.kind === 101 /* ThisKeyword */; - case 99 /* SuperKeyword */: - return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 103 /* ThisKeyword */: + return target.kind === 103 /* ThisKeyword */; + case 101 /* SuperKeyword */: + return target.kind === 101 /* SuperKeyword */; + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -46541,8 +49439,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 /* PropertyAccessExpression */ ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -46566,7 +49464,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73 /* Identifier */) { + if (expr.kind === 75 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -46597,7 +49495,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -46625,14 +49523,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 193 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -46674,8 +49572,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -46780,15 +49678,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 208 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 231 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -46805,21 +49703,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -46827,7 +49725,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -46845,37 +49743,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 230 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 231 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 241 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 241 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 190 /* BindingElement */ && node.parent.kind === 208 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -46885,13 +49778,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 199 /* ParenthesizedExpression */ || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -46913,8 +49806,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { - if (clause.expression.kind === 10 /* StringLiteral */) { + if (clause.kind === 275 /* CaseClause */) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -46997,8 +49890,7 @@ var ts; return mapType(typeWithPrimitives, function (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; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47050,8 +49942,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47074,33 +49966,78 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 193 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 195 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 60 /* EqualsToken */ && + parent.parent.kind === 208 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 /* VariableDeclaration */ || declaration.kind === 155 /* Parameter */ || + declaration.kind === 158 /* PropertyDeclaration */ || declaration.kind === 157 /* PropertySignature */) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99 /* SuperKeyword */) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + // We require the dotted function name in an assertion expression to be comprised of identifiers + // that reference function, method, class or value module symbols; or variable, property or + // parameter symbols with declarations that have explicit type annotations. Such references are + // resolvable with no possibility of triggering circularities in control flow analysis. + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216 /* InWithStatement */)) { + switch (node.kind) { + case 75 /* Identifier */: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 103 /* ThisKeyword */: + return getExplicitThisType(node); + case 193 /* PropertyAccessExpression */: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199 /* ParenthesizedExpression */: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + // A call expression parented by an expression statement is a potential assertion. Other call + // expressions are potential type predicate function calls. In order to avoid triggering + // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call + // target expression of an assertion. + var funcType = node.parent.kind === 225 /* ExpressionStatement */ ? getTypeOfDottedName(node.expression, /*diagnostic*/ undefined) : + node.expression.kind !== 101 /* SuperKeyword */ ? checkOptionalExpression(node, node.expression).type : + undefined; + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -47108,6 +50045,68 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 /* PreFinally */ && flow.lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048 /* Shared */) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + } + noCacheCheck = false; + } + if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 4096 /* PreFinally */)) { + flow = flow.antecedent; + } + else if (flags & 512 /* Call */) { + var signature = getEffectsSignature(flow.node); + if (signature && getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 4 /* BranchLabel */) { + // A branching point is reachable if any branch is reachable. + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8 /* LoopLabel */) { + // A loop is reachable if the control flow path that leads to the top is reachable. + flow = flow.antecedents[0]; + } + else if (flags & 128 /* SwitchClause */) { + // The control flow path representing an unmatched value in a switch statement with + // no default clause is unreachable if the switch statement is exhaustive. + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192 /* AfterFinally */) { + // Cache is unreliable once we start locking nodes + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, /*skipCacheCheck*/ false); + flow.locked = false; + return result; + } + else { + return !(flags & 1 /* Unreachable */); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -47119,6 +50118,7 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; @@ -47127,7 +50127,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47149,16 +50149,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192 /* Cached */) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -47170,13 +50161,13 @@ var ts; } } var type = void 0; - if (flags & 4096 /* AfterFinally */) { + if (flags & 8192 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048 /* PreFinally */) { + else if (flags & 4096 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; @@ -47188,14 +50179,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192 /* Cached */; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512 /* Call */) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96 /* Condition */) { @@ -47222,11 +50211,11 @@ var ts; } else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && - reference.kind !== 101 /* ThisKeyword */) { + reference.kind !== 193 /* PropertyAccessExpression */ && + reference.kind !== 194 /* ElementAccessExpression */ && + reference.kind !== 103 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -47238,7 +50227,7 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // Record visited node and the associated type in the cache. sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; @@ -47248,11 +50237,34 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384 /* Cached */) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */ ? + getInitialType(node) : + getAssignedType(node), reference); + // We cache the assigned type when getFlowTypeOfReference was recursively invoked in the + // resolution of the assigned type and we're not within loop analysis. + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384 /* Cached */; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -47261,11 +50273,11 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } @@ -47274,27 +50286,60 @@ var ts; // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } // A matching dotted name might also be an expando property on a function *expression*, // 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 === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 200 /* FunctionExpression */ || init.kind === 201 /* 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 === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 208 /* BinaryExpression */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56 /* BarBarToken */) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, /*assumeTrue*/ true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : + predicate.kind === 3 /* AssertsIdentifier */ ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 195 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47302,7 +50347,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47337,7 +50382,7 @@ var ts; // *only* place a silent never type is ever generated. var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -47355,12 +50400,15 @@ 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 === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else if (containsMatchingReferenceDiscriminant(reference, expr)) { type = declaredType; } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } return createFlowType(type, isIncomplete(flowType)); } function getTypeAtFlowBranchLabel(flow) { @@ -47369,7 +50417,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + if (antecedent.flags & 4096 /* PreFinally */ && antecedent.lock.locked) { // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. @@ -47429,25 +50477,32 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + // The first antecedent of a loop junction is always the non-looping control + // flow path that leads to the top. + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - // If we see a value appear in the cache it is a sign that control flow analysis - // was restarted and completed by checkExpressionCached. We can simply pick up - // the resulting type and bail out. - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + // All but the first antecedent are the looping control flow paths that lead + // back to the loop junction. We track these on the flow loop stack. + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + // If we see a value appear in the cache it is a sign that control flow analysis + // was restarted and completed by checkExpressionCached. We can simply pick up + // the resulting type and bail out. + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control @@ -47521,19 +50576,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -47552,9 +50607,9 @@ var ts; return declaredType; } break; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94 /* InKeyword */: + case 96 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -47569,11 +50624,11 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && (operator === 35 /* EqualsEqualsEqualsToken */) && assumeTrue) { + if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { return valueType; } @@ -47586,7 +50641,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? @@ -47598,7 +50653,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* EqualsEqualsToken */ ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -47611,7 +50666,7 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // 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 @@ -47621,7 +50676,7 @@ var ts; } return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (type.flags & 1 /* Any */ && literal.text === "function") { @@ -47848,22 +50903,24 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { return type; } - if (ts.isIdentifierTypePredicate(predicate)) { + if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { var predicateArgument = callExpression.arguments[predicate.parameterIndex]; - if (predicateArgument) { + if (predicateArgument && predicate.type) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } @@ -47874,7 +50931,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { + if (ts.isAccessExpression(invokedExpression) && predicate.type) { var possibleReference = ts.skipParentheses(invokedExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -47889,27 +50946,44 @@ var ts; // Narrow the given type based on the given expression having the assumed boolean value. The returned type // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { + // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` + if (ts.isOptionalChainRoot(expr.parent) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 195 /* CallExpression */: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: - if (expr.operator === 52 /* ExclamationToken */) { + case 206 /* PrefixUnaryExpression */: + if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; @@ -47917,7 +50991,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 === 73 /* Identifier */) { + if (location.kind === 75 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -47938,9 +51012,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 249 /* ModuleBlock */ || + node.kind === 288 /* SourceFile */ || + node.kind === 158 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -47959,10 +51033,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 === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155 /* Parameter */) { symbol.isAssigned = true; } } @@ -47977,7 +51051,7 @@ 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 === 152 /* Parameter */ && + declaration.kind === 155 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -47985,10 +51059,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 193 /* PropertyAccessExpression */ || + parent.kind === 195 /* CallExpression */ && parent.expression === node || + parent.kind === 194 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 190 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48003,8 +51077,11 @@ var ts; } return type; } + function isExportOrExportExpression(location) { + return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */) && !isInTypeQuery(location) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && ((compilerOptions.preserveConstEnums && isExportOrExportExpression(location)) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol)))) { markAliasSymbolAsReferenced(symbol); } } @@ -48022,7 +51099,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* 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 */)) { @@ -48043,7 +51120,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 === 241 /* ClassDeclaration */ + if (declaration.kind === 244 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48055,14 +51132,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 213 /* 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 !== 285 /* SourceFile */) { + while (container.kind !== 288 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 158 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48111,7 +51188,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 === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 155 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48120,8 +51197,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 === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 /* FunctionExpression */ || + flowContainer.kind === 201 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48129,11 +51206,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 4194304 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261 /* ExportSpecifier */) || + node.parent.kind === 217 /* NonNullExpression */ || + declaration.kind === 241 /* VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -48167,7 +51244,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 278 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48190,7 +51267,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, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48208,8 +51285,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 === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 229 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48227,7 +51304,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 199 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48235,9 +51312,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 206 /* PrefixUnaryExpression */ || current.parent.kind === 207 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -48248,7 +51325,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 158 /* PropertyDeclaration */ || container.kind === 161 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48316,37 +51393,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 161 /* 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 === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* 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 244 /* EnumDeclaration */: + case 247 /* 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 158 /* Constructor */: + case 161 /* 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 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* 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 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48385,10 +51462,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48396,12 +51471,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 200 /* FunctionExpression */ || container.kind === 243 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48430,9 +51503,22 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 200 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48442,16 +51528,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 160 /* MethodDeclaration */ && + container.parent.kind === 192 /* 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 === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && + container.parent.kind === 279 /* PropertyAssignment */ && + container.parent.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48459,7 +51545,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 197 /* FunctionExpression */ && + else if (container.kind === 200 /* 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") && @@ -48484,7 +51570,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 298 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48498,15 +51584,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 /* 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 === 198 /* ArrowFunction */) { + while (container && container.kind === 201 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48519,14 +51605,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153 /* ComputedPropertyName */; }); + if (current && current.kind === 153 /* 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 === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -48534,7 +51620,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 161 /* 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) { @@ -48603,7 +51689,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 === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 160 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -48617,7 +51703,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 192 /* 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; @@ -48638,7 +51724,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 /* 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; @@ -48653,7 +51739,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 === 158 /* Constructor */; + return container.kind === 161 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -48661,21 +51747,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 === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */ || + container.kind === 158 /* PropertyDeclaration */ || + container.kind === 157 /* PropertySignature */ || + container.kind === 161 /* Constructor */; } } } @@ -48683,14 +51769,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 160 /* MethodDeclaration */ || + func.kind === 162 /* GetAccessor */ || + func.kind === 163 /* SetAccessor */) && func.parent.kind === 192 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 200 /* FunctionExpression */ && func.parent.kind === 279 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -48698,7 +51784,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -48725,7 +51811,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 279 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -48739,9 +51825,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 === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 193 /* PropertyAccessExpression */ || target.kind === 194 /* 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)) { @@ -48805,9 +51891,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 155 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -48897,6 +51983,15 @@ var ts; } return false; } + function getContextualIterationType(kind, functionDecl) { + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); + var contextualReturnType = getContextualReturnType(functionDecl); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) + || undefined; + } + return undefined; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed @@ -48928,7 +52023,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 197 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -48937,7 +52032,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: if (node !== right) { return undefined; } @@ -48946,7 +52041,8 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -48955,7 +52051,7 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -48983,19 +52079,22 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 67220415 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -49017,12 +52116,13 @@ var ts; } if (kind === 2 /* ModuleExports */) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -49066,7 +52166,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49155,32 +52255,35 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 73 /* Identifier */: - case 142 /* UndefinedKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 75 /* Identifier */: + case 145 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 199 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 274 /* 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 === 276 /* 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 === 279 /* 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 === 268 /* 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 === 271 /* 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, contextFlags) { - var contextualType = instantiateContextualType(getContextualType(node, contextFlags), node, contextFlags); - if (contextualType) { - var apparentType = mapType(contextualType, getApparentType, /*noReductions*/ true); + var contextualType = ts.isObjectLiteralMethod(node) ? + getContextualTypeForObjectLiteralMethod(node, contextFlags) : + getContextualType(node, contextFlags); + var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); + if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { return discriminateContextualTypeByObjectMembers(node, apparentType); @@ -49247,7 +52350,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49256,58 +52359,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 190 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 201 /* ArrowFunction */: + case 234 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: - if (parent.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (parent.expression.kind === 95 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: + case 196 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 191 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 220 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 210 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 199 /* 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, contextFlags); } - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49462,7 +52565,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 200 /* FunctionExpression */ || node.kind === 201 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49476,14 +52579,12 @@ 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 !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = ts.isObjectLiteralMethod(node) ? - getContextualTypeForObjectLiteralMethod(node, 1 /* Signature */) : - getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* Signature */); if (!type) { return undefined; } @@ -49492,8 +52593,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var current = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -49523,8 +52624,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 190 /* BindingElement */ && !!node.initializer) || + (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -49536,7 +52637,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 212 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -49561,12 +52662,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 212 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212 /* 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] = []". @@ -49608,9 +52709,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return isNumericComputedName(name); - case 73 /* Identifier */: + case 75 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -49698,7 +52799,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 188 /* ObjectBindingPattern */ || contextualType.pattern.kind === 192 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -49713,13 +52814,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 === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 279 /* PropertyAssignment */ || + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -49742,8 +52843,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 === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -49768,7 +52869,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 281 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -49794,7 +52895,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 162 /* GetAccessor */ || memberDecl.kind === 163 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -49854,7 +52955,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -49902,7 +53009,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 === 73 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -49947,7 +53054,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 273 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -49970,7 +53077,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 /* 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); @@ -50044,7 +53151,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 67897832 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -50118,7 +53225,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 67897832 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -50142,7 +53249,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 67897832 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -50294,13 +53401,13 @@ var ts; var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(node); var reactLocation = isNodeOpeningLikeElement ? node.tagName : node; - var reactSym = resolveName(reactLocation, reactNamespace, 67220415 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); + var reactSym = resolveName(reactLocation, reactNamespace, 111551 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted reactSym.isReferenced = 67108863 /* All */; - // If react symbol is alias, mark it as referenced - if (reactSym.flags & 2097152 /* Alias */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + // If react symbol is alias, mark it as refereced + if (reactSym.flags & 2097152 /* Alias */) { markAliasSymbolAsReferenced(reactSym); } } @@ -50389,7 +53496,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 152 /* QualifiedName */ ? node.right : node.kind === 187 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* 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)); @@ -50487,12 +53594,11 @@ var ts; function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); + } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { if (strictNullChecks && type.flags & 2 /* Unknown */) { @@ -50524,14 +53630,13 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + var _a = checkOptionalExpression(node, left), isOptional = _a.isOptional, leftType = _a.type; var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -50545,6 +53650,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0 /* String */) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -50572,9 +53678,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 103 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -50583,14 +53689,14 @@ var ts; } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return propagateOptionalTypeMarker(getFlowTypeOfAccessExpression(node, prop, propType, right), isOptional); } function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { // 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. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 194 /* ElementAccessExpression */ && node.kind !== 193 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -50600,11 +53706,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 && node.expression.kind === 101 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -50625,7 +53731,7 @@ var ts; } function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { var valueDeclaration = prop.valueDeclaration; - if (!valueDeclaration) { + if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) { return; } var diagnosticMessage; @@ -50635,9 +53741,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && - !(valueDeclaration.flags & 4194304 /* Ambient */) && + else if (valueDeclaration.kind === 244 /* ClassDeclaration */ && + node.parent.kind !== 168 /* TypeReference */ && + !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -50648,22 +53754,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 279 /* PropertyAssignment */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 281 /* SpreadAssignment */: + case 153 /* ComputedPropertyName */: + case 220 /* TemplateSpan */: + case 274 /* JsxExpression */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 266 /* JsxOpeningElement */: + case 215 /* ExpressionWithTypeArguments */: + case 277 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -50703,7 +53809,7 @@ var ts; 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)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -50741,7 +53847,7 @@ var ts; return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 67220415 /* Value */); + return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -50836,16 +53942,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 101 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 152 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 187 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 /* PropertyAccessExpression */ && node.expression.kind === 101 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -50862,13 +53968,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 242 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73 /* Identifier */) { + else if (initializer.kind === 75 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -50885,13 +53991,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73 /* Identifier */) { + if (e.kind === 75 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 230 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -50905,28 +54011,14 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + var _a = checkOptionalExpression(node, node.expression), isOptional = _a.isOptional, exprType = _a.type; var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* 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); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -50935,7 +54027,7 @@ var ts; 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); + return propagateOptionalTypeMarker(checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node), isOptional); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === errorType) { @@ -50981,13 +54073,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 156 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51006,7 +54098,7 @@ var ts; // interface B extends A { (x: 'foo'): string } // const b: B; // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -51014,8 +54106,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -51047,11 +54139,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? createOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 212 /* SpreadElement */ || arg.kind === 219 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51065,9 +54157,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 210 /* 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. @@ -51082,7 +54174,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 156 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51097,7 +54189,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 196 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51190,7 +54282,7 @@ var ts; // 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 !== 153 /* Decorator */) { + if (node.kind !== 156 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51220,7 +54312,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -51233,7 +54325,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51257,7 +54349,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 219 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51332,12 +54424,12 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 196 /* 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. @@ -51347,7 +54439,7 @@ var ts; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors"); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1; @@ -51355,7 +54447,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 !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -51365,7 +54457,7 @@ var ts; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } } @@ -51375,7 +54467,7 @@ var ts; if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, /*containingMessageChain*/ undefined, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(errorNode, spreadType, restType); - return errorOutputContainer.errors || []; + return errorOutputContainer.errors || ts.emptyArray; } } return undefined; @@ -51396,15 +54488,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 193 /* PropertyAccessExpression */ || callee.kind === 194 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(219 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51414,17 +54506,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 156 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51439,7 +54531,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, /*isSpread*/ i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -51454,30 +54546,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* 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 152 /* Parameter */: + case 155 /* 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 === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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 !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 158 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51491,17 +54583,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* 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 152 /* Parameter */: + case 155 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -51539,8 +54631,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -51609,8 +54701,8 @@ var ts; // Overloads exist var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -51625,22 +54717,22 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 156 /* 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 !== 99 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -51689,7 +54781,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 195 /* 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 @@ -51742,7 +54834,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -51760,7 +54852,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -51894,7 +54986,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { + var _loop_15 = function (i) { var symbols = ts.mapDefined(candidates, function (_a) { var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; return hasRestParameter ? @@ -51905,7 +54997,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); var hasRestParameter = restParameterSymbols.length !== 0; @@ -51983,7 +55075,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -51998,12 +55090,12 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var _b = checkOptionalExpression(node, node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined), isOptional = _b.isOptional, funcType = _b.type; if (funcType === silentNeverType) { return silentNeverSignature; } @@ -52069,7 +55161,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -52132,7 +55224,7 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time @@ -52140,7 +55232,7 @@ var ts; // operation is Any. It is an error to have a Void this type. var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -52225,8 +55317,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var constituent = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var constituent = types_16[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52317,23 +55409,23 @@ var ts; invocationError(node.tag, apparentType, 0 /* Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52370,16 +55462,16 @@ var ts; invocationErrorRecovery(apparentType, 0 /* Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, 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(121 /* AnyKeyword */)); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* 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(124 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -52410,7 +55502,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -52426,16 +55518,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 156 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52486,57 +55578,52 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); - } - return false; - } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 193 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -52551,15 +55638,15 @@ var ts; // returns a function type. We defer checking and return nonInferrableType. return nonInferrableType; } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 196 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 161 /* Constructor */ && + declaration.kind !== 165 /* ConstructSignature */ && + declaration.kind !== 170 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -52579,18 +55666,28 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 /* CallExpression */ && node.parent.kind === 225 /* ExpressionStatement */ && + returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -52607,7 +55704,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -52628,7 +55725,7 @@ var ts; // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -52667,7 +55764,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -52676,19 +55773,20 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 243 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 241 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 4194304 /* Ambient */); + return !!decl && !!(decl.flags & 8388608 /* Ambient */); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 131072 /* MakeTemplateObject */); } @@ -52703,20 +55801,20 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || + op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -52752,10 +55850,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96 /* NewKeyword */) { + if (node.keywordToken === 98 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93 /* ImportKeyword */) { + if (node.keywordToken === 95 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -52766,7 +55864,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 === 158 /* Constructor */) { + else if (container.kind === 161 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -52776,11 +55874,11 @@ var ts; } } function checkImportMetaProperty(node) { - if (languageVersion < 99 /* ESNext */ || moduleKind < ts.ModuleKind.ESNext) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_options); + if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -52822,7 +55920,7 @@ var ts; // otherwise would return the type 'undefined'). var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -52854,7 +55952,7 @@ var ts; if (signature.hasRestParameter) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; @@ -52952,7 +56050,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 === 73 /* Identifier */) { + if (element.name.kind === 75 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -52966,8 +56064,8 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73 /* Identifier */) { - // if inference didn't come up with anything but {}, fall back to the binding pattern if present. + if (decl.name.kind !== 75 /* Identifier */) { + // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -53021,7 +56119,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 222 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -53093,7 +56191,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -53204,17 +56302,18 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200 /* TypeOfExpression */) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203 /* 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 & 131072 /* Never */); + var type_4 = getBaseConstraintOfType(operandType) || operandType; + return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -53227,13 +56326,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128 /* HasImplicitReturn */)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */ function checkAndAggregateReturnExpressionTypes(func, checkMode) { @@ -53273,11 +56366,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 160 /* MethodDeclaration */: + return func.parent.kind === 192 /* ObjectLiteralExpression */; default: return false; } @@ -53303,10 +56396,10 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 159 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 222 /* Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; if (type && type.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -53336,7 +56429,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -53356,7 +56449,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 200 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53410,7 +56503,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53423,7 +56516,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 222 /* Block */) { checkSourceElement(node.body); } else { @@ -53504,11 +56597,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && - expr.expression.kind === 101 /* ThisKeyword */) { + (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) && + expr.expression.kind === 103 /* 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 === 158 /* Constructor */)) { + if (!(func && func.kind === 161 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -53521,31 +56614,35 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 255 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 75 /* Identifier */ && node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32 /* OptionalChain */) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 193 /* PropertyAccessExpression */ && expr.kind !== 194 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -53567,14 +56664,14 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 16384 /* AwaitContext */)) { + if (!(node.flags & 32768 /* AwaitContext */)) { // use of 'await' in non-async function var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -53587,7 +56684,11 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) { + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); + } + return awaitedType; } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -53597,14 +56698,14 @@ var ts; switch (node.operand.kind) { case 8 /* NumericLiteral */: switch (node.operator) { - case 39 /* MinusToken */: + case 40 /* MinusToken */: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38 /* PlusToken */: + case 39 /* PlusToken */: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9 /* BigIntLiteral */: - if (node.operator === 39 /* MinusToken */) { + if (node.operator === 40 /* MinusToken */) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -53612,32 +56713,32 @@ var ts; } } switch (node.operator) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38 /* PlusToken */) { + if (node.operator === 39 /* 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)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 45 /* PlusPlusToken */: + case 46 /* 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -53651,7 +56752,7 @@ var ts; 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); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -53672,8 +56773,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var t = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var t = types_17[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -53762,7 +56863,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */ || property.kind === 280 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -53775,9 +56876,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 281 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -53820,8 +56921,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 214 /* OmittedExpression */) { + if (element.kind !== 212 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -53839,7 +56940,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 208 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -53855,7 +56956,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 280 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -53871,24 +56972,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 208 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 192 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 191 /* 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 === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 281 /* 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)) { + var optionalError = target.parent.kind === 281 /* SpreadAssignment */ ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -53904,53 +57008,53 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 145 /* UndefinedKeyword */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 203 /* TypeOfExpression */: + case 217 /* NonNullExpression */: + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 52 /* ExclamationToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 53 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 204 /* VoidExpression */: // Explicit opt-out + case 198 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 216 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -53962,15 +57066,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60 /* QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); + if (operator === 62 /* EqualsToken */ && (left.kind === 192 /* ObjectLiteralExpression */ || left.kind === 191 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103 /* ThisKeyword */); } var leftType; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -53978,28 +57094,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40 /* AsteriskToken */: - case 41 /* AsteriskAsteriskToken */: - case 63 /* AsteriskEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 43 /* PercentToken */: - case 66 /* PercentEqualsToken */: - case 39 /* MinusToken */: - case 62 /* MinusEqualsToken */: - case 46 /* LessThanLessThanToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: + case 41 /* AsteriskToken */: + case 42 /* AsteriskAsteriskToken */: + case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 44 /* PercentToken */: + case 68 /* PercentEqualsToken */: + case 40 /* MinusToken */: + case 64 /* MinusEqualsToken */: + case 47 /* LessThanLessThanToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54026,17 +57142,17 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); } resultType_1 = bigintType; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54044,8 +57160,8 @@ var ts; } return resultType_1; } - case 38 /* PlusToken */: - case 61 /* PlusEqualsToken */: + case 39 /* PlusToken */: + case 63 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54078,24 +57194,24 @@ var ts; } if (!resultType) { // Types that have a reasonably good chance of being a valid operand type. - // If both types have an awaited type of one of these, we’ll assume the user + // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61 /* PlusEqualsToken */) { + if (operator === 63 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -54104,25 +57220,29 @@ var ts; }); } return booleanType; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 60 /* EqualsToken */: + case 60 /* QuestionQuestionToken */: + return getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + leftType; + case 62 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -54149,6 +57269,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54156,7 +57279,7 @@ var ts; var propType = getTypeOfSymbol(prop); if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 67897832 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); @@ -54166,7 +57289,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 75 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -54181,15 +57304,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - return 55 /* BarBarToken */; - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - return 36 /* ExclamationEqualsEqualsToken */; - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: - return 54 /* AmpersandAmpersandToken */; + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + return 56 /* BarBarToken */; + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + return 37 /* ExclamationEqualsEqualsToken */; + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: + return 55 /* AmpersandAmpersandToken */; default: return undefined; } @@ -54202,7 +57325,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non-compound operation to be assignable to the type of VarExpr. - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); @@ -54236,17 +57359,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); + } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54254,12 +57383,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: typeName = "false"; break; - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -54268,6 +57397,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54286,7 +57426,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -54335,12 +57475,7 @@ var ts; return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) || anyType; } - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, contextualReturnType, isAsync) - || anyType; - } - return anyType; + return getContextualIterationType(2 /* Next */, func) || anyType; } function checkConditionalExpression(node, checkMode) { checkTruthinessExpression(node.condition); @@ -54362,7 +57497,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 /* 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; @@ -54401,12 +57536,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 198 /* TypeAssertionExpression */ || node.kind === 216 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54428,10 +57563,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54483,7 +57618,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54494,7 +57629,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54506,8 +57641,8 @@ var ts; var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8 /* SkipGenericFunctions */) { @@ -54637,11 +57772,11 @@ 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 === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + var _a = checkOptionalExpression(expr, expr.expression), isOptional = _a.isOptional, funcType = _a.type; var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -54687,17 +57822,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 261 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 8388608 /* Ambient */)); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304 /* Ambient */) { + if (constEnumDeclaration.flags & 8388608 /* Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -54710,14 +57846,25 @@ var ts; return checkExpression(node.expression, checkMode); } function checkExpressionWorker(node, checkMode, forceTuple) { - switch (node.kind) { - case 73 /* Identifier */: + var kind = node.kind; + if (cancellationToken) { + // 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 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 75 /* Identifier */: return checkIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return checkThisExpression(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkSuperExpression(node); - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -54728,82 +57875,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: return trueType; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: - if (node.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (node.expression.kind === 95 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 196 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 219 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -54840,7 +57987,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -54851,10 +57998,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 === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 161 /* Constructor */ || func.kind === 165 /* ConstructSignature */ || func.kind === 170 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -54878,7 +58025,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -54887,9 +58034,11 @@ var ts; error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, - /*headMessage*/ undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, + /*headMessage*/ undefined, leadingError); + } } } else if (parameterName) { @@ -54910,13 +58059,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 201 /* ArrowFunction */: + case 164 /* CallSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 169 /* FunctionType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -54930,11 +58079,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 75 /* 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 === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 189 /* ArrayBindingPattern */ || name.kind === 188 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -54943,13 +58092,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* 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 === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 169 /* FunctionType */ || node.kind === 243 /* FunctionDeclaration */ || node.kind === 170 /* ConstructorType */ || + node.kind === 164 /* CallSignature */ || node.kind === 161 /* Constructor */ || + node.kind === 165 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -54979,10 +58128,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55012,28 +58161,21 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 166 /* IndexSignature */ && node.kind !== 298 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } } function checkClassForDuplicateDeclarations(node) { - var Declaration; - (function (Declaration) { - Declaration[Declaration["Getter"] = 1] = "Getter"; - Declaration[Declaration["Setter"] = 2] = "Setter"; - Declaration[Declaration["Method"] = 4] = "Method"; - Declaration[Declaration["Property"] = 3] = "Property"; - })(Declaration || (Declaration = {})); var instanceNames = ts.createUnderscoreEscapedMap(); var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 161 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; - if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* Property */); + if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { + addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); } } } @@ -55044,17 +58186,17 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: - addName(names, name, memberName, 1 /* Getter */); + case 162 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: - addName(names, name, memberName, 2 /* Setter */); + case 163 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* Property */); + case 158 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: - addName(names, name, memberName, 4 /* Method */); + case 160 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */); break; } } @@ -55063,8 +58205,8 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 4 /* Method */) { - if (meaning !== 4 /* Method */) { + if (prev & 8 /* Method */) { + if (meaning !== 8 /* Method */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } } @@ -55116,7 +58258,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 157 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55124,7 +58266,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 73 /* Identifier */: + case 75 /* Identifier */: memberName = ts.idText(name); break; default: @@ -55141,7 +58283,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* 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 @@ -55161,7 +58303,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -55169,7 +58311,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -55196,7 +58338,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 === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 160 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55221,7 +58363,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55249,9 +58391,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55276,9 +58418,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { - if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { - if (!(node.flags & 256 /* HasExplicitReturn */)) { + if (node.kind === 162 /* GetAccessor */) { + if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { + if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -55286,13 +58428,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* 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 === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55310,7 +58452,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55358,19 +58500,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { @@ -55406,16 +58545,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 176 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 175 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55436,7 +58575,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 /* 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)); } @@ -55487,7 +58626,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 /* 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); @@ -55498,16 +58637,16 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 4194304 /* Ambient */); + return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && - n.flags & 4194304 /* Ambient */) { + if (n.parent.kind !== 245 /* InterfaceDeclaration */ && + n.parent.kind !== 244 /* ClassDeclaration */ && + n.parent.kind !== 213 /* ClassExpression */ && + n.flags & 8388608 /* 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 flags |= 1 /* Export */; @@ -55597,7 +58736,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 === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* 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 @@ -55632,11 +58771,12 @@ var ts; } var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; + var hasNonAmbientClass = false; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent.kind === 245 /* InterfaceDeclaration */ || node.parent.kind === 172 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -55647,7 +58787,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if ((node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 243 /* FunctionDeclaration */ || node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */ || node.kind === 161 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -55688,6 +58831,15 @@ var ts; error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation); }); } + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { + // A non-ambient class cannot be an implementation for a non-constructor function/class merge + // TODO: The below just replicates our older error from when classes and functions were + // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" + // might be warranted. :shrug: + ts.forEach(declarations, function (declaration) { + addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + }); + } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && !ts.hasModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { @@ -55699,8 +58851,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -55709,13 +58861,6 @@ var ts; } } } - var DeclarationSpaces; - (function (DeclarationSpaces) { - DeclarationSpaces[DeclarationSpaces["None"] = 0] = "None"; - DeclarationSpaces[DeclarationSpaces["ExportValue"] = 1] = "ExportValue"; - DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; - DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; - })(DeclarationSpaces || (DeclarationSpaces = {})); function checkExportsOnMergedDeclarations(node) { if (!produceDiagnostics) { return; @@ -55776,40 +58921,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 258 /* 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 */; } 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 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 243 /* FunctionDeclaration */: + case 257 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -55843,7 +58990,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { @@ -55878,9 +59025,6 @@ var ts; */ function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); - if (awaitedType === type && !(type.flags & 3 /* AnyOrUnknown */)) { - addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(errorNode, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); - } return awaitedType || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { @@ -56039,10 +59183,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67220415 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 75 /* 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 { @@ -56062,7 +59206,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67220415 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -56081,24 +59225,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 155 /* 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 155 /* PropertyDeclaration */: + case 158 /* 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 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56119,7 +59263,7 @@ var ts; if (!typeName) return; var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 67897832 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 75 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56144,29 +59288,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var typeNode = types_18[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* 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); @@ -56212,14 +59356,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* 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 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56228,23 +59372,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 160 /* 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 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 155 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56307,7 +59451,7 @@ var ts; 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 === 149 /* 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 === 152 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56340,9 +59484,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56355,7 +59499,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 === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56371,7 +59515,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -56384,7 +59528,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 159 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56410,7 +59554,7 @@ var ts; } function registerForUnusedIdentifiersCheck(node) { // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`. - if (produceDiagnostics && !(node.flags & 4194304 /* Ambient */)) { + if (produceDiagnostics && !(node.flags & 8388608 /* Ambient */)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -56426,42 +59570,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 288 /* SourceFile */: + case 248 /* ModuleDeclaration */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 180 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56481,11 +59625,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 160 /* MethodDeclaration */: + case 158 /* PropertyDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + if (member.kind === 163 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56494,7 +59638,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 158 /* Constructor */: + case 161 /* 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 */)) { @@ -56502,8 +59646,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 166 /* IndexSignature */: + case 221 /* SemicolonClassElement */: // Can't be private break; default: @@ -56530,7 +59674,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -56565,7 +59709,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304 /* Ambient */) + if (nodeWithLocals.flags & 8388608 /* Ambient */) return; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); @@ -56600,7 +59744,7 @@ var ts; var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } @@ -56615,7 +59759,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -56633,7 +59777,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 === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 242 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -56654,7 +59798,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 === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -56666,24 +59810,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 254 /* ImportClause */ || node.kind === 257 /* ImportSpecifier */ || node.kind === 255 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 254 /* ImportClause */ ? decl : decl.kind === 255 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 222 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -56700,7 +59844,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -56713,21 +59857,21 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 158 /* PropertyDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 160 /* MethodDeclaration */ || + node.kind === 159 /* MethodSignature */ || + node.kind === 162 /* GetAccessor */ || + node.kind === 163 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // ambient context - no codegen impact return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -56737,7 +59881,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 73 /* Identifier */; + var isDeclaration_1 = node.kind !== 75 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -56752,7 +59896,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 73 /* Identifier */; + var isDeclaration_2 = node.kind !== 75 /* 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); } @@ -56778,7 +59922,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 /* 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)); } @@ -56793,7 +59937,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 === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* 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)); } @@ -56828,7 +59972,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 === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 241 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -56840,17 +59984,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 224 /* 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 === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 222 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 249 /* ModuleBlock */ || + container.kind === 248 /* ModuleDeclaration */ || + container.kind === 288 /* 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 @@ -56880,18 +60024,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 === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 190 /* BindingElement */) { + if (node.parent.kind === 188 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -56905,26 +60049,26 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 /* 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 === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 /* 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)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -56961,7 +60105,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -56987,10 +60131,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -56999,7 +60143,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 158 /* PropertyDeclaration */ || nextDeclaration.kind === 157 /* PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -57009,8 +60153,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 155 /* Parameter */ && right.kind === 241 /* VariableDeclaration */) || + (left.kind === 241 /* VariableDeclaration */ && right.kind === 155 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57047,13 +60191,56 @@ var ts; function checkIfStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 223 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + // While it technically should be invalid for any known-truthy value + // to be tested, we de-scope to functions unrefenced in the block as a + // heuristic to identify the most common bugs. There are too many + // false positives for values sourced from type definitions without + // strictNullChecks otherwise. + var callSignatures = getSignaturesOfType(type, 0 /* Call */); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -57076,12 +60263,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 242 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57115,14 +60302,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 === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* 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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* 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. @@ -57130,7 +60317,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -57154,7 +60341,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* 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); @@ -57168,7 +60355,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 === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* 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)) { @@ -57176,7 +60363,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved @@ -57529,7 +60716,7 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use @@ -57541,7 +60728,7 @@ var ts; // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -57620,7 +60807,7 @@ var ts; // - `Generator` or `AsyncGenerator` var globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `IterableIterator` and `AsyncIterableIterator` are defined by the // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. @@ -57631,7 +60818,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(/*reportErrors*/ false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -57667,11 +60854,11 @@ var ts; // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` // or `IteratorReturnResult` types, then just grab its type argument. if (isReferenceToType(type, getGlobalIteratorYieldResultType(/*reportErrors*/ false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, /*returnType*/ undefined, /*nextType*/ undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(/*reportErrors*/ false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(/*yieldType*/ undefined, returnType_1, /*nextType*/ undefined); } // Choose any constituents that can produce the requested iteration type. @@ -57735,11 +60922,13 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + // The value of `next(value)` is *not* awaited by async generators + nextType = methodParameterType; } else if (methodName === "return") { + // The value of `return(value)` *is* awaited by async generators + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -57832,12 +61021,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160 /* SetAccessor */) { + if (func.kind === 163 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 161 /* 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); } @@ -57855,7 +61044,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -57863,7 +61052,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384 /* AwaitContext */) { + if (node.flags & 32768 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -57884,7 +61073,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 === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 276 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -57896,7 +61085,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 275 /* 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. @@ -57925,7 +61114,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58032,8 +61221,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 === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 208 /* BinaryExpression */ || + name.kind === 153 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58110,7 +61299,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 168 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58170,11 +61359,10 @@ var ts; var constraint = ts.getEffectiveConstraintOfTypeParameter(source); var sourceConstraint = constraint && getTypeFromTypeNode(constraint); var targetConstraint = getConstraintOfTypeParameter(target); - if (sourceConstraint) { - // relax check if later interface augmentation has no constraint - if (!targetConstraint || !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { - return false; - } + // relax check if later interface augmentation has no constraint, it's more broad and is OK to merge with + // a more constrained interface (this could be generalized to a full heirarchy check, but that's maybe overkill) + if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) { + return false; } // If the type parameter node has a default and it is not identical to the default // for the type parameter at this position, we report an error. @@ -58211,7 +61399,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassNameCollisionWithObject(node.name); } } @@ -58224,11 +61412,12 @@ var ts; checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } @@ -58266,12 +61455,9 @@ var ts; } 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 - // that the base type is a class or interface type (and not, for example, an anonymous object type). - // (Javascript constructor functions have this property trivially true since their return type is ignored.) + // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -58314,7 +61500,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -58333,7 +61519,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -58359,7 +61545,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 244 /* ClassDeclaration */ || d.kind === 245 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58378,7 +61564,7 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 4194304 /* Prototype */) { @@ -58387,53 +61573,104 @@ var ts; var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); - if (derived) { - // In order to resolve whether the inherited method was overridden in the base class or not, - // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* - // type declaration, derived and base resolve to the same symbol even in the case of generic classes. - if (derived === base) { - // derived class inherits base without override/redeclaration - var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); - // It is an error to inherit an abstract member without implementing it or being declared abstract. - // If there is no declaration for the derived class (as in the case of class expressions), - // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 210 /* ClassExpression */) { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); - } - else { - error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + // In order to resolve whether the inherited method was overridden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { + // Searches other base types for a declaration that would satisfy the inherited abstract member. + // (The class may have more than one base type via declaration merging with an interface with the + // same name.) + for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { + var otherBaseType = _b[_a]; + if (otherBaseType === baseType) + continue; + var baseSymbol = getPropertyOfObjectType(otherBaseType, base.escapedName); + var derivedElsewhere = baseSymbol && getTargetSymbol(baseSymbol); + if (derivedElsewhere && derivedElsewhere !== base) { + continue basePropertyCheck; } } + if (derivedClassDecl.kind === 213 /* ClassExpression */) { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); + } + else { + error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } - else { - // derived overrides base. - var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { - // either base or derived property is private - not override, skip it + } + else { + // derived overrides base. + var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + // either base or derived property is private - not override, skip it + continue; + } + var errorMessage = void 0; + var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + if (basePropertyFlags && derivedPropertyFlags) { + // property/accessor is overridden with property/accessor + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 /* InterfaceDeclaration */ + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { + // when the base property is abstract or from an interface, base/derived flags don't need to match + // same when the derived property is from an assignment continue; } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; + if (basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; } - var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + else if (basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 /* PropertyDeclaration */ && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432 /* Transient */) + && !(baseDeclarationFlags & 128 /* Abstract */) + && !(derivedDeclarationFlags & 128 /* Abstract */) + && !derived.declarations.some(function (d) { return d.flags & 8388608 /* Ambient */; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } } + // correct case + continue; } - else if (base.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived)) { + // method is overridden with method -- correct case + continue; + } + else if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } - error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } + else if (base.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -58470,12 +61707,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2 /* Ambient */) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -58490,7 +61730,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -58514,7 +61754,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -58577,7 +61817,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -58609,7 +61849,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304 /* Ambient */) { + else if (member.parent.flags & 8388608 /* Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -58619,66 +61859,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38 /* PlusToken */: return value_2; - case 39 /* MinusToken */: return -value_2; - case 53 /* TildeToken */: return ~value_2; + case 39 /* PlusToken */: return value_2; + case 40 /* MinusToken */: return -value_2; + case 54 /* TildeToken */: return ~value_2; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - 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); + case 51 /* BarToken */: return left | right; + case 50 /* AmpersandToken */: return left & right; + case 48 /* GreaterThanGreaterThanToken */: return left >> right; + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* LessThanLessThanToken */: return left << right; + case 52 /* CaretToken */: return left ^ right; + case 41 /* AsteriskToken */: return left * right; + case 43 /* SlashToken */: return left / right; + case 39 /* PlusToken */: return left + right; + case 40 /* MinusToken */: return left - right; + case 44 /* PercentToken */: return left % right; + case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { return left + right; } break; case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 73 /* Identifier */: + case 75 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* 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 === 190 /* PropertyAccessExpression */) { + if (ex.kind === 193 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -58703,10 +61942,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10 /* StringLiteral */; + return node.kind === 75 /* Identifier */ || + node.kind === 193 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 194 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -58740,7 +61979,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 !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 247 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -58763,9 +62002,9 @@ 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 === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304 /* Ambient */)) { + if ((declaration.kind === 244 /* ClassDeclaration */ || + (declaration.kind === 243 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } } @@ -58788,7 +62027,7 @@ var ts; if (produceDiagnostics) { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304 /* Ambient */; + var inAmbientContext = node.flags & 8388608 /* Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -58827,7 +62066,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, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 244 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -58877,23 +62116,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* 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 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 241 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -58904,12 +62143,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -58930,17 +62169,36 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: + return node; + case 152 /* QualifiedName */: + do { + node = node.left; + } while (node.kind !== 75 /* Identifier */); + return node; + case 193 /* PropertyAccessExpression */: + do { + node = node.expression; + } while (node.kind !== 75 /* Identifier */); + return node; + } + } + function getFirstNonModuleExportsIdentifier(node) { + switch (node.kind) { + case 75 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } node = node.expression; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; } } @@ -58954,9 +62212,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -58978,27 +62236,29 @@ var ts; function checkAliasSymbol(node) { var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); - if (target !== unknownSymbol) { - // For external modules symbol represent local symbol for an alias. + var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864 /* Assignment */; + if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + // For external modules symbol represents local symbol for an alias. // This local symbol will merge any other local declarations (excluding other aliases) // and symbol.flags will contains combined representation for all merged declaration. // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). - var excludedMeanings = (symbol.flags & (67220415 /* Value */ | 1048576 /* ExportValue */) ? 67220415 /* Value */ : 0) | - (symbol.flags & 67897832 /* Type */ ? 67897832 /* Type */ : 0) | + symbol = getMergedSymbol(symbol.exportSymbol || symbol); + var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | + (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 261 /* 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 === 258 /* ExportSpecifier */ - && !(target.flags & 67220415 /* Value */) - && !(node.flags & 4194304 /* Ambient */)) { + && node.kind === 261 /* ExportSpecifier */ + && !(target.flags & 111551 /* Value */) + && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -59023,7 +62283,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59047,23 +62307,23 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 263 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 67220415 /* Value */) { + if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 67220415 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 67897832 /* Type */) { + if (target.flags & 788968 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608 /* Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -59083,10 +62343,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 /* ModuleBlock */ && + !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59103,7 +62363,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 288 /* SourceFile */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 248 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59117,13 +62377,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { markExportAsReferenced(node); + var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + checkExpressionCached(node.propertyName || node.name); + } } } } @@ -59132,8 +62396,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 === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59146,8 +62410,18 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73 /* Identifier */) { - markExportAsReferenced(node); + if (node.expression.kind === 75 /* Identifier */) { + var id = node.expression; + var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + if (sym) { + markAliasReferenced(sym, id); + // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) + var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* Value */) { + // However if it is a value, we need to check it's being used correctly + checkExpressionCached(node.expression); + } + } if (ts.getEmitDeclarations(compilerOptions)) { collectLinkedAliases(node.expression, /*setVisibility*/ true); } @@ -59156,10 +62430,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -59185,9 +62459,9 @@ var ts; } } // Checks for export * conflicts - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -59216,14 +62490,6 @@ var ts; links.exportsChecked = true; } } - function isNotAccessor(declaration) { - // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks - return !ts.isAccessor(declaration); - } - function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || - !!declaration.body; - } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -59245,158 +62511,162 @@ 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 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 /* FirstStatement */ && kind <= 240 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 181 /* ParenthesizedType */: + case 175 /* OptionalType */: + case 176 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 182 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return checkImportType(node); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 311 /* JSDocTypedefTag */: - case 304 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 309 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 306 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 298 /* JSDocTypeLiteral */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: + case 302 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 292 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 223 /* EmptyStatement */: + case 240 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -59491,23 +62761,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 264 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -59536,7 +62806,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } // Grammar checking @@ -59622,7 +62892,7 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608 /* InWithStatement */) { + if (location.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } @@ -59637,35 +62907,35 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // 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 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStatic) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67897832 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -59707,17 +62977,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 /* Identifier */ && + return name.kind === 75 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 154 /* TypeParameter */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -59725,16 +62995,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 168 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 193 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 215 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -59762,13 +63032,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 152 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 252 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 258 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -59794,7 +63064,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 187 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -59804,7 +63074,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 193 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -59812,17 +63082,17 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 258 /* 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); + /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } 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, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 252 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -59840,11 +63110,11 @@ 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 === 212 /* ExpressionWithTypeArguments */) { - meaning = 67897832 /* Type */; + if (entityName.parent.kind === 215 /* ExpressionWithTypeArguments */) { + meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { - meaning |= 67220415 /* Value */; + meaning |= 111551 /* Value */; } } else { @@ -59856,10 +63126,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 306 /* JSDocParameterTag */) { + if (entityName.parent.kind === 310 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 310 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 154 /* TypeParameter */ && entityName.parent.parent.kind === 314 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -59869,19 +63139,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 73 /* Identifier */) { + if (entityName.kind === 75 /* 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); + return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 193 /* PropertyAccessExpression */ || entityName.kind === 152 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 193 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -59891,22 +63161,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 67897832 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 168 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 167 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -59920,12 +63190,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 190 /* BindingElement */ && + grandParent.kind === 188 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -59935,11 +63205,11 @@ var ts; } } switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -59951,14 +63221,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 182 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkExpression(node).symbol; - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 161 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -59969,7 +63239,7 @@ var ts; // 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 === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 /* ImportDeclaration */ || node.parent.kind === 259 /* 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); @@ -59986,22 +63256,22 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81 /* DefaultKeyword */: - case 91 /* FunctionKeyword */: - case 37 /* EqualsGreaterThanToken */: - case 77 /* ClassKeyword */: + case 83 /* DefaultKeyword */: + case 93 /* FunctionKeyword */: + case 38 /* EqualsGreaterThanToken */: + case 79 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 67220415 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 280 /* ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; } @@ -60009,10 +63279,10 @@ var ts; function getExportSpecifierLocalTargetSymbol(node) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 67220415 /* Value */ | 67897832 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -60068,27 +63338,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 192 /* ObjectLiteralExpression */ || expr.kind === 191 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 231 /* 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 === 205 /* BinaryExpression */) { + if (expr.parent.kind === 208 /* 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 === 276 /* PropertyAssignment */) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60127,17 +63397,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } // Return the list of properties of the given type, augmented with properties from Function @@ -60189,7 +63458,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60210,13 +63479,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 67220415 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 67220415 /* Value */); + return s && !!(s.flags & 111551 /* Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -60245,7 +63514,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 288 /* 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. @@ -60265,7 +63534,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 67220415 /* Value */)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -60273,7 +63542,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60282,7 +63551,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 67220415 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -60304,7 +63573,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 === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 222 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60345,26 +63614,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258 /* ExportAssignment */: + return node.expression && node.expression.kind === 75 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60378,7 +63646,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 67220415 /* Value */) && + return !!(target.flags & 111551 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -60392,7 +63660,7 @@ var ts; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && - target.flags & 67220415 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + target.flags & 111551 /* Value */ && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -60446,7 +63714,7 @@ var ts; if (!symbol || !(symbol.flags & 16 /* Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 67220415 /* Value */ && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -60465,15 +63733,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 282 /* EnumMember */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 282 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -60500,9 +63768,9 @@ var ts; return ts.TypeReferenceSerializationKind.Unknown; } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - var valueSymbol = resolveEntityName(typeName, 67220415 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 67897832 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { @@ -60558,7 +63826,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -60577,7 +63845,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -60585,7 +63853,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -60607,7 +63875,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -60628,7 +63896,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 67220415 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse(); return enumResult || ts.createLiteral(type.value); } @@ -60709,12 +63977,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 === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 163 /* SetAccessor */ ? 162 /* GetAccessor */ : 163 /* 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 === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -60727,10 +63995,19 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 215 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 277 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -60741,9 +64018,9 @@ var ts; // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 67897832 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 67220415 /* Value */ | 1048576 /* ExportValue */; + var meaning = 788968 /* Type */ | 1920 /* Namespace */; + if ((node.kind === 75 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 193 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -60793,7 +64070,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -60821,12 +64098,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 /* 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, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 288 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -60959,16 +64236,16 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; for (var helper = 1 /* FirstEmitHelper */; helper <= 131072 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 67220415 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -61015,14 +64292,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 /* 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 === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* 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); @@ -61039,23 +64316,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 !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (modifier.kind !== 137 /* ReadonlyKeyword */) { + if (node.kind === 157 /* PropertySignature */ || node.kind === 159 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); + case 80 /* ConstKeyword */: + if (node.kind !== 247 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80 /* ConstKeyword */)); } break; - case 116 /* PublicKeyword */: - case 115 /* ProtectedKeyword */: - case 114 /* PrivateKeyword */: + case 118 /* PublicKeyword */: + case 117 /* ProtectedKeyword */: + case 116 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -61069,11 +64346,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* 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 === 114 /* PrivateKeyword */) { + if (modifier.kind === 116 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -61082,7 +64359,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -61092,10 +64369,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 === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61104,18 +64381,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */ && node.kind !== 166 /* IndexSignature */ && node.kind !== 155 /* 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 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -61128,52 +64405,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 === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 83 /* DefaultKeyword */: + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* 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 126 /* DeclareKeyword */: + case 129 /* 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 === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 249 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 119 /* AbstractKeyword */: + case 121 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 244 /* ClassDeclaration */) { + if (node.kind !== 160 /* MethodDeclaration */ && + node.kind !== 158 /* PropertyDeclaration */ && + node.kind !== 162 /* GetAccessor */ && + node.kind !== 163 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 244 /* 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 */) { @@ -61185,14 +64462,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 122 /* AsyncKeyword */: + case 125 /* 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 */) { + else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61200,7 +64477,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61215,13 +64492,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 253 /* ImportDeclaration */ || node.kind === 252 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 /* 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 === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 155 /* 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 */) { @@ -61242,38 +64519,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 248 /* ModuleDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 155 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 125 /* AsyncKeyword */); + case 244 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AbstractKeyword */); + case 245 /* InterfaceDeclaration */: + case 224 /* VariableStatement */: + case 246 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); + case 247 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 80 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -61285,10 +64562,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61317,7 +64594,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -61351,7 +64628,7 @@ var ts; ts.addRelatedInfo(error(parameter, ts.Diagnostics.This_parameter_is_not_allowed_with_use_strict_directive), ts.createDiagnosticForNode(useStrictDirective_1, ts.Diagnostics.use_strict_directive_used_here)); }); var diagnostics_1 = nonSimpleParameters.map(function (parameter, index) { return (index === 0 ? ts.createDiagnosticForNode(parameter, ts.Diagnostics.Non_simple_parameter_declared_here) : ts.createDiagnosticForNode(parameter, ts.Diagnostics.and_here)); }); - ts.addRelatedInfo.apply(void 0, [error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)].concat(diagnostics_1)); + ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1)); return true; } } @@ -61403,7 +64680,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 /* StringKeyword */ && parameter.type.kind !== 136 /* NumberKeyword */) { + if (parameter.type.kind !== 142 /* StringKeyword */ && parameter.type.kind !== 139 /* 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(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -61435,11 +64712,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211 /* OmittedExpression */) { + if (arg.kind === 214 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61469,7 +64752,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 === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -61482,7 +64765,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -61498,14 +64781,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -61516,21 +64799,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 153 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 208 /* 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 === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); - if (node.flags & 4194304 /* Ambient */) { + ts.Debug.assert(node.kind === 243 /* FunctionDeclaration */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 160 /* MethodDeclaration */); + if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -61545,17 +64828,10 @@ var ts; return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { - var Flags; - (function (Flags) { - Flags[Flags["Property"] = 1] = "Property"; - Flags[Flags["GetAccessor"] = 2] = "GetAccessor"; - Flags[Flags["SetAccessor"] = 4] = "SetAccessor"; - Flags[Flags["GetOrSetAccessor"] = 6] = "GetOrSetAccessor"; - })(Flags || (Flags = {})); var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 281 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -61566,20 +64842,21 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 /* 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); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 125 /* AsyncKeyword */ || prop.kind !== 160 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -61594,24 +64871,25 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 279 /* 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 157 /* MethodDeclaration */: - currentKind = 1 /* Property */; + currentKind = 4 /* PropertyAssignment */; break; - case 159 /* GetAccessor */: - currentKind = 2 /* GetAccessor */; + case 160 /* MethodDeclaration */: + currentKind = 8 /* Method */; break; - case 160 /* SetAccessor */: - currentKind = 4 /* SetAccessor */; + case 162 /* GetAccessor */: + currentKind = 1 /* GetAccessor */; + break; + case 163 /* SetAccessor */: + currentKind = 2 /* SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -61625,11 +64903,11 @@ var ts; seen.set(effectiveName, currentKind); } else { - if (currentKind === 1 /* Property */ && existingKind === 1 /* Property */) { + if ((currentKind & 12 /* PropertyAssignmentOrMethod */) && (existingKind & 12 /* PropertyAssignmentOrMethod */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 6 /* GetOrSetAccessor */) && (existingKind & 6 /* GetOrSetAccessor */)) { - if (existingKind !== 6 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { + if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -61647,7 +64925,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 === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 273 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -61657,7 +64935,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 274 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -61671,14 +64949,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + if (forInOrOfStatement.kind === 231 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -61689,7 +64967,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 242 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -61704,20 +64982,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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 === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* 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); @@ -61727,42 +65005,38 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (accessor.flags & 4194304 /* Ambient */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { - return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + if (!(accessor.flags & 8388608 /* Ambient */)) { + if (languageVersion < 1 /* ES5 */) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); + } + if (accessor.body === undefined && !ts.hasModifier(accessor, 128 /* Abstract */)) { + return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); + } } - else if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { + if (accessor.body && ts.hasModifier(accessor, 128 /* Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - else if (accessor.typeParameters) { + if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 159 /* GetAccessor */ ? + if (!doesAccessorHaveCorrectParameterCount(accessor)) { + return grammarErrorOnNode(accessor.name, accessor.kind === 162 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 160 /* SetAccessor */) { + if (accessor.kind === 163 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } + var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + if (parameter.dotDotDotToken) { + return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); + } + if (parameter.questionToken) { + return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); + } + if (parameter.initializer) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); } } return false; @@ -61772,23 +65046,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 === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143 /* UniqueKeyword */) { - if (node.type.kind !== 140 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140 /* SymbolKeyword */)); + if (node.operator === 146 /* UniqueKeyword */) { + if (node.type.kind !== 143 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* 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)) { @@ -61798,13 +65072,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 158 /* 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 154 /* PropertySignature */: + case 157 /* 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); } @@ -61813,9 +65087,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); + else if (node.operator === 137 /* ReadonlyKeyword */) { + if (node.type.kind !== 173 /* ArrayType */ && node.type.kind !== 174 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143 /* SymbolKeyword */)); } } } @@ -61828,10 +65102,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 160 /* MethodDeclaration */) { + if (node.parent.kind === 192 /* 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 === 122 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -61854,17 +65128,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* 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 === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 160 /* 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 === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* 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 === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* 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); } } @@ -61875,11 +65149,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 237 /* 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 === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 232 /* 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); @@ -61887,8 +65161,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 236 /* SwitchStatement */: + if (node.kind === 233 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -61903,13 +65177,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* 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 === 230 /* BreakStatement */ + var message = node.kind === 233 /* 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); @@ -61932,13 +65206,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -61951,7 +65225,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 /* TrueKeyword */ || initializer.kind === 88 /* FalseKeyword */ || + initializer.kind === 105 /* TrueKeyword */ || initializer.kind === 90 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -61968,8 +65242,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { - if (node.flags & 4194304 /* Ambient */) { + if (node.parent.parent.kind !== 230 /* ForInStatement */ && node.parent.parent.kind !== 231 /* ForOfStatement */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -61981,11 +65255,11 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -61998,7 +65272,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -62015,8 +65289,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73 /* Identifier */) { - if (name.originalKeywordKind === 112 /* LetKeyword */) { + if (name.kind === 75 /* Identifier */) { + if (name.originalKeywordKind === 114 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -62043,15 +65317,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62069,12 +65343,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96 /* NewKeyword */: + case 98 /* 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 93 /* ImportKeyword */: + case 95 /* 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"); } @@ -62132,7 +65406,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* 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; } @@ -62140,7 +65414,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* 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; } @@ -62148,11 +65422,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { + node.flags & 8388608 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } @@ -62169,13 +65443,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 246 /* TypeAliasDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 259 /* ExportDeclaration */ || + node.kind === 258 /* ExportAssignment */ || + node.kind === 251 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62184,7 +65458,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 === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 224 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62193,17 +65467,13 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304 /* Ambient */) { - // An accessors is already reported about the ambient context - if (ts.isAccessor(node.parent)) { - return getNodeLinks(node).hasReportedStatementInAmbientContext = true; - } + if (node.flags & 8388608 /* Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); - if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { + if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } // We are either parented by another statement, or some sort of block. @@ -62211,7 +65481,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 === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 222 /* Block */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62233,20 +65503,39 @@ 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, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 186 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 282 /* 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 === 39 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62301,11 +65590,19 @@ var ts; } } ts.createTypeChecker = createTypeChecker; + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 243 /* FunctionDeclaration */ && declaration.kind !== 160 /* MethodDeclaration */) || + !!declaration.body; + } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62313,21 +65610,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 254 /* ImportClause */: // For default import + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: // For rename import `x as y` return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 257 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62337,7 +65633,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62408,6 +65703,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62455,7 +65751,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73 /* Identifier */); + var node = createSynthesizedNode(75 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -62536,23 +65832,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(99 /* SuperKeyword */); + return createSynthesizedNode(101 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101 /* ThisKeyword */); + return createSynthesizedNode(103 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97 /* NullKeyword */); + return createSynthesizedNode(99 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103 /* TrueKeyword */); + return createSynthesizedNode(105 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88 /* FalseKeyword */); + return createSynthesizedNode(90 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -62563,44 +65859,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(86 /* ExportKeyword */)); + result.push(createModifier(88 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(126 /* DeclareKeyword */)); + result.push(createModifier(129 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(81 /* DefaultKeyword */)); + result.push(createModifier(83 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(78 /* ConstKeyword */)); + result.push(createModifier(80 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(116 /* PublicKeyword */)); + result.push(createModifier(118 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(114 /* PrivateKeyword */)); + result.push(createModifier(116 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(115 /* ProtectedKeyword */)); + result.push(createModifier(117 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(119 /* AbstractKeyword */)); + result.push(createModifier(121 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(117 /* StaticKeyword */)); + result.push(createModifier(119 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(134 /* ReadonlyKeyword */)); + result.push(createModifier(137 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(122 /* AsyncKeyword */)); + result.push(createModifier(125 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(152 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -62619,7 +65915,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(153 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -62632,7 +65928,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(154 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -62648,7 +65944,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(155 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -62672,7 +65968,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(156 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -62685,7 +65981,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(157 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -62705,12 +66001,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(158 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -62720,8 +66016,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -62729,7 +66025,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(159 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -62746,7 +66042,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(160 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -62759,6 +66055,38 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), + /*typeArguments*/ undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + /* @internal */ + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + /* @internal */ + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -62774,7 +66102,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(161 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -62794,7 +66122,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(162 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62817,7 +66145,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(163 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -62838,7 +66166,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -62846,7 +66174,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -62854,7 +66182,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(166 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -62894,21 +66222,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167 /* TypePredicate */); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(168 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -62922,7 +66260,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(169 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -62930,7 +66268,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(170 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -62938,7 +66276,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(171 /* TypeQuery */); node.exprName = exprName; return node; } @@ -62950,7 +66288,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(172 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -62962,7 +66300,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(173 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -62974,7 +66312,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(174 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -62986,7 +66324,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(175 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -62998,7 +66336,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(176 /* RestType */); node.type = type; return node; } @@ -63010,7 +66348,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(177 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63018,7 +66356,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(178 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63037,7 +66375,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(179 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63055,7 +66393,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(180 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63067,7 +66405,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(187 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63085,7 +66423,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(181 /* ParenthesizedType */); node.type = type; return node; } @@ -63097,12 +66435,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(182 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; + var node = createSynthesizedNode(183 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -63112,7 +66450,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(184 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63126,7 +66464,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(185 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63144,7 +66482,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(186 /* LiteralType */); node.literal = literal; return node; } @@ -63157,7 +66495,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(188 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63169,7 +66507,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(189 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63181,7 +66519,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(190 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63200,7 +66538,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(191 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63214,7 +66552,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(192 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63228,7 +66566,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63236,6 +66574,7 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessChain using updatePropertyAccess. Use updatePropertyAccessChain instead."); // Because we are updating existed propertyAccess we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -63244,22 +66583,62 @@ var ts; : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072 /* NoIndentation */); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(194 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessChain using updateElementAccess. Use updateElementAccessChain instead."); return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194 /* ElementAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(195 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63267,6 +66646,7 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + ts.Debug.assert(!(node.flags & 32 /* OptionalChain */), "Cannot update a CallChain using updateCall. Use updateCallChain instead."); return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -63274,8 +66654,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195 /* CallExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(196 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63291,7 +66691,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(197 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63314,7 +66714,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(198 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63328,7 +66728,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(199 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63340,7 +66740,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(200 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63364,12 +66764,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(201 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -63386,7 +66786,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(202 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63398,7 +66798,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(203 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63410,7 +66810,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(204 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63422,7 +66822,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(205 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63434,7 +66834,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(206 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63447,7 +66847,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(207 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63460,7 +66860,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(208 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63477,11 +66877,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(209 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(58 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -63497,7 +66897,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(210 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -63510,34 +66910,93 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; - function createTemplateHead(text) { - var node = createSynthesizedNode(15 /* TemplateHead */); + var rawTextScanner; + var invalidValueSentinel = {}; + function getCookedText(kind, rawText) { + if (!rawTextScanner) { + rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + } + switch (kind) { + case 14 /* NoSubstitutionTemplateLiteral */: + rawTextScanner.setText("`" + rawText + "`"); + break; + case 15 /* TemplateHead */: + rawTextScanner.setText("`" + rawText + "${"); + break; + case 16 /* TemplateMiddle */: + rawTextScanner.setText("}" + rawText + "${"); + break; + case 17 /* TemplateTail */: + rawTextScanner.setText("}" + rawText + "`"); + break; + } + var token = rawTextScanner.scan(); + if (token === 23 /* CloseBracketToken */) { + token = rawTextScanner.reScanTemplateToken(); + } + if (rawTextScanner.isUnterminated()) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + var tokenValue; + switch (token) { + case 14 /* NoSubstitutionTemplateLiteral */: + case 15 /* TemplateHead */: + case 16 /* TemplateMiddle */: + case 17 /* TemplateTail */: + tokenValue = rawTextScanner.getTokenValue(); + break; + } + if (rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + rawTextScanner.setText(undefined); + return invalidValueSentinel; + } + rawTextScanner.setText(undefined); + return tokenValue; + } + function createTemplateLiteralLikeNode(kind, text, rawText) { + var node = createSynthesizedNode(kind); + node.text = text; + if (rawText === undefined || text === rawText) { + node.rawText = rawText; + } + else { + var cooked = getCookedText(kind, rawText); + if (typeof cooked === "object") { + return ts.Debug.fail("Invalid raw text"); + } + ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'."); + node.rawText = rawText; + } + return node; + } + function createTemplateHead(text, rawText) { + var node = createTemplateLiteralLikeNode(15 /* TemplateHead */, text, rawText); node.text = text; return node; } ts.createTemplateHead = createTemplateHead; - function createTemplateMiddle(text) { - var node = createSynthesizedNode(16 /* TemplateMiddle */); + function createTemplateMiddle(text, rawText) { + var node = createTemplateLiteralLikeNode(16 /* TemplateMiddle */, text, rawText); node.text = text; return node; } ts.createTemplateMiddle = createTemplateMiddle; - function createTemplateTail(text) { - var node = createSynthesizedNode(17 /* TemplateTail */); + function createTemplateTail(text, rawText) { + var node = createTemplateLiteralLikeNode(17 /* TemplateTail */, text, rawText); node.text = text; return node; } ts.createTemplateTail = createTemplateTail; - function createNoSubstitutionTemplateLiteral(text) { - var node = createSynthesizedNode(14 /* NoSubstitutionTemplateLiteral */); - node.text = text; + function createNoSubstitutionTemplateLiteral(text, rawText) { + var node = createTemplateLiteralLikeNode(14 /* NoSubstitutionTemplateLiteral */, text, rawText); return node; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -63549,7 +67008,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(212 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -63561,7 +67020,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(213 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63582,11 +67041,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(214 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(215 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -63600,7 +67059,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(216 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -63614,7 +67073,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(217 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63626,7 +67085,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(218 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -63640,7 +67099,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(220 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -63654,12 +67113,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(221 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(222 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -63673,7 +67132,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(224 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -63688,11 +67147,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(223 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(225 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -63708,7 +67167,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(226 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -63724,7 +67183,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(227 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -63738,7 +67197,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(228 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63752,7 +67211,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(229 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -63770,7 +67229,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(230 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -63786,7 +67245,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(231 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -63804,7 +67263,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(232 /* ContinueStatement */); node.label = asName(label); return node; } @@ -63816,7 +67275,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(233 /* BreakStatement */); node.label = asName(label); return node; } @@ -63828,7 +67287,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(234 /* ReturnStatement */); node.expression = expression; return node; } @@ -63840,7 +67299,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(235 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -63854,7 +67313,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(236 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -63868,7 +67327,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(237 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -63882,7 +67341,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(238 /* ThrowStatement */); node.expression = expression; return node; } @@ -63894,7 +67353,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(239 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -63910,11 +67369,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(240 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(241 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -63931,7 +67390,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(242 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -63944,7 +67403,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(243 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63970,7 +67429,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(244 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63992,7 +67451,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(245 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64014,7 +67473,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(246 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64034,7 +67493,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(247 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64053,8 +67512,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); + var node = createSynthesizedNode(248 /* ModuleDeclaration */); + node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -64072,7 +67531,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(249 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64084,7 +67543,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(250 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64096,7 +67555,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(251 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64108,7 +67567,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(252 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64126,7 +67585,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(253 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64144,7 +67603,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(254 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64158,7 +67617,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(255 /* NamespaceImport */); node.name = name; return node; } @@ -64170,7 +67629,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(256 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64182,7 +67641,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(257 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64196,11 +67655,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(258 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -64213,7 +67672,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(259 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64230,8 +67689,13 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + /* @internal */ + function createEmptyExports() { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(260 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64243,7 +67707,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(261 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64258,7 +67722,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(263 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64272,14 +67736,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(292 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(309 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(313 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64287,7 +67751,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(311 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64295,14 +67759,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(308 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(312 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(306 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(310 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64312,7 +67776,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(297 /* JSDocComment */); + var node = createSynthesizedNode(301 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64326,7 +67790,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(264 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64342,7 +67806,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(265 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64358,7 +67822,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(266 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64374,7 +67838,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(267 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64386,7 +67850,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(268 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64408,11 +67872,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(269 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(270 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64424,7 +67888,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(271 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -64438,7 +67902,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(272 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -64450,7 +67914,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(273 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -64462,7 +67926,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(274 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -64476,7 +67940,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(275 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -64490,7 +67954,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(276 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -64502,7 +67966,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(277 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -64515,7 +67979,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(278 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -64530,7 +67994,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(279 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -64545,7 +68009,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(280 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -64559,7 +68023,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(281 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64572,7 +68036,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(282 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -64593,7 +68057,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(288 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -64677,7 +68141,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(314 /* NotEmittedStatement */); + var node = createSynthesizedNode(318 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -64689,7 +68153,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(322 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64701,7 +68165,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(317 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(321 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -64716,7 +68180,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(315 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(319 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -64732,7 +68196,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 316 /* CommaListExpression */) { + if (node.kind === 320 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -64742,7 +68206,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(316 /* CommaListExpression */); + var node = createSynthesizedNode(320 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -64753,9 +68217,25 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + /* @internal */ + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323 /* SyntheticReferenceExpression */); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + /* @internal */ + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(289 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -64786,7 +68266,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(290 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -64868,8 +68348,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal" /* Internal */: - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } // falls through case "text" /* Text */: (texts || (texts = [])).push(createUnparsedNode(section, node)); @@ -64918,10 +68401,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 283 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 284 /* UnparsedPrepend */; + case "internal" /* Internal */: return 286 /* UnparsedInternalText */; + case "text" /* Text */: return 285 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -64939,14 +68422,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(287 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(291 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -64992,8 +68475,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65036,43 +68519,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28 /* LessThanToken */, right); + return createBinary(left, 29 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60 /* EqualsToken */, right); + return createBinary(left, 62 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 36 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 37 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38 /* PlusToken */, right); + return createBinary(left, 39 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39 /* MinusToken */, right); + return createBinary(left, 40 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44 /* PlusPlusToken */); + return createPostfix(operand, 45 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54 /* AmpersandAmpersandToken */, right); + return createBinary(left, 55 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55 /* BarBarToken */, right); + return createBinary(left, 56 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60 /* QuestionQuestionToken */, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52 /* ExclamationToken */, operand); + return createPrefix(53 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -65092,7 +68579,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -65136,7 +68626,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 === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65201,7 +68691,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -65487,9 +68976,9 @@ var ts; ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createFunctionCall(func, thisArg, argumentsList, location) { return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ thisArg - ].concat(argumentsList)), location); + ], argumentsList)), location); } ts.createFunctionCall = createFunctionCall; function createFunctionApply(func, thisArg, argumentsExpression, location) { @@ -65590,29 +69079,34 @@ var ts; } ts.createExpressionForJsxFragment = createExpressionForJsxFragment; // Helpers - function getHelperName(name) { + /** + * Gets an identifier for the name of an *unscoped* emit helper. + */ + function getUnscopedHelperName(name) { return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } - ts.getHelperName = getHelperName; + ts.getUnscopedHelperName = getUnscopedHelperName; ts.valuesHelper = { name: "typescript:values", + importName: "__values", scoped: false, - text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };" + text: "\n var __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n };" }; function createValuesHelper(context, expression, location) { context.requestEmitHelper(ts.valuesHelper); - return ts.setTextRange(ts.createCall(getHelperName("__values"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), /*typeArguments*/ undefined, [expression]), location); } ts.createValuesHelper = createValuesHelper; ts.readHelper = { name: "typescript:read", + importName: "__read", scoped: false, text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };" }; function createReadHelper(context, iteratorRecord, count, location) { context.requestEmitHelper(ts.readHelper); - return ts.setTextRange(ts.createCall(getHelperName("__read"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), /*typeArguments*/ undefined, count !== undefined ? [iteratorRecord, ts.createLiteral(count)] : [iteratorRecord]), location); @@ -65620,24 +69114,26 @@ var ts; ts.createReadHelper = createReadHelper; ts.spreadHelper = { name: "typescript:spread", + importName: "__spread", scoped: false, text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spread"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadHelper = createSpreadHelper; ts.spreadArraysHelper = { name: "typescript:spreadArrays", + importName: "__spreadArrays", scoped: false, text: "\n var __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n };" }; function createSpreadArraysHelper(context, argumentList, location) { context.requestEmitHelper(ts.spreadArraysHelper); - return ts.setTextRange(ts.createCall(getHelperName("__spreadArrays"), + return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), /*typeArguments*/ undefined, argumentList), location); } ts.createSpreadArraysHelper = createSpreadArraysHelper; @@ -65659,7 +69155,7 @@ var ts; ts.createForOfBindingStatement = createForOfBindingStatement; function insertLeadingStatement(dest, source) { if (ts.isBlock(dest)) { - return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements)); } else { return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); @@ -65670,7 +69166,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -65682,20 +69178,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cacheIdentifiers; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -65710,7 +69206,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99 /* SuperKeyword */) { + else if (callee.kind === 101 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -65722,7 +69218,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 193 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65735,7 +69231,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -65792,14 +69288,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66077,8 +69573,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -66106,9 +69602,9 @@ var ts; function ensureUseStrict(statements) { var foundUseStrict = findUseStrictPrologue(statements); if (!foundUseStrict) { - return ts.setTextRange(ts.createNodeArray([ + return ts.setTextRange(ts.createNodeArray(__spreadArrays([ startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))) - ].concat(statements)), statements); + ], statements)), statements); } return statements; } @@ -66125,7 +69621,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 === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 199 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66159,10 +69655,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(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 /* ArrowFunction */ && binaryOperatorPrecedence > 3) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66174,7 +69670,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 211 /* YieldExpression */) { return false; } return true; @@ -66211,7 +69707,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 38 /* PlusToken */) { + if (binaryOperator === 39 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -66246,10 +69742,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 === 40 /* AsteriskToken */ - || binaryOperator === 50 /* BarToken */ - || binaryOperator === 49 /* AmpersandToken */ - || binaryOperator === 51 /* CaretToken */; + return binaryOperator === 41 /* AsteriskToken */ + || binaryOperator === 51 /* BarToken */ + || binaryOperator === 50 /* AmpersandToken */ + || binaryOperator === 52 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -66262,22 +69758,20 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(209 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -66312,8 +69806,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: needsParens = true; } } @@ -66329,9 +69823,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66354,7 +69848,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66392,7 +69886,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66403,29 +69897,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 200 /* FunctionExpression */ || kind === 201 /* 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 === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 192 /* ObjectLiteralExpression */ || leftmostExpressionKind === 200 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 179 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -66433,9 +69927,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 171 /* TypeQuery */: + case 183 /* TypeOperator */: + case 180 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -66461,28 +69955,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 315 /* PartiallyEmittedExpression */: + case 216 /* AsExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 217 /* NonNullExpression */: + case 319 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -66491,15 +69985,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 192 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 316 /* CommaListExpression */; + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 320 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -66512,13 +70006,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 217 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -66543,7 +70037,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 217 /* NonNullExpression */) { node = node.expression; } return node; @@ -66551,11 +70045,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 315 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -66573,7 +70067,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -66598,6 +70092,60 @@ var ts; return emitNode && emitNode.externalHelpersModuleName; } ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function hasRecordedExternalHelpers(sourceFile) { + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers); + } + ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers; + function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) { + if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var namedBindings = void 0; + var moduleKind = ts.getEmitModuleKind(compilerOptions); + if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + // use named imports + var helpers = ts.getEmitHelpers(sourceFile); + if (helpers) { + var helperNames = []; + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!helper.scoped) { + var importName = helper.importName; + if (importName) { + ts.pushIfUnique(helperNames, importName); + } + } + } + if (ts.some(helperNames)) { + helperNames.sort(ts.compareStringsCaseSensitive); + // Alias the imports if the names are used somewhere in the file. + // NOTE: We don't need to care about global import collisions as this is a module. + namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) + ? ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)) + : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); })); + var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); + var emitNode = ts.getOrCreateEmitNode(parseNode); + emitNode.externalHelpers = true; + } + } + } + else { + // use a namespace import + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault); + if (externalHelpersModuleName) { + namedBindings = ts.createNamespaceImport(externalHelpersModuleName); + } + } + if (namedBindings) { + var externalHelpersImportDeclaration = ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText)); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + return externalHelpersImportDeclaration; + } + } + } + ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded; function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) { if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) { var externalHelpersModuleName = getExternalHelpersModuleName(node); @@ -66612,8 +70160,8 @@ var ts; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { - for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { - var helper = helpers_2[_i]; + for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) { + var helper = helpers_3[_i]; if (!helper.scoped) { create = true; break; @@ -66638,10 +70186,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 253 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 259 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -66760,7 +70308,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -66772,11 +70320,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -66808,12 +70356,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 155 /* Parameter */: + case 190 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 212 /* SpreadElement */: + case 281 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -66825,7 +70373,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 190 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -66837,7 +70385,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -66849,7 +70397,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -66872,13 +70420,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -66918,11 +70466,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67045,11 +70593,9 @@ var ts; function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); - if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { - statements = ts.setTextRange(ts.createNodeArray([ts.createExpressionStatement(ts.createLiteral("use strict"))].concat(statements)), statements); - } - var declarations = context.endLexicalEnvironment(); - return ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements); + if (ensureUseStrict) + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; /** @@ -67083,278 +70629,287 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */) || kind === 182 /* ThisType */) { return node; } switch (kind) { // Names - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 155 /* 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 153 /* Decorator */: + case 156 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 157 /* 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 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 159 /* 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 157 /* MethodDeclaration */: + case 160 /* 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 158 /* Constructor */: + case 161 /* 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 159 /* GetAccessor */: + case 162 /* 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 160 /* SetAccessor */: + case 163 /* 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 161 /* CallSignature */: + case 164 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 166 /* 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 164 /* TypePredicate */: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 167 /* TypePredicate */: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 174 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 176 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 177 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 179 /* 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 177 /* InferType */: + case 180 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 187 /* 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 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 185 /* 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 183 /* LiteralType */: + case 186 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 190 /* 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 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 200 /* 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 198 /* ArrowFunction */: + case 201 /* 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 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 209 /* 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 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 213 /* 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 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 222 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 226 /* 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 224 /* DoStatement */: + case 227 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 229 /* 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 227 /* ForInStatement */: + case 230 /* 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 228 /* ForOfStatement */: + case 231 /* 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 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 243 /* 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 241 /* ClassDeclaration */: + case 244 /* 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 242 /* InterfaceDeclaration */: + case 245 /* 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 243 /* TypeAliasDeclaration */: + case 246 /* 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 244 /* EnumDeclaration */: + case 247 /* 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 245 /* ModuleDeclaration */: + case 248 /* 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 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 252 /* 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 250 /* ImportDeclaration */: + case 253 /* 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 251 /* ImportClause */: + case 254 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 259 /* 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 257 /* NamedExports */: + case 260 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -67396,58 +70951,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 167 /* TypePredicate */ && kind <= 186 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 314 /* NotEmittedStatement */: + case 221 /* SemicolonClassElement */: + case 223 /* EmptyStatement */: + case 214 /* OmittedExpression */: + case 240 /* DebuggerStatement */: + case 318 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 155 /* 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 153 /* Decorator */: + case 156 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 157 /* 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 155 /* PropertyDeclaration */: + case 158 /* 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 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67456,12 +71011,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 161 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67469,7 +71024,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67477,50 +71032,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 196 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -67528,123 +71083,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 201 /* 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 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 213 /* 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 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 216 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 222 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 229 /* 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 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67653,7 +71208,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -67661,140 +71216,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 247 /* 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 245 /* ModuleDeclaration */: + case 248 /* 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 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* 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 250 /* ImportDeclaration */: + case 253 /* 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 251 /* ImportClause */: + case 254 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 259 /* 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 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -67867,7 +71422,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 !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 215 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -67940,19 +71495,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ 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); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68155,12 +71711,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ 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 @@ -68172,6 +71727,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -68540,7 +72096,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -68582,25 +72138,31 @@ var ts; var hasExportDefault = false; var exportEquals; var hasExportStarsToExportValues = false; - var hasImportStarOrImportDefault = false; + var hasImportStar = false; + var hasImportDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); - hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); + if (!hasImportStar && getImportNeedsImportStarHelper(node)) { + hasImportStar = true; + } + if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) { + hasImportDefault = true; + } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 252 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -68630,13 +72192,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -68644,7 +72206,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -68664,7 +72226,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -68686,12 +72248,8 @@ var ts; break; } } - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault); - var externalHelpersImportDeclaration = externalHelpersModuleName && ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault); if (externalHelpersImportDeclaration) { - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); externalImports.unshift(externalHelpersImportDeclaration); } return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; @@ -68766,7 +72324,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -68796,42 +72354,28 @@ var ts; } ts.helperString = helperString; /** - * Gets all property declarations with initializers on either the static or instance side of a class. + * Gets all the static or all the instance property declarations of a class * * @param node The class node. * @param isStatic A value indicating whether to get properties from the static or instance side of the class. */ - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); - } - ts.getInitializedProperties = getInitializedProperties; - /** - * Gets a value indicating whether a class element is a static property declaration with an initializer. - * - * @param member The class element node. - */ - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); - } - ts.isStaticInitializedProperty = isStaticInitializedProperty; - /** - * Gets a value indicating whether a class element is an instance property declaration with an initializer. - * - * @param member The class element node. - */ - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; + ts.getProperties = getProperties; /** - * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. + * Is a class element either a static or an instance property declaration with an initializer? * * @param member The class element node. * @param isStatic A value indicating whether the member should be a static or instance member. */ - function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ - && member.initializer !== undefined; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; + } + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -69279,6 +72823,7 @@ var ts; } ts.restHelper = { name: "typescript:rest", + importName: "__rest", scoped: false, text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n };" }; @@ -69303,7 +72848,7 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), + return ts.createCall(ts.getUnscopedHelperName("__rest"), /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) @@ -69356,8 +72901,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -69383,14 +72928,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* 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 === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -69441,16 +72986,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 249 /* ModuleBlock */: + case 222 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -69462,7 +73007,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 === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 244 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -69505,10 +73050,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -69529,13 +73074,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -69555,11 +73100,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 259 /* ExportDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 254 /* ImportClause */ || + (node.kind === 252 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 263 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -69583,19 +73128,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -69605,7 +73150,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 86 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 88 /* ExportKeyword */) { return undefined; } return node; @@ -69622,67 +73167,71 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 124 /* BooleanKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 133 /* NeverKeyword */: - case 107 /* VoidKeyword */: - case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 137 /* ReadonlyKeyword */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 172 /* TypeLiteral */: + case 167 /* TypePredicate */: + case 154 /* TypeParameter */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 127 /* BooleanKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 136 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 143 /* SymbolKeyword */: + case 170 /* ConstructorType */: + case 169 /* FunctionType */: + case 171 /* TypeQuery */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 181 /* ParenthesizedType */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 166 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 156 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 158 /* 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 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 245 /* 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 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69692,7 +73241,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -69702,35 +73251,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -69740,35 +73289,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -69806,7 +73355,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -69835,7 +73384,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1 /* Export */))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); @@ -70072,7 +73621,7 @@ var ts; var members = []; var constructor = ts.getFirstConstructorWithBody(node); var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (parametersWithPropertyAssignments) { for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) { var parameter = parametersWithPropertyAssignments_1[_i]; @@ -70178,12 +73727,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70336,7 +73885,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 158 /* 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() @@ -70437,13 +73986,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(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -70459,10 +74008,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 158 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -70472,7 +74021,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -70483,12 +74032,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; } return false; @@ -70505,15 +74054,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -70550,7 +74099,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 162 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -70595,69 +74144,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: - case 124 /* BooleanKeyword */: + case 167 /* TypePredicate */: + case 127 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return ts.createIdentifier("String"); - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: - if (node.operator === 134 /* ReadonlyKeyword */) { + case 183 /* TypeOperator */: + if (node.operator === 137 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 171 /* TypeQuery */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 172 /* TypeLiteral */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 182 /* ThisType */: + case 187 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -70668,15 +74217,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var typeNode = types_18[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* 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); @@ -70756,12 +74305,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73 /* Identifier */) { + if (node.left.kind === 75 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -70777,7 +74326,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* 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); @@ -70785,7 +74334,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -70869,7 +74418,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 110 /* ImplementsKeyword */) { + if (node.token === 112 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -70919,7 +74468,7 @@ var ts; } function transformConstructorBody(body, constructor) { var parametersWithPropertyAssignments = constructor && - ts.filter(constructor.parameters, ts.isParameterPropertyDeclaration); + ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); }); if (!ts.some(parametersWithPropertyAssignments)) { return ts.visitFunctionBody(body, visitor, context); } @@ -71332,12 +74881,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 === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 288 /* 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 === 244 /* EnumDeclaration */) { + if (node.kind === 247 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -71462,7 +75011,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 249 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -71508,13 +75057,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 !== 246 /* ModuleBlock */) { + if (body.kind !== 249 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -71555,7 +75104,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 255 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -71768,7 +75317,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -71776,7 +75325,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(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -71786,17 +75335,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(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(75 /* Identifier */); + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(248 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 248 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 247 /* EnumDeclaration */; } /** * Hook for node emit. @@ -71855,11 +75404,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -71897,9 +75446,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 !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 288 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 248 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 247 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -71921,9 +75470,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } return substitute; @@ -71949,18 +75499,19 @@ var ts; } } context.requestEmitHelper(ts.decorateHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } ts.decorateHelper = { name: "typescript:decorate", + importName: "__decorate", scoped: false, priority: 2, text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" }; function createMetadataHelper(context, metadataKey, metadataValue) { context.requestEmitHelper(ts.metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), + return ts.createCall(ts.getUnscopedHelperName("__metadata"), /*typeArguments*/ undefined, [ ts.createLiteral(metadataKey), metadataValue @@ -71968,13 +75519,14 @@ var ts; } ts.metadataHelper = { name: "typescript:metadata", + importName: "__metadata", scoped: false, priority: 3, text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" }; function createParamHelper(context, expression, parameterOffset, location) { context.requestEmitHelper(ts.paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), /*typeArguments*/ undefined, [ ts.createLiteral(parameterOffset), expression @@ -71982,6 +75534,7 @@ var ts; } ts.paramHelper = { name: "typescript:param", + importName: "__param", scoped: false, priority: 4, text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" @@ -72024,7 +75577,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -72035,11 +75590,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72051,20 +75606,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72074,7 +75629,7 @@ var ts; var savedPendingStatements = pendingStatements; pendingStatements = []; var visitedNode = ts.visitEachChild(node, visitor, context); - var statement = ts.some(pendingStatements) ? [visitedNode].concat(pendingStatements) : + var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) : visitedNode; pendingStatements = savedPendingStatements; return statement; @@ -72107,7 +75662,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var statements = [ ts.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -72123,9 +75678,9 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -72143,9 +75698,9 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { @@ -72157,7 +75712,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -72198,8 +75753,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -72212,7 +75767,7 @@ var ts; /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, /*isStatic*/ false); + var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false); // Only generate synthetic constructor when there are property initializers to move. if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); @@ -72244,7 +75799,7 @@ var ts; if (constructor && constructor.body) { var parameterPropertyDeclarationCount = 0; for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) { - if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]))) { + if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) { parameterPropertyDeclarationCount++; } else { @@ -72256,7 +75811,7 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -72273,7 +75828,7 @@ var ts; * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -72310,19 +75865,29 @@ var ts; */ function transformInitializedProperty(property, receiver) { // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72342,7 +75907,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -72426,6 +75991,7 @@ var ts; var hasSuperElementAccess; /** A set of node IDs for generated super accessors (variable statements). */ var substitutedSuperAccessors = []; + var topLevel; // Save the previous transformation hooks. var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; @@ -72437,38 +76003,57 @@ var ts; if (node.isDeclarationFile) { return node; } + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitor(node) { if ((node.transformFlags & 32 /* ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 243 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -72476,27 +76061,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 222 /* Block */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 235 /* WithStatement */: + case 237 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -72697,7 +76282,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 === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 201 /* 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 @@ -72720,7 +76305,7 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -72747,7 +76332,7 @@ var ts; result = block; } else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); + var expression = createAwaiterHelper(context, !topLevel, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body)); var declarations = endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(expression); @@ -72788,17 +76373,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -72846,23 +76431,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -72874,19 +76459,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -72946,23 +76531,24 @@ var ts; ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; ts.awaiterHelper = { name: "typescript:awaiter", + importName: "__awaiter", scoped: false, priority: 5, text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n };" }; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; - return ts.createCall(ts.getHelperName("__awaiter"), + return ts.createCall(ts.getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), generatorFunc @@ -72996,9 +76582,11 @@ var ts; context.onEmitNode = onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; + var exportedVariableStatement = false; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; + var topLevel; /** Keeps track of property names accessed on super (`super.x`) within async functions. */ var capturedSuperProperties; /** Whether the async function contains an element access on super (`super[x]`). */ @@ -73010,6 +76598,8 @@ var ts; if (node.isDeclarationFile) { return node; } + exportedVariableStatement = false; + topLevel = ts.isEffectiveStrictModeSourceFile(node, compilerOptions); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -73021,68 +76611,85 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122 /* AsyncKeyword */) { + if (node.kind === 125 /* AsyncKeyword */) { return undefined; } return node; } + function doOutsideOfTopLevel(cb, value) { + if (topLevel) { + topLevel = false; + var result = cb(value); + topLevel = true; + return result; + } + return cb(value); + } + function visitDefault(node) { + return ts.visitEachChild(node, visitor, context); + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 16 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 238 /* VariableDeclaration */: + case 224 /* VariableStatement */: + return visitVariableStatement(node); + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: - return visitConstructorDeclaration(node); - case 157 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - return visitGetAccessorDeclaration(node); - case 160 /* SetAccessor */: - return visitSetAccessorDeclaration(node); - case 240 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: - return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + return doOutsideOfTopLevel(visitConstructorDeclaration, node); + case 160 /* MethodDeclaration */: + return doOutsideOfTopLevel(visitMethodDeclaration, node); + case 162 /* GetAccessor */: + return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); + case 163 /* SetAccessor */: + return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); + case 243 /* FunctionDeclaration */: + return doOutsideOfTopLevel(visitFunctionDeclaration, node); + case 200 /* FunctionExpression */: + return doOutsideOfTopLevel(visitFunctionExpression, node); + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -73115,7 +76722,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 231 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73127,7 +76734,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 === 278 /* SpreadAssignment */) { + if (e.kind === 281 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73136,7 +76743,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 279 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73170,7 +76777,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 192 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -73215,23 +76822,44 @@ var ts; var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { - block = ts.updateBlock(block, [ + block = ts.updateBlock(block, __spreadArrays([ ts.createVariableStatement(/*modifiers*/ undefined, visitedBindings) - ].concat(block.statements)); + ], block.statements)); } return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, /*type*/ undefined, /*initializer*/ undefined), block); } return ts.visitEachChild(node, visitor, context); } + function visitVariableStatement(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = true; + var visited = ts.visitEachChild(node, visitor, context); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a VariableDeclaration node with a binding pattern. * * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { + if (exportedVariableStatement) { + var savedExportedVariableStatement = exportedVariableStatement; + exportedVariableStatement = false; + var visited = visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ true); + exportedVariableStatement = savedExportedVariableStatement; + return visited; + } + return visitVariableDeclarationWorker(node, /*exportedVariableStatement*/ false); + } + function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. if (ts.isBindingPattern(node.name) && node.name.transformFlags & 8192 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */); + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } @@ -73446,10 +77074,10 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))))); + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); @@ -73515,17 +77143,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(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -73573,23 +77201,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -73601,19 +77229,19 @@ var ts; ? substitutePropertyAccessExpression(expression) : substituteElementAccessExpression(expression); return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, __spreadArrays([ ts.createThis() - ].concat(node.arguments)); + ], node.arguments)); } return node; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73629,65 +77257,69 @@ var ts; ts.transformES2018 = transformES2018; ts.assignHelper = { name: "typescript:assign", + importName: "__assign", scoped: false, priority: 1, text: "\n var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };" }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); - return ts.createCall(ts.getHelperName("__assign"), + return ts.createCall(ts.getUnscopedHelperName("__assign"), /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; ts.awaitHelper = { name: "typescript:await", + importName: "__await", scoped: false, text: "\n var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }" }; function createAwaitHelper(context, expression) { context.requestEmitHelper(ts.awaitHelper); - return ts.createCall(ts.getHelperName("__await"), /*typeArguments*/ undefined, [expression]); + return ts.createCall(ts.getUnscopedHelperName("__await"), /*typeArguments*/ undefined, [expression]); } ts.asyncGeneratorHelper = { name: "typescript:asyncGenerator", + importName: "__asyncGenerator", scoped: false, text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; - function createAsyncGeneratorHelper(context, generatorFunc) { + function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__asyncGenerator"), + return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ - ts.createThis(), + hasLexicalThis ? ts.createThis() : ts.createVoidZero(), ts.createIdentifier("arguments"), generatorFunc ]); } ts.asyncDelegator = { name: "typescript:asyncDelegator", + importName: "__asyncDelegator", scoped: false, text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); } ts.asyncValues = { name: "typescript:asyncValues", + importName: "__asyncValues", scoped: false, text: "\n var __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n };" }; function createAsyncValuesHelper(context, expression, location) { context.requestEmitHelper(ts.asyncValues); - return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), /*typeArguments*/ undefined, [expression]), location); } })(ts || (ts = {})); @@ -73707,7 +77339,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -73726,6 +77358,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -73738,10 +77371,143 @@ var ts; return node; } switch (node.kind) { + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + var updated = visitOptionalExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208 /* BinaryExpression */: + if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a.b` -> { expression: `(_a = a).b`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a[b]` -> { expression: `(_a = a)[b]`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193 /* PropertyAccessExpression */: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194 /* ElementAccessExpression */: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193 /* PropertyAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194 /* ElementAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195 /* CallExpression */: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, + /*typeArguments*/ undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createNull()), ts.createToken(55 /* AmpersandAmpersandToken */), ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -73776,13 +77542,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73792,13 +77558,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -73873,7 +77639,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 274 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -73967,7 +77733,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 264 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74273,7 +78039,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74281,9 +78047,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74486,13 +78252,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 234 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 222 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -74505,72 +78271,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 73 /* Identifier */: + case 75 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -74581,28 +78347,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitSpreadElement(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -74693,14 +78459,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 === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 233 /* 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 === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -74711,7 +78477,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -74969,7 +78735,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -75107,11 +78873,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 234 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 226 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75119,7 +78885,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 222 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75274,10 +79040,10 @@ var ts; return false; } // `declarationName` is the name of the local declaration for the parameter. - var declarationName = parameter.name.kind === 73 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var declarationName = parameter.name.kind === 75 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 73 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; @@ -75301,7 +79067,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73 /* Identifier */) { + if (parameter.name.kind !== 75 /* Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); @@ -75317,7 +79083,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 201 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -75338,25 +79104,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 161 /* 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 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* 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 */), 95 /* 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 */), 97 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -75385,20 +79151,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -75424,12 +79190,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), - /*location*/ member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. @@ -75586,7 +79362,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 === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 243 /* FunctionDeclaration */ || node.kind === 200 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -75630,7 +79406,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 201 /* 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 @@ -75698,9 +79474,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 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -75719,9 +79495,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 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -75756,7 +79532,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 60 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -75930,14 +79706,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76125,7 +79901,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 153 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76180,7 +79956,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -76246,11 +80022,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 229 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 231 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 227 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 228 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76275,11 +80051,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 242 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -76430,7 +80206,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -76492,7 +80268,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(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -76530,7 +80306,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -76541,7 +80317,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, 60 /* EqualsToken */, source); + return ts.createBinary(target, 62 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -76554,7 +80330,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -76568,7 +80344,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(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -76589,10 +80365,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -76678,20 +80454,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -76767,7 +80543,7 @@ var ts; } function addStatementToStartOfBlock(block, statement) { var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement); - return ts.updateBlock(block, [statement].concat(transformedStatements)); + return ts.updateBlock(block, __spreadArrays([statement], transformedStatements)); } /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a @@ -76798,7 +80574,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -76851,7 +80627,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 /* SuperKeyword */ || + if (expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -76975,10 +80751,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 4096 /* ContainsRestOrSpread */ || - node.expression.kind === 99 /* SuperKeyword */ || + node.expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -76996,7 +80772,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -77008,10 +80784,10 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -77035,7 +80811,7 @@ var ts; // [output] // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), /*typeArguments*/ undefined, []); } return ts.visitEachChild(node, visitor, context); @@ -77199,13 +80975,16 @@ var ts; // Find original source text, since we need to emit the raw strings of the tagged template. // The raw strings contain the (escaped) strings of what the user wrote. // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + 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 // and LineTerminatorSequences are normalized to for both TV and TRV. @@ -77296,13 +81075,11 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 98 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return ts.createFileLevelUniqueName("_newTarget"); } @@ -77334,7 +81111,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } /** @@ -77344,14 +81121,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableSubstitution(103 /* ThisKeyword */); + context.enableEmitNotification(161 /* Constructor */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(201 /* ArrowFunction */); + context.enableEmitNotification(200 /* FunctionExpression */); + context.enableEmitNotification(243 /* FunctionDeclaration */); } } /** @@ -77392,10 +81169,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 241 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -77408,9 +81185,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -77477,19 +81254,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -77499,7 +81276,7 @@ var ts; ts.transformES2015 = transformES2015; function createExtendsHelper(context, name) { context.requestEmitHelper(ts.extendsHelper); - return ts.createCall(ts.getHelperName("__extends"), + return ts.createCall(ts.getUnscopedHelperName("__extends"), /*typeArguments*/ undefined, [ name, ts.createFileLevelUniqueName("_super") @@ -77507,7 +81284,7 @@ var ts; } function createTemplateObjectHelper(context, cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getHelperName("__makeTemplateObject"), + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), /*typeArguments*/ undefined, [ cooked, raw @@ -77515,12 +81292,14 @@ var ts; } ts.extendsHelper = { name: "typescript:extends", + importName: "__extends", scoped: false, priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; ts.templateObjectHelper = { name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", scoped: false, priority: 0, text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" @@ -77542,15 +81321,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(266 /* JsxOpeningElement */); + context.enableEmitNotification(267 /* JsxClosingElement */); + context.enableEmitNotification(265 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(279 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -77569,9 +81348,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -77628,7 +81407,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */) { + if (token !== undefined && token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -77903,13 +81682,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -77922,24 +81701,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -77960,21 +81739,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -77987,9 +81766,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78188,23 +81967,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 /* FirstCompoundAssignment */ - && kind <= 72 /* LastCompoundAssignment */; + return kind >= 63 /* FirstCompoundAssignment */ + && kind <= 74 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61 /* PlusEqualsToken */: return 38 /* PlusToken */; - case 62 /* MinusEqualsToken */: return 39 /* MinusToken */; - case 63 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; - case 64 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; - case 65 /* SlashEqualsToken */: return 42 /* SlashToken */; - case 66 /* PercentEqualsToken */: return 43 /* PercentToken */; - case 67 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; - case 68 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; - case 70 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; - case 71 /* BarEqualsToken */: return 50 /* BarToken */; - case 72 /* CaretEqualsToken */: return 51 /* CaretToken */; + case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; + case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; + case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; + case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; + case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; + case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; + case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; + case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; + case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; + case 73 /* BarEqualsToken */: return 51 /* BarToken */; + case 74 /* CaretEqualsToken */: return 52 /* CaretToken */; } } /** @@ -78217,7 +81996,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78229,7 +82008,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -78316,7 +82095,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 === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -78455,13 +82234,13 @@ var ts; temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement - ? [leadingElement].concat(initialElements) : initialElements)); + ? __spreadArrays([leadingElement], initialElements) : initialElements)); leadingElement = undefined; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); + : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { var hasAssignedTemp = temp !== undefined; @@ -78470,7 +82249,7 @@ var ts; } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) - : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); + : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine)); leadingElement = undefined; expressions = []; } @@ -78605,35 +82384,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79063,7 +82842,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 276 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79076,7 +82855,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79249,11 +83028,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -79388,7 +83166,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -80214,7 +83992,7 @@ var ts; ts.transformGenerators = transformGenerators; function createGeneratorHelper(context, body) { context.requestEmitHelper(ts.generatorHelper); - return ts.createCall(ts.getHelperName("__generator"), + return ts.createCall(ts.getUnscopedHelperName("__generator"), /*typeArguments*/ undefined, [ts.createThis(), body]); } // The __generator helper is used by down-level transformations to emulate the runtime @@ -80278,6 +84056,7 @@ var ts; // For examples of how these are used, see the comments in ./transformers/generators.ts ts.generatorHelper = { name: "typescript:generator", + importName: "__generator", scoped: false, priority: 6, text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" @@ -80304,12 +84083,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(288 /* 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. @@ -80407,14 +84186,14 @@ var ts; // define(moduleName?, ["module1", "module2"], function ... var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ ts.createExpressionStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ // Add the dependency array argument: // // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : [ + ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), // Add the module body function argument: // // function (require, exports, module1, module2) ... @@ -80424,10 +84203,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ]))) ]), @@ -80462,11 +84241,11 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ + /*typeArguments*/ undefined, __spreadArrays((moduleName ? [moduleName] : []), [ + ts.createArrayLiteral(__spreadArrays([ ts.createLiteral("require"), ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), + ], aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") ]))) ]))) @@ -80494,10 +84273,10 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ + /*typeParameters*/ undefined, __spreadArrays([ ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") - ].concat(importAliasNames), + ], importAliasNames), /*type*/ undefined, transformAsynchronousModuleBody(node)) ])) ]), @@ -80637,23 +84416,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 317 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -80680,24 +84459,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -80812,7 +84591,7 @@ var ts; var promise = ts.createNew(ts.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getHelperName("__importStar")]); + return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), /*typeArguments*/ undefined, [ts.getUnscopedHelperName("__importStar")]); } return promise; } @@ -80826,7 +84605,7 @@ var ts; var requireCall = ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); if (compilerOptions.esModuleInterop) { context.requestEmitHelper(ts.importStarHelper); - requireCall = ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); + requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } var func; if (languageVersion >= 2 /* ES2015 */) { @@ -80860,11 +84639,11 @@ var ts; } if (ts.getImportNeedsImportStarHelper(node)) { context.requestEmitHelper(ts.importStarHelper); - return ts.createCall(ts.getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (ts.getImportNeedsImportDefaultHelper(node)) { context.requestEmitHelper(ts.importDefaultHelper); - return ts.createCall(ts.getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); + return ts.createCall(ts.getUnscopedHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } return innerExpr; } @@ -81175,7 +84954,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81230,10 +85009,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -81415,8 +85194,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -81432,7 +85211,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -81494,12 +85273,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -81520,7 +85299,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -81588,15 +85367,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 === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* 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 === 204 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 207 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -81636,7 +85415,7 @@ var ts; function createExportStarHelper(context, module) { var compilerOptions = context.getCompilerOptions(); return compilerOptions.importHelpers - ? ts.createCall(ts.getHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) + ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]); } // emit helper for dynamic import @@ -81648,12 +85427,14 @@ var ts; // emit helper for `import * as Name from "foo"` ts.importStarHelper = { name: "typescript:commonjsimportstar", + importName: "__importStar", scoped: false, text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" }; // emit helper for `import Name from "foo"` ts.importDefaultHelper = { name: "typescript:commonjsimportdefault", + importName: "__importDefault", scoped: false, text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};" }; @@ -81670,16 +85451,18 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(218 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. var noSubstitutionMap = []; // Set of nodes for which substitution rules should be ignored for each file. + var contextObjectMap = []; // The context object associated with a source file. var currentSourceFile; // The current file. var moduleInfo; // ExternalModuleInfo for the current file. var exportFunction; // The export function for the current file. @@ -81718,7 +85501,7 @@ var ts; // existing identifiers. exportFunction = ts.createUniqueName("exports"); exportFunctionsMap[id] = exportFunction; - contextObject = ts.createUniqueName("context"); + contextObject = contextObjectMap[id] = ts.createUniqueName("context"); // Add the body of the module. var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); @@ -81896,7 +85679,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 259 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -81921,7 +85704,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 259 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -81990,28 +85773,28 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; + var group_2 = dependencyGroups_1[_i]; // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82061,15 +85844,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82245,7 +86028,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 === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 288 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -82309,7 +86092,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 === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -82371,10 +86154,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82554,43 +86337,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node); - case 317 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 318 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -82837,7 +86620,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 288 /* SourceFile */; } else { return false; @@ -82853,8 +86636,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -82870,12 +86653,13 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; exportFunction = exportFunctionsMap[id]; noSubstitution = noSubstitutionMap[id]; + contextObject = contextObjectMap[id]; if (noSubstitution) { delete noSubstitutionMap[id]; } @@ -82883,6 +86667,7 @@ var ts; currentSourceFile = undefined; moduleInfo = undefined; exportFunction = undefined; + contextObject = undefined; noSubstitution = undefined; } else { @@ -82918,7 +86703,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -82952,13 +86737,15 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); + case 218 /* MetaProperty */: + return substituteMetaProperty(node); } return node; } @@ -83043,22 +86830,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 === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* 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 === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 207 /* 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 === 204 /* PostfixUnaryExpression */) { - expression = node.operator === 44 /* PlusPlusToken */ + if (node.kind === 207 /* PostfixUnaryExpression */) { + expression = node.operator === 45 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -83067,6 +86854,12 @@ var ts; } return node; } + function substituteMetaProperty(node) { + if (ts.isImportMeta(node)) { + return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta")); + } + return node; + } /** * Gets the exports of a name. * @@ -83079,7 +86872,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83118,24 +86911,20 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); - context.enableSubstitution(73 /* Identifier */); - var currentSourceFile; + context.enableEmitNotification(288 /* SourceFile */); + context.enableSubstitution(75 /* Identifier */); + var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); - if (externalHelpersModuleName) { + var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions); + if (externalHelpersImportDeclaration) { var statements = []; var statementOffset = ts.addPrologue(statements, node.statements); - var tslibImport = ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - ts.addEmitFlags(tslibImport, 67108864 /* NeverApplyImportHelper */); - ts.append(statements, tslibImport); + ts.append(statements, externalHelpersImportDeclaration); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -83147,10 +86936,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83171,9 +86960,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { if (ts.isSourceFile(node)) { - currentSourceFile = node; + helperNameSubstitutions = ts.createMap(); previousOnEmitNode(hint, node, emitCallback); - currentSourceFile = undefined; + helperNameSubstitutions = undefined; } else { previousOnEmitNode(hint, node, emitCallback); @@ -83190,19 +86979,18 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (ts.isIdentifier(node) && hint === 1 /* Expression */) { - return substituteExpressionIdentifier(node); + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + return substituteHelperName(node); } return node; } - function substituteExpressionIdentifier(node) { - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { - var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); - if (externalHelpersModuleName) { - return ts.createPropertyAccess(externalHelpersModuleName, node); - } + function substituteHelperName(node) { + var name = ts.idText(node); + var substitution = helperNameSubstitutions.get(name); + if (!substitution) { + helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name)); } - return node; + return substitution; } } ts.transformES2015Module = transformES2015Module; @@ -83258,7 +87046,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83287,7 +87075,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83313,7 +87101,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node) && ts.hasModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8 /* Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -83334,7 +87122,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 === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* 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 : @@ -83343,8 +87131,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 === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 158 /* PropertyDeclaration */ || node.kind === 193 /* PropertyAccessExpression */ || node.kind === 157 /* PropertySignature */ || + (node.kind === 155 /* 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 ? @@ -83353,7 +87141,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 === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 244 /* ClassDeclaration */ || node.kind === 155 /* 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 : @@ -83378,7 +87166,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* 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 */)) { @@ -83417,26 +87205,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* 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 161 /* CallSignature */: + case 164 /* 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 163 /* IndexSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83444,7 +87232,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 === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* 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 : @@ -83458,7 +87246,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 243 /* 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 : @@ -83483,30 +87271,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 161 /* 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 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 165 /* ConstructSignature */: + case 170 /* 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 161 /* CallSignature */: + case 164 /* 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 163 /* IndexSignature */: + case 166 /* 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 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -83514,7 +87302,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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* 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 : @@ -83527,13 +87315,20 @@ 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 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 243 /* FunctionDeclaration */: + case 169 /* 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 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -83542,39 +87337,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 185 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* 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 === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* 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 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 169 /* FunctionType */: + case 243 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -83589,9 +87384,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 244 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 /* 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; } @@ -83626,11 +87421,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; // No declaration diagnostics for js for now - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -83640,7 +87432,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 155 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -83701,9 +87493,9 @@ var ts; var currentSourceFile; var refs; var libs; + var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -83786,20 +87578,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -83812,18 +87613,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { 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(126 /* 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 statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : 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 === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -83860,12 +87661,19 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - var emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(combinedStatements.concat([createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -83907,6 +87715,15 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { + var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, host.getSourceFiles(), + /*preferences*/ undefined, host.redirectTargetsMap); + if (!ts.pathIsRelative(specifier)) { + // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration + // via a non-relative name, emit a type reference directive to that non-relative name, rather than + // a relative path to the declaration file + recordTypeReferenceDirectivesIfNecessary([specifier]); + return; + } var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) { @@ -83943,11 +87760,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 189 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -83955,20 +87772,20 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 214 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); } } - function ensureParameter(p, modifierMask) { + function ensureParameter(p, modifierMask, type) { var oldDiag; if (!suppressNewDiagnosticContexts) { oldDiag = getSymbolAccessibilityDiagnostic; 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(56 /* 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(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -83993,19 +87810,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 155 /* 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(121 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* 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(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -84013,12 +87830,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 155 /* Parameter */ + || node.kind === 158 /* PropertyDeclaration */ + || node.kind === 157 /* 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)); @@ -84029,26 +87846,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(124 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return false; } return false; @@ -84075,6 +87892,33 @@ var ts; } return ts.createNodeArray(newParams, params.hasTrailingComma); } + function updateAccessorParamsList(input, isPrivate) { + var newParams; + if (!isPrivate) { + var thisParameter = ts.getThisParameter(input); + if (thisParameter) { + newParams = [ensureParameter(thisParameter)]; + } + } + if (ts.isSetAccessorDeclaration(input)) { + var newValueParameter = void 0; + if (!isPrivate) { + var valueParameter = ts.getSetAccessorValueParameter(input); + if (valueParameter) { + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + newValueParameter = ensureParameter(valueParameter, /*modifierMask*/ undefined, accessorType); + } + } + if (!newValueParameter) { + newValueParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "value"); + } + newParams = ts.append(newParams, newValueParameter); + } + return ts.createNodeArray(newParams || ts.emptyArray); + } function ensureTypeParams(node, params) { return ts.hasModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } @@ -84102,7 +87946,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 /* ModuleDeclaration */ && parent.kind !== 187 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84122,7 +87966,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 263 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84149,7 +87993,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 === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 255 /* 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; @@ -84198,11 +88042,11 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -84212,13 +88056,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -84241,6 +88078,11 @@ var ts; enclosingDeclaration = input; } var oldDiag = getSymbolAccessibilityDiagnostic; + // Setup diagnostic-related flags before first potential `cleanup` call, otherwise + // We'd see a TDZ violation at runtime + var canProduceDiagnostic = ts.canProduceDiagnostics(input); + var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 /* TypeLiteral */ || input.kind === 185 /* MappedType */) && input.parent.kind !== 246 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -84249,76 +88091,77 @@ var ts; return cleanup(ts.createProperty(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); } } - var canProdiceDiagnostic = ts.canProduceDiagnostics(input); - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input); } if (ts.isTypeQueryNode(input)) { checkEntityNameVisibility(input.exprName, enclosingDeclaration); } - var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* 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 212 /* ExpressionWithTypeArguments */: { + case 215 /* 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 165 /* TypeReference */: { + case 168 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 161 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(161 /* 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 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(159 /* 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 159 /* GetAccessor */: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 162 /* GetAccessor */: { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); } - case 160 /* SetAccessor */: { - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 163 /* SetAccessor */: { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); } - case 155 /* PropertyDeclaration */: + case 158 /* 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 154 /* PropertySignature */: + case 157 /* 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 156 /* MethodSignature */: { + case 159 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 164 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 166 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -84326,13 +88169,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 151 /* TypeParameter */: { + case 154 /* 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 176 /* ConditionalType */: { + case 179 /* 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); @@ -84344,13 +88187,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 169 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 170 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 187 /* 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)); @@ -84360,13 +88203,13 @@ var ts; } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { - if (returnValue && canProdiceDiagnostic && ts.hasDynamicName(input)) { + if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) { checkName(input); } if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (canProdiceDiagnostic && !suppressNewDiagnosticContexts) { + if (canProduceDiagnostic && !suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } if (shouldEnterSuppressNewDiagnosticsContextContext) { @@ -84379,7 +88222,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 160 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -84389,7 +88232,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 259 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -84398,13 +88241,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 258 /* 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 === 73 /* Identifier */) { + if (input.expression.kind === 75 /* Identifier */) { return input; } else { @@ -84414,7 +88257,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(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -84439,10 +88282,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -84463,14 +88306,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 246 /* 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), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 245 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 243 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -84485,7 +88328,7 @@ var ts; fakespace_1.symbol = props[0].parent; var declarations = ts.mapDefined(props, function (p) { if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { - return undefined; + return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker); @@ -84518,17 +88361,17 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 248 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 249 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304 /* Ambient */) { + if (input.flags & 8388608 /* Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -84537,7 +88380,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(lateStatements.concat([createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -84564,7 +88407,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 244 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -84575,7 +88418,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73 /* Identifier */) { + if (param.name.kind === 75 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -84605,7 +88448,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 !== 97 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); @@ -84615,16 +88458,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(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87 /* ExtendsKeyword */) { + if (clause.token === 89 /* 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 === 97 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -84635,10 +88478,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 247 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -84657,7 +88500,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 248 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -84678,7 +88521,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 214 /* OmittedExpression */) { return; } if (e.name) { @@ -84728,55 +88571,36 @@ var ts; function ensureModifierFlags(node) { 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 === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 288 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; } return maskModifierFlags(node, mask, additions); } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } + function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) { var accessorType = getTypeAnnotationFromAccessor(node); - if (!accessorType && accessors.secondAccessor) { + if (!accessorType && node !== accessors.firstAccessor) { + accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor); + // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message + getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor); + } + if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) { accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor); // If we end up pulling the type from the second accessor, we also need to change the diagnostic context to get the expected error message getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor); } - var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3 /* MultiLineCommentTrivia */) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = [lines[0]].concat(ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; + return accessorType; } 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 === 87 /* ExtendsKeyword */ && t.expression.kind === 97 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 /* ExtendsKeyword */ && t.expression.kind === 99 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { return true; } return false; @@ -84801,7 +88625,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 162 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -84810,52 +88634,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 224 /* VariableStatement */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 165 /* ConstructSignature */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 241 /* VariableDeclaration */: + case 154 /* TypeParameter */: + case 215 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 179 /* ConditionalType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 187 /* ImportType */: return true; } return false; @@ -84984,7 +88808,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(319 /* Count */); + var enabledSyntaxKindFeatures = new Array(324 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -85191,7 +89015,7 @@ var ts; var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { if (lexicalEnvironmentFunctionDeclarations) { - statements = lexicalEnvironmentFunctionDeclarations.slice(); + statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } if (lexicalEnvironmentVariableDeclarations) { var statement = ts.createVariableStatement( @@ -85269,15 +89093,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -85287,22 +89111,21 @@ var ts; if (!onlyBuildInfo) { for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) { var sourceFile = sourceFiles_1[_a]; - var result = action(getOutputPathsFor(sourceFile, host, emitOnlyDtsFiles), sourceFile); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - /*@internal*/ - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -85325,7 +89148,7 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; @@ -85333,14 +89156,14 @@ var ts; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 289 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -85350,9 +89173,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -85393,11 +89214,13 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase) { + if (configFile.options.emitDeclarationOnly) + return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ? ".json" /* Json */ : @@ -85408,43 +89231,73 @@ var ts; outputFileName : undefined; } + function createAddOutput() { + var outputs; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } /*@internal*/ function getAllProjectOutputs(configFile, ignoreCase) { - var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) - continue; - if (configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; /*@internal*/ function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { @@ -85458,8 +89311,13 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase); if (jsFilePath) return jsFilePath; + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + continue; + if (ts.getEmitDeclarations(configFile.options)) { + return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); @@ -85467,7 +89325,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -85481,7 +89339,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -85577,17 +89435,16 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle || !declarationFilePath) { return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; // Setup and perform the transformation to retrieve declarations from the input files - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -85619,7 +89476,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -85627,12 +89484,8 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { - // Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule. - // But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow. - // Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the - // tslint directive can be all be removed. - var sourceFile = declarationTransform.transformed[0]; // tslint:disable-line + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288 /* SourceFile */) { + var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } @@ -85642,7 +89495,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -85654,8 +89507,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -85696,7 +89549,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 288 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -85803,10 +89656,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(288 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -85818,7 +89672,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(225 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -85857,7 +89711,7 @@ var ts; var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); }); var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host); var emitHost = { - getPrependNodes: ts.memoize(function () { return prependNodes.concat([ownPrependInput]); }), + getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }), getCanonicalFileName: host.getCanonicalFileName, getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); }, getCompilerOptions: function () { return config.options; }, @@ -85911,6 +89765,7 @@ var ts; useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, + redirectTargetsMap: ts.createMultiMap() }; emitFiles(ts.notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers)); @@ -85963,6 +89818,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -85991,9 +89848,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 288 /* SourceFile */: return printFile(node); + case 289 /* Bundle */: return printBundle(node); + case 290 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86162,8 +90019,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -86175,7 +90031,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86191,6 +90047,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { @@ -86200,21 +90058,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(4 /* Unspecified */, node); + var substitute = pipelineEmit(4 /* Unspecified */, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(2 /* IdentifierName */, node); + return pipelineEmit(2 /* IdentifierName */, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1 /* Expression */, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(1 /* Expression */, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -86229,12 +90098,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 288 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -86248,10 +90117,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -86271,279 +90143,279 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 290 /* UnparsedSource */: + case 284 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 283 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 287 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 156 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 293 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 294 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + case 299 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 222 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 223 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 267 /* JsxClosingElement */: + case 270 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 306 /* JSDocParameterTag */: - case 312 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 307 /* JSDocReturnTag */: - case 309 /* JSDocTypeTag */: - case 308 /* JSDocThisTag */: - case 305 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 301 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 310 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 311 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 304 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 299 /* JSDocSignature */: + case 303 /* JSDocSignature */: return emitJSDocSignature(node); - case 298 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 303 /* JSDocClassTag */: - case 300 /* JSDocTag */: + case 307 /* JSDocClassTag */: + case 304 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 297 /* JSDocComment */: + case 301 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -86561,83 +90433,83 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Reserved words - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 103 /* TrueKeyword */: - case 101 /* ThisKeyword */: - case 93 /* ImportKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 105 /* TrueKeyword */: + case 103 /* ThisKeyword */: + case 95 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 315 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 316 /* CommaListExpression */: + case 320 /* CommaListExpression */: return emitCommaList(node); } } @@ -86650,8 +90522,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -86665,8 +90540,8 @@ var ts; var helpers = getSortedEmitHelpers(sourceFile); if (!helpers) continue; - for (var _c = 0, helpers_3 = helpers; _c < helpers_3.length; _c++) { - var helper = helpers_3[_c]; + for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) { + var helper = helpers_4[_c]; if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) { bundledHelpers.set(helper.name, true); (result || (result = [])).push(helper.name); @@ -86677,7 +90552,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 289 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -86686,12 +90561,12 @@ var ts; for (var i = 0; i < numNodes; i++) { var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node; var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile; - var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile)); var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit; var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode); if (helpers) { - for (var _a = 0, helpers_4 = helpers; _a < helpers_4.length; _a++) { - var helper = helpers_4[_a]; + for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) { + var helper = helpers_5[_a]; if (!helper.scoped) { // Skip the helper if it can be skipped and the noEmitHelpers compiler // option is set, or if it can be imported and the importHelpers compiler @@ -86777,7 +90652,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -86810,7 +90685,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -86846,7 +90721,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 298 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -86908,7 +90783,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 162 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -86949,11 +90824,17 @@ var ts; // Types // function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -87085,18 +90966,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); - pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* QuestionToken */) { writePunctuation("?"); } } @@ -87176,66 +91056,57 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, - /*stopAfterLineBreak*/ false, - /*stopAtComments*/ true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { - var dotToken = ts.createToken(24 /* DotToken */); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(96 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(98 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -87275,22 +91146,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(84 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(107 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(126 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -87315,9 +91186,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* 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 */))); + return operand.kind === 206 /* PrefixUnaryExpression */ + && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) + || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -87330,7 +91201,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); @@ -87358,7 +91229,7 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(118 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(120 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -87435,7 +91306,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87443,8 +91314,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + emitTokenWithComment(86 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -87454,14 +91325,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(85 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -87470,14 +91341,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -87489,25 +91360,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -87515,7 +91386,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { emit(node); } else { @@ -87524,12 +91395,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(76 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -87557,12 +91428,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(100 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87570,7 +91441,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -87580,17 +91451,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -87599,13 +91470,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(82 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -87630,7 +91501,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -87802,7 +91673,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512 /* GlobalAugmentation */) { + if (~node.flags & 1024 /* GlobalAugmentation */) { writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); writeSpace(); } @@ -87810,7 +91681,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 248 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -87831,17 +91702,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -87850,12 +91721,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -87870,9 +91741,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -87883,42 +91754,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(81 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(83 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -87938,7 +91809,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -88016,7 +91887,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88027,13 +91898,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(75 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(77 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -88045,12 +91916,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -88061,7 +91932,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -88131,7 +92002,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 309 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88165,7 +92036,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88184,7 +92055,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 298 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -88318,8 +92189,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_19 = types; _d < types_19.length; _d++) { - var directive = types_19[_d]; + for (var _d = 0, types_20 = types; _d < types_20.length; _d++) { + var directive = types_20[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -88499,7 +92370,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -88537,8 +92408,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmbeddedStatement */, node); } else { emit(node); @@ -88945,6 +92815,9 @@ var ts; return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -88962,7 +92835,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89027,81 +92900,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 237 /* LabeledStatement */: + case 235 /* WithStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89110,12 +92983,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -89173,7 +93046,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (67220415 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { return false; } } @@ -89295,25 +93168,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 258 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -89356,11 +93229,12 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 314 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 318 /* 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 */; @@ -89384,7 +93258,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -89414,6 +93288,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -89627,6 +93502,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -89641,7 +93517,7 @@ var ts; 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 !== 314 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -89654,12 +93530,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 314 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -90022,6 +93899,9 @@ var ts; var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) { + ts.sysLog = function (s) { return log(s); }; + } return { watchFile: function (host, file, callback, pollingInterval, detailInfo1, detailInfo2) { return createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo); @@ -90377,7 +94257,7 @@ var ts; } ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { - var diagnostics = program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (ts.getEmitDeclarations(program.getCompilerOptions())) { ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } @@ -90566,8 +94446,8 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name = names_1[_i]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name = names_2[_i]; var result = void 0; if (cache.has(name)) { result = cache.get(name); @@ -90580,6 +94460,8 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + /* @internal */ + ts.inferredTypesContainingFile = "__inferred type names__.ts"; /** * Determines if program structure is upto date or needs to be recreated */ @@ -90654,7 +94536,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -90684,15 +94566,17 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -90728,7 +94612,7 @@ var ts; var resolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference).map(function (resolved) { + resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).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; @@ -90745,7 +94629,7 @@ var ts; } var resolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference); }; + resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 @@ -90774,8 +94658,13 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - var structuralIsReused = tryReuseStructureFromOldProgram(); + // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks + // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. + var structuralIsReused; + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -90783,20 +94672,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } } } @@ -90809,7 +94714,7 @@ var ts; 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(); - var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -90845,8 +94750,8 @@ var ts; // not part of the new program. if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || // old file wasnt redirect but new file is @@ -90862,12 +94767,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -90904,7 +94810,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -90931,9 +94839,14 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + // source file is allowed to be emitted and its not source of project reference redirect + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -91137,6 +95050,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; @@ -91227,7 +95146,7 @@ var ts; // moduleAugmentations has changed oldProgram.structureIsReused = 1 /* SafeModules */; } - if ((oldSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) { // dynamicImport has changed oldProgram.structureIsReused = 1 /* SafeModules */; } @@ -91264,28 +95183,26 @@ var ts; 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 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) { - oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + 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) { + oldProgram.structureIsReused = 1 /* SafeModules */; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } 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, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutions_1 = 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) { + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -91299,11 +95216,19 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping 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 (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined); + } + } // Set the file as found during node modules search if it was found that way in old progra, if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); @@ -91321,9 +95246,10 @@ var ts; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { - return __assign({ getPrependNodes: getPrependNodes, + return __assign(__assign({ getPrependNodes: getPrependNodes, getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -91332,7 +95258,7 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {}), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); } }); + } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -91388,15 +95314,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -91404,7 +95330,7 @@ var ts; // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones if (options.noEmitOnError) { - var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); + var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) { declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken); } @@ -91428,7 +95354,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -91503,15 +95430,16 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || - sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || + sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -91570,22 +95498,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 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 241 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -91593,41 +95521,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 110 /* ImplementsKeyword */) { + if (heritageClause.token === 112 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -91640,51 +95568,52 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* 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 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 224 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 158 /* 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 !== 117 /* StaticKeyword */) { + if (modifier.kind !== 119 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152 /* Parameter */: + case 155 /* 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 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 197 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -91701,24 +95630,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 126 /* DeclareKeyword */: - case 119 /* AbstractKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 129 /* DeclareKeyword */: + case 121 /* 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 117 /* StaticKeyword */: - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 119 /* StaticKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: } } } @@ -91793,8 +95722,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 /* Identifier */ - ? b.kind === 73 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 75 /* Identifier */ + ? b.kind === 75 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -91824,7 +95753,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -91875,7 +95804,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -91956,24 +95885,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, diagnostic].concat(args)) : ts.createCompilerDiagnostic.apply(void 0, [diagnostic].concat(args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -91996,15 +95919,26 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); + var file_2 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected - if (file_1 && options.forceConsistentCasingInFileNames) { + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -92013,34 +95947,35 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } // See if we need to reprocess the imports due to prior skipped imports - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -92058,14 +95993,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92096,7 +96024,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92119,8 +96047,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92135,8 +96073,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts or any of the non ts files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + // Ignore dts + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -92175,6 +96113,35 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + // Dont know which source file it means so return true? + var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); @@ -92209,9 +96176,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -92227,10 +96202,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -92242,7 +96223,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -92252,8 +96233,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -92261,14 +96241,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -92286,20 +96266,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { - return ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)); + if (!refFile) { + return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, [refFile, refPos, refEnd - refPos, message].concat(args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -92339,14 +96319,22 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152 /* JSDoc */)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -92365,12 +96353,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { var sourceFile = sourceFiles_2[_i]; if (!sourceFile.isDeclarationFile) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -92427,9 +96418,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -92464,17 +96452,18 @@ var ts; else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); } + if (options.noEmit && ts.isIncrementalCompilation(options)) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite"); + } verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -92590,8 +96579,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -92656,8 +96645,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -92684,7 +96706,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -92759,7 +96781,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -92818,6 +96840,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; /* @internal */ @@ -92863,9 +96891,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } /* @internal */ /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. @@ -92915,9 +96940,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93163,11 +97188,19 @@ var ts; } } else { - var emitOutput = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); - if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { - latestSignature = computeHash(emitOutput.outputFiles[0].text); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, + /*emitOnlyDtsFiles*/ true, cancellationToken, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); + var firstDts_1 = emitOutput_1.outputFiles && + programOfThisState.getCompilerOptions().declarationMap ? + emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : + emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + if (firstDts_1) { + ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + latestSignature = computeHash(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { - updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); + updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } else { @@ -93270,6 +97303,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; /** * For script files that contains only ambient external modules, although they are not actually external module files, * they can only be consumed via importing elements from them. Regular script files cannot consume them. Therefore, @@ -93373,6 +97407,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -93386,8 +97425,7 @@ var ts; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them - // With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -93410,7 +97448,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -93456,7 +97495,7 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } @@ -93465,7 +97504,7 @@ var ts; function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -93484,7 +97523,7 @@ var ts; } function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined }); } /** * Releases program and other related not needed properties @@ -93510,7 +97549,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -93542,7 +97582,6 @@ var ts; handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash); return affectedFile; } - seenAffectedFiles.set(affectedFile.path, true); affectedFilesIndex++; } // Remove the changed file from the change set @@ -93588,13 +97627,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -93613,7 +97657,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -93638,7 +97682,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -93656,15 +97700,40 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } /** * Iterate on referencing modules that export entities from affected file */ function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { return; } + if (!isChangedSignagure(state, affectedFile.path)) + return; + // Since isolated modules dont change js files, files affected by change in signature is itself + // But we need to cleanup semantic diagnostics and queue dts emit for affected files + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } + } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); // Go through exported modules from cache first @@ -93732,7 +97801,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -93742,6 +97811,9 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); + } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; } @@ -93753,8 +97825,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); + return { result: result, affected: affected }; + } + /** + * Returns the result with affected file + */ + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -93784,7 +97863,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -93879,7 +97958,7 @@ var ts; } function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) { var file = diagnostic.file; - return __assign({}, diagnostic, { file: file ? relativeToBuildInfo(file.path) : undefined }); + return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.path) : undefined }); } var BuilderProgramKind; (function (BuilderProgramKind) { @@ -93977,22 +98056,24 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94005,10 +98086,10 @@ var ts; affected = program; } } - return toAffectedFileResult(state, + return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94064,7 +98145,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94096,7 +98177,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94108,8 +98189,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94145,7 +98232,7 @@ var ts; compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return ts.isString(value) ? value : value[0]; }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true }; return { @@ -94271,15 +98358,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -94444,8 +98543,8 @@ var ts; !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]; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && @@ -94525,7 +98624,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -94736,6 +98835,10 @@ var ts; // Mark the file as needing re-evaluation of module resolution instead of using it blindly. resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + // When its a file with inferred types resolution, invalidate type reference directive resolution + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -94921,8 +99024,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -94938,20 +99042,26 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // Returns an import for each symlink and for the realpath. + /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) { var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); if (ambient) return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.fileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -94967,7 +99077,7 @@ var ts; var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; var ending = _b.ending, relativePreference = _b.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || + var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl || relativePreference === 0 /* Relative */) { return relativePath; @@ -95003,38 +99113,12 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. - // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** * Looks for existing imports that use symlinks to this module. @@ -95042,10 +99126,12 @@ var ts; */ function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? redirects.concat([importedFileName]) : [importedFileName]; + var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -95062,7 +99148,31 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + // Sort by paths closest to importing file Name directory + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -95093,16 +99203,18 @@ var ts; } } } - function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) { + function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { return undefined; } var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return ts.removeFileExtension(relativePath); + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs + ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) + : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -95111,24 +99223,27 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } // Simplify the full file path to something that can be resolved by Node. // If the module could be imported by a directory name, use that directory's name - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) @@ -95323,6 +99438,15 @@ var ts; ? newLine + newLine : newLine; } + /** + * Get locale specific time based on whether we are in test mode + */ + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -95330,7 +99454,7 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -95339,7 +99463,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -95532,7 +99656,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var result = originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); if (result) { result.version = computeHash.call(host, result.text); } @@ -95546,7 +99670,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -95580,7 +99706,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -95629,7 +99755,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -95722,7 +99848,7 @@ var ts; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - return getVersionedSourceFileByPath.apply(void 0, [fileName, toPath(fileName)].concat(args)); + return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args)); }; compilerHost.getSourceFileByPath = getVersionedSourceFileByPath; compilerHost.getNewLine = function () { return newLine; }; @@ -95750,10 +99876,22 @@ 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, redirectedReference) { return host.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveModuleNames.apply(host, args); + }) : (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - (function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }) : + (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return host.resolveTypeReferenceDirectives.apply(host, args); + }) : (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); @@ -95979,13 +100117,19 @@ var ts; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: - return reloadFileNamesFromConfigFile(); + ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); + reloadFileNamesFromConfigFile(); + break; case ts.ConfigFileProgramReloadLevel.Full: - return reloadConfigFile(); + ts.perfLogger.logStartUpdateProgram("FullConfigReload"); + reloadConfigFile(); + break; default: + ts.perfLogger.logStartUpdateProgram("SynchronizeProgram"); synchronizeProgram(); - return; + break; } + ts.perfLogger.logStopUpdateProgram("Done"); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -96169,12 +100313,22 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -96330,11 +100484,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -96343,8 +100500,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -96364,12 +100520,35 @@ var ts; } } function getBuildOrder(state) { - return state.buildOrder || - (state.buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }))); + return state.buildOrder || createStateBuildOrder(state); + } + function createStateBuildOrder(state) { + var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); + // Clear all to ResolvedConfigFilePaths cache to start fresh + state.resolvedConfigFilePaths.clear(); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var noopOnDelete = { onDeleteValue: ts.noop }; + // Config file cache + ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete); + ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete); + // Remove watches for the program no longer in the solution + if (state.watch) { + ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher }); + ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } }); + ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } }); + } + return state.buildOrder = buildOrder; } function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -96377,6 +100556,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -96393,7 +100573,7 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return originalGetSourceFile.call.apply(originalGetSourceFile, [compilerHost].concat(args)); + return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args)); }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache; state.readFileWithCache = readFileWithCache; compilerHost.getSourceFile = getSourceFileWithCache; @@ -96448,7 +100628,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -96620,7 +100800,7 @@ var ts; } function getSyntaxDiagnostics(cancellationToken) { ts.Debug.assertDefined(program); - handleDiagnostics(program.getConfigFileParsingDiagnostics().concat(program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); + handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); @@ -96788,6 +100968,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -96844,8 +101026,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97016,10 +101201,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97078,7 +101265,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -97243,16 +101430,22 @@ var ts; disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) ? + ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped : + errorProjects ? + successfulProjects ? + ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : + ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : + ts.ExitStatus.Success; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkupped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -97395,8 +101588,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -97428,6 +101621,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -97438,7 +101632,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args))); + state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); } function reportWatchStatus(state, message) { var args = []; @@ -97446,7 +101640,7 @@ var ts; args[_i - 2] = arguments[_i]; } if (state.hostWithWatch.onWatchStatusChange) { - state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, [message].concat(args)), state.host.getNewLine(), state.baseCompilerOptions); + state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions); } } function reportErrors(_a, errors) { @@ -97464,23 +101658,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -97513,13 +101717,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -97541,7 +101748,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -98181,6 +102387,8 @@ var ts; this.sendResponse({ kind: server.EventBeginInstallTypes, eventId: requestId, + // qualified explicitly to prevent occasional shadowing + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier typingsInstallerVersion: ts.version, projectName: req.projectName }); @@ -98228,7 +102436,9 @@ var ts; projectName: req.projectName, packagesToInstall: scopedTypings, installSuccess: ok, - typingsInstallerVersion: ts.version // tslint:disable-line no-unnecessary-qualifier (qualified explicitly to prevent occasional shadowing) + // qualified explicitly to prevent occasional shadowing + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier + typingsInstallerVersion: ts.version }; _this.sendResponse(response); } @@ -98545,7 +102755,7 @@ var ts; this.log.writeLine("Exec: " + command); } try { - var stdout = this.nodeExecSync(command, __assign({}, options, { encoding: "utf-8" })); + var stdout = this.nodeExecSync(command, __assign(__assign({}, options), { encoding: "utf-8" })); if (this.log.isEnabled()) { this.log.writeLine(" Succeeded. stdout:" + indent(ts.sys.newLine, stdout)); } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 6a691dc0af66d..5ad30ae8803d4 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -8553,7 +8553,7 @@ declare namespace ts.server { static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void, logErrors?: (message: string) => void): {} | undefined; isKnownTypesPackageName(name: string): boolean; installPackage(options: InstallPackageOptions): Promise; - private readonly typingsCache; + private get typingsCache(); getCompilationSettings(): CompilerOptions; getCompilerOptions(): CompilerOptions; getNewLine(): string;